libMesh
Loading...
Searching...
No Matches
mesh_communication.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_MESH_COMMUNICATION_H
21#define LIBMESH_MESH_COMMUNICATION_H
22
23// Local Includes
24#include "libmesh/compare_elems_by_level.h"
25#include "libmesh/libmesh_common.h"
26#include "libmesh/mesh_base.h"
27
28// C++ Includes
29#include <set>
30#include <utility>
31#include <unordered_map>
32#include <vector>
33
34namespace libMesh
35{
36
37// Forward declarations
38class MeshBase;
39class DistributedMesh;
40
41// This is for backwards compatibility, but if your code relies on
42// forward declarations in our headers then fix it.
43class ParallelMesh;
44
54{
55public:
56
60 MeshCommunication () = default;
61
65 ~MeshCommunication () = default;
66
70 void clear ();
71
72 // /**
73 // * Finds all the processors that may contain
74 // * elements that neighbor my elements. This list
75 // * is guaranteed to include all processors that border
76 // * any of my elements, but may include additional ones as
77 // * well. This method computes bounding boxes for the
78 // * elements on each processor and checks for overlaps.
79 // */
80 // void find_neighboring_processors(const MeshBase &);
81
88 void broadcast (MeshBase &) const;
89
105 bool newly_coarsened_only = false) const;
106
111
116 void send_coarse_ghosts (MeshBase &) const;
117
128 void gather (const processor_id_type root_id, MeshBase &) const;
129
140
155 void delete_remote_elements (DistributedMesh &, const std::set<Elem *> &) const;
156
167 void assign_global_indices (MeshBase &) const;
168
174
179 template <typename ForwardIterator>
181 const ForwardIterator &,
182 const ForwardIterator &,
183 std::unordered_map<dof_id_type, dof_id_type> &) const;
184
189 template <typename ForwardIterator>
190 void find_global_indices (const Parallel::Communicator & communicator,
191 const libMesh::BoundingBox &,
192 const ForwardIterator &,
193 const ForwardIterator &,
194 std::vector<dof_id_type> &) const;
195
200
201#ifdef LIBMESH_ENABLE_AMR
206#endif // LIBMESH_ENABLE_AMR
207
214
221
227
234
241
248
254};
255
256
257// Related utilities
258
259// What to use to fill sets of connected nodes and elements
260typedef std::set<const Node *> connected_node_set_type;
261typedef std::set<const Elem *, CompareElemIdsByLevel> connected_elem_set_type;
262
263// Ask a mesh's ghosting functors to insert into a set all elements
264// that are either on or connected to processor id \p pid. Ask only
265// for elements in the range from \p elem_it before \p elem_end;
266// typically this may be mesh.active_pid_elements_*(pid)
271 connected_elem_set_type & connected_elements);
272
273// Take a set of elements and insert all immediate
274// children of elements in the given range
275void connect_children(const MeshBase & mesh,
278 connected_elem_set_type & connected_elements);
279
280// Take a set of elements and create a set of connected nodes.
281void reconnect_nodes (connected_elem_set_type & connected_elements,
282 connected_node_set_type & connected_nodes);
283
284// Take a set of elements and of nodes, and insert all
285// libMesh-mandated element of them: ancestor elements,
286// immediate children, subactive descendents of active elements,
287// interior_parents, nodes of any of those elements, and elements used
288// to constrain any of those nodes. This must be done recursively
289// (well, repeatedly; we unroll) in the general case, since a node
290// constraint can require a new element that can require other new
291// elements with new nodes with new constraints.
293 connected_elem_set_type & connected_elements,
294 connected_node_set_type & connected_nodes);
295
296// Takes already-examined sets and not-yet-examined sets, returns more sets
297// in need of examination (or empty sets if done).
298std::pair<connected_elem_set_type, connected_node_set_type>
300 const connected_elem_set_type & connected_elements,
301 const connected_node_set_type & connected_nodes,
302 const connected_elem_set_type & new_connected_elements,
303 const connected_node_set_type & new_connected_nodes);
304
305//--------------------------------------------------------------
306// MeshCommunication inline members
307
308
309} // namespace libMesh
310
311#endif // LIBMESH_MESH_COMMUNICATION_H
Defines a Cartesian bounding box by the two corner extremum.
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484
This is the MeshBase class.
Definition mesh_base.h:81
This is the MeshCommunication class.
void make_node_unique_ids_parallel_consistent(MeshBase &)
Assuming all unique_ids on local nodes are globally unique, and assuming all processor ids are parall...
void delete_remote_elements(DistributedMesh &, const std::set< Elem * > &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void check_for_duplicate_global_indices(MeshBase &) const
Throw an error if we have any index clashes in the numbering used by assign_global_indices.
void clear()
Clears all data structures and resets to a pristine state.
~MeshCommunication()=default
Destructor.
void assign_global_indices(MeshBase &) const
This method assigns globally unique, partition-agnostic indices to the nodes and elements in the mesh...
void find_local_indices(const libMesh::BoundingBox &, const ForwardIterator &, const ForwardIterator &, std::unordered_map< dof_id_type, dof_id_type > &) const
This method determines a locally unique, contiguous index for each object in the input range.
void find_global_indices(const Parallel::Communicator &communicator, const libMesh::BoundingBox &, const ForwardIterator &, const ForwardIterator &, std::vector< dof_id_type > &) const
This method determines a globally unique, partition-agnostic index for each object in the input range...
void redistribute(DistributedMesh &mesh, bool newly_coarsened_only=false) const
This method takes a parallel distributed mesh and redistributes the elements.
void make_elems_parallel_consistent(MeshBase &)
Copy ids of ghost elements from their local processors.
void allgather(MeshBase &mesh) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void make_node_bcids_parallel_consistent(MeshBase &)
Assuming all processor ids are parallel consistent, this function makes all ghost boundary ids on nod...
void send_coarse_ghosts(MeshBase &) const
Examine a just-coarsened mesh, and for any newly-coarsened elements, send the associated ghosted elem...
void make_p_levels_parallel_consistent(MeshBase &)
Copy p levels of ghost elements from their local processors.
void make_node_ids_parallel_consistent(MeshBase &)
Assuming all ids on local nodes are globally unique, and assuming all processor ids are parallel cons...
void make_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
void make_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on ghost nodes from their local processors.
void gather_neighboring_elements(DistributedMesh &) const
void gather(const processor_id_type root_id, MeshBase &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void make_new_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
MeshCommunication()=default
Constructor.
void make_new_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on new nodes from their local processors.
void broadcast(MeshBase &) const
This method takes a mesh (which is assumed to reside on processor 0) and broadcasts it to all the oth...
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
void reconnect_nodes(connected_elem_set_type &connected_elements, connected_node_set_type &connected_nodes)
std::set< const Elem *, CompareElemIdsByLevel > connected_elem_set_type
void query_ghosting_functors(const MeshBase &mesh, processor_id_type pid, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, connected_elem_set_type &connected_elements)
std::set< const Node * > connected_node_set_type
void connect_element_dependencies(const MeshBase &mesh, connected_elem_set_type &connected_elements, connected_node_set_type &connected_nodes)
void connect_children(const MeshBase &mesh, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, connected_elem_set_type &connected_elements)
uint8_t processor_id_type
Definition id_types.h:104
The definition of the const_element_iterator struct.
Definition mesh_base.h:2556