libMesh
mesh_communication.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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_tools.h"
27 
28 // C++ Includes
29 #include <unordered_map>
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class MeshBase;
36 class DistributedMesh;
37 
38 // This is for backwards compatibility, but if your code relies on
39 // forward declarations in our headers then fix it.
40 class ParallelMesh;
41 
51 {
52 public:
53 
58 
63 
67  void clear ();
68 
69  // /**
70  // * Finds all the processors that may contain
71  // * elements that neighbor my elements. This list
72  // * is guaranteed to include all processors that border
73  // * any of my elements, but may include additional ones as
74  // * well. This method computes bounding boxes for the
75  // * elements on each processor and checks for overlaps.
76  // */
77  // void find_neighboring_processors(const MeshBase &);
78 
85  void broadcast (MeshBase &) const;
86 
102  bool newly_coarsened_only = false) const;
103 
108 
113  void send_coarse_ghosts (MeshBase &) const;
114 
125  void gather (const processor_id_type root_id, DistributedMesh &) const;
126 
137 
152  void delete_remote_elements (DistributedMesh &, const std::set<Elem *> &) const;
153 
164  void assign_global_indices (MeshBase &) const;
165 
171 
176  template <typename ForwardIterator>
178  const ForwardIterator &,
179  const ForwardIterator &,
180  std::unordered_map<dof_id_type, dof_id_type> &) const;
181 
186  template <typename ForwardIterator>
187  void find_global_indices (const Parallel::Communicator & communicator,
188  const libMesh::BoundingBox &,
189  const ForwardIterator &,
190  const ForwardIterator &,
191  std::vector<dof_id_type> &) const;
192 
197 
198 #ifdef LIBMESH_ENABLE_AMR
199 
203 #endif // LIBMESH_ENABLE_AMR
204 
211 
218 
225 
232 
239 
245 };
246 
247 
248 // Related utilities
249 
250 // Ask a mesh's ghosting functors to insert into a set all elements
251 // that are either on or connected to processor id \p pid. Ask only
252 // for elements in the range from \p elem_it before \p elem_end;
253 // typically this may be mesh.active_pid_elements_*(pid)
254 void query_ghosting_functors(const MeshBase & mesh,
255  processor_id_type pid,
256  MeshBase::const_element_iterator elem_it,
257  MeshBase::const_element_iterator elem_end,
258  std::set<const Elem *, CompareElemIdsByLevel> & connected_elements);
259 
260 // Take a set of elements and insert all immediate
261 // children of elements in the given range
262 void connect_children(const MeshBase & mesh,
263  MeshBase::const_element_iterator elem_it,
264  MeshBase::const_element_iterator elem_end,
265  std::set<const Elem *, CompareElemIdsByLevel> & connected_elements);
266 
267 // Take a set of elements and insert all elements' ancestors and
268 // subactive descendants as well.
269 void connect_families(std::set<const Elem *, CompareElemIdsByLevel> & connected_elements);
270 
271 // Take a set of elements and create a set of connected nodes.
272 void reconnect_nodes (const std::set<const Elem *, CompareElemIdsByLevel> & connected_elements,
273  std::set<const Node *> & connected_nodes);
274 
275 
276 
277 //--------------------------------------------------------------
278 // MeshCommunication inline members
279 
280 
281 } // namespace libMesh
282 
283 #endif // LIBMESH_MESH_COMMUNICATION_H
libMesh::MeshCommunication::check_for_duplicate_global_indices
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.
Definition: mesh_communication_global_indices.C:577
libMesh::connect_children
void connect_children(const MeshBase &mesh, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
Definition: mesh_communication.C:169
libMesh::MeshCommunication::allgather
void allgather(DistributedMesh &mesh) const
This method takes an input DistributedMesh which may be distributed among all the processors.
Definition: mesh_communication.h:135
libMesh::MeshCommunication::delete_remote_elements
void delete_remote_elements(DistributedMesh &, const std::set< Elem * > &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
Definition: mesh_communication.C:1852
libMesh::BoundingBox
Defines a Cartesian bounding box by the two corner extremum.
Definition: bounding_box.h:40
libMesh::MeshCommunication::gather_neighboring_elements
void gather_neighboring_elements(DistributedMesh &) const
Definition: mesh_communication.C:540
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::MeshCommunication::find_local_indices
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.
Definition: mesh_communication_global_indices.C:674
libMesh::MeshCommunication::make_p_levels_parallel_consistent
void make_p_levels_parallel_consistent(MeshBase &)
Copy p levels of ghost elements from their local processors.
Definition: mesh_communication.C:1537
libMesh::reconnect_nodes
void reconnect_nodes(const std::set< const Elem *, CompareElemIdsByLevel > &connected_elements, std::set< const Node * > &connected_nodes)
Definition: mesh_communication.C:259
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::MeshCommunication::MeshCommunication
MeshCommunication()
Constructor.
Definition: mesh_communication.h:57
libMesh::MeshCommunication::make_node_ids_parallel_consistent
void make_node_ids_parallel_consistent(MeshBase &)
Assuming all ids on local nodes are globally unique, and assuming all processor ids are parallel cons...
Definition: mesh_communication.C:1460
libMesh::MeshCommunication::make_nodes_parallel_consistent
void make_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on ghost nodes from their local processors.
Definition: mesh_communication.C:1771
libMesh::MeshCommunication::send_coarse_ghosts
void send_coarse_ghosts(MeshBase &) const
Examine a just-coarsened mesh, and for any newly-coarsened elements, send the associated ghosted elem...
Definition: mesh_communication.C:915
libMesh::MeshCommunication::find_global_indices
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...
Definition: mesh_communication_global_indices.C:710
libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent
void make_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
Definition: mesh_communication.C:1664
libMesh::MeshCommunication::broadcast
void broadcast(MeshBase &) const
Definition: mesh_communication.C:1084
libMesh::MeshCommunication::redistribute
void redistribute(DistributedMesh &mesh, bool newly_coarsened_only=false) const
This method takes a parallel distributed mesh and redistributes the elements.
Definition: mesh_communication.C:285
libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent
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...
Definition: mesh_communication.C:1489
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::MeshCommunication::gather
void gather(const processor_id_type root_id, DistributedMesh &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
Definition: mesh_communication.C:1168
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::MeshCommunication::make_new_nodes_parallel_consistent
void make_new_nodes_parallel_consistent(MeshBase &)
Copy processor_ids and ids on new nodes from their local processors.
Definition: mesh_communication.C:1813
libMesh::MeshCommunication::clear
void clear()
Clears all data structures and resets to a pristine state.
Definition: mesh_communication.C:276
libMesh::query_ghosting_functors
void query_ghosting_functors(const MeshBase &mesh, processor_id_type pid, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
Definition: mesh_communication.C:138
libMesh::connect_families
void connect_families(std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
Definition: mesh_communication.C:192
libMesh::MeshCommunication::make_elems_parallel_consistent
void make_elems_parallel_consistent(MeshBase &)
Copy ids of ghost elements from their local processors.
Definition: mesh_communication.C:1513
libMesh::MeshCommunication::assign_global_indices
void assign_global_indices(MeshBase &) const
This method assigns globally unique, partition-agnostic indices to the nodes and elements in the mesh...
Definition: mesh_communication_global_indices.C:178
libMesh::DofObject::invalid_processor_id
static const 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:432
libMesh::MeshCommunication
This is the MeshCommunication class.
Definition: mesh_communication.h:50
libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent
void make_new_node_proc_ids_parallel_consistent(MeshBase &)
Assuming all processor ids on nodes touching local elements are parallel consistent,...
Definition: mesh_communication.C:1693
libMesh::DistributedMesh
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
Definition: distributed_mesh.h:50
libMesh::MeshCommunication::~MeshCommunication
~MeshCommunication()
Destructor.
Definition: mesh_communication.h:62