Debian Codegraph @

include/deal.II/particles/partitioner.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2020 - 2025 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_particles_partitioner_h
16 #define dealii_particles_partitioner_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/particles/particle_iterator.h>
21
22 #include <vector>
23
24
25 DEAL_II_NAMESPACE_OPEN
26
27 namespace Particles
28 {
29 namespace internal
30 {
31 /**
32 * Cache structure used to store the elements which are required to
33 * exchange the particle information (location and properties) across
34 * processors in order to update the ghost particles.
35 *
36 * This structure should only be used when one wishes to carry out work
37 * using the particles without calling
38 * sort_particles_into_subdomain_and_cells at every iteration. This is
39 * useful when particle-particle interaction occurs at a different time
40 * scale than particle-mesh interaction.
41 */
42 template <int dim, int spacedim>
43 struct GhostParticlePartitioner
44 {
45 /**
46 * A type that can be used to iterate over all particles in the domain.
47 */
48 using particle_iterator = ParticleIterator<dim, spacedim>;
49
50 /**
51 * Indicates if the cache has been built to prevent updating particles
52 * with an invalid cache.
53 */
54 bool valid = false;
55
56 /**
57 * Vector of the subdomain id of all possible neighbors of the current
58 * subdomain.
59 */
60 std::vector<types::subdomain_id> neighbors;
61
62 /**
63 * Vector of size (neighbors.size()+1) used to store the start and the
64 * end point of the data that must go from the current subdomain to the
65 * neighbors. For neighbor i, send_pointers[i] indicates the beginning
66 * and send_pointers[i+1] indicates the end of the data that must be
67 * sent.
68 */
69 std::vector<unsigned int> send_pointers;
70
71 /**
72 * Set of particles that currently live in the ghost cells of the local
73 * domain, organized by the subdomain_id. These
74 * particles are equivalent to the ghost entries in distributed vectors.
75 */
76 std::map<types::subdomain_id, std::vector<particle_iterator>>
77 ghost_particles_by_domain;
78
79 /**
80 * Vector of size (neighbors.size()+1) used to store the start and the
81 * end point of the data that must be received from neighbor[i] on
82 * the current subdomain. For neighbor i, recv_pointers[i] indicate the
83 * beginning and recv_pointers[i+1] indicates the end of the data that
84 * must be received.
85 *
86 * This structure is similar to
87 * Utilities::MPI::Partitioner::import_targets when combined with
88 * neighbors.
89 */
90 std::vector<unsigned int> recv_pointers;
91
92 /**
93 * Vector of ghost particles in the order in which they are inserted
94 * in the multimap used to store particles on the triangulation. This
95 * information is used to update the ghost particle information
96 * without clearing the multimap of ghost particles, thus greatly
97 * reducing the cost of exchanging the ghost particles information.
98 */
99 std::vector<particle_iterator> ghost_particles_iterators;
100
101 /**
102 * Temporary storage that holds the data of the particles to be sent
103 * to other processors to update the ghost particles information
104 * in update_ghost_particles()
105 * send_recv_particles_properties_and_location()
106 */
107 std::vector<char> send_data;
108
109 /**
110 * Temporary storage that holds the data of the particles to receive
111 * the ghost particles information from other processors in
112 * update_ghost_particles()
113 * send_recv_particles_properties_and_location()
114 */
115 std::vector<char> recv_data;
116 };
117 } // namespace internal
118
119 } // namespace Particles
120
121 DEAL_II_NAMESPACE_CLOSE
122
123 #endif