libMesh
ghosting_functor.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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_GHOSTING_FUNCTOR_H
21 #define LIBMESH_GHOSTING_FUNCTOR_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/id_types.h"
26 #include "libmesh/mesh_base.h"
27 #include "libmesh/reference_counted_object.h"
28 #include "libmesh/dof_object.h"
29 
30 // C++ Includes
31 #include <unordered_map>
32 
33 namespace libMesh
34 {
35 
36 // Forward Declarations
37 class CouplingMatrix;
38 class Elem;
39 #ifdef LIBMESH_ENABLE_PERIODIC
40 class PeriodicBoundaries;
41 #endif
42 
184 class GhostingFunctor : public ReferenceCountedObject<GhostingFunctor>
185 {
186 public:
187 
191  GhostingFunctor(): _mesh(nullptr) {}
192 
197 
203  _mesh (other._mesh)
204  {}
205 
209  virtual ~GhostingFunctor() = default;
210 
215  virtual std::unique_ptr<GhostingFunctor> clone () const
216  // Let us return nullptr for backward compatibility.
217  // We will come back to mark this function as pure virtual
218  // once the API upgrade is done.
219  { return nullptr; }
220 
225  virtual void set_mesh(const MeshBase * mesh) { _mesh = mesh; }
226 
227 #ifdef LIBMESH_ENABLE_PERIODIC
228  // Set PeriodicBoundaries to couple
230 #endif
231 
235  const MeshBase * get_mesh() const { libmesh_assert(_mesh); return _mesh; }
236 
241  typedef std::map<const Elem*, const CouplingMatrix*, CompareDofObjectsByPIDAndThenID> map_type;
242 
253  virtual void operator() (const MeshBase::const_element_iterator & range_begin,
254  const MeshBase::const_element_iterator & range_end,
256  map_type & coupled_elements) = 0;
257 
264  virtual void mesh_reinit () {};
265 
272  virtual void dofmap_reinit () {};
273 
284  virtual void redistribute () {};
285 
291  virtual void delete_remote_elements () {};
292 
293 protected:
294  const MeshBase * _mesh;
295 };
296 
297 } // namespace libMesh
298 
299 #endif // LIBMESH_GHOSTING_FUNCTOR_H
virtual void mesh_reinit()
GhostingFunctor subclasses which cache data will need to initialize that cache.
This abstract base class defines the interface by which library code and user code can report associa...
The definition of the const_element_iterator struct.
Definition: mesh_base.h:2216
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
const MeshBase * get_mesh() const
Return the mesh associated with ghosting functor.
virtual void operator()(const MeshBase::const_element_iterator &range_begin, const MeshBase::const_element_iterator &range_end, processor_id_type p, map_type &coupled_elements)=0
For the specified range of active elements, what other elements currently living (whether local or gh...
virtual void set_mesh(const MeshBase *mesh)
It should be called after cloning a ghosting functor.
MeshBase & mesh
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
virtual void redistribute()
GhostingFunctor subclasses with relatively long-lasting caches may want to redistribute those caches ...
GhostingFunctor()
Constructor.
The libMesh namespace provides an interface to certain functionality in the library.
virtual void dofmap_reinit()
For algebraic ghosting or coupling functors we also call dofmap_reinit() later, after dofs have been ...
uint8_t processor_id_type
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:75
GhostingFunctor(const MeshBase &mesh)
Constructor using mesh.
virtual void set_periodic_boundaries(const PeriodicBoundaries *)
libmesh_assert(ctx)
This class implements reference counting.
GhostingFunctor(const GhostingFunctor &other)
Copy Constructor.
virtual std::unique_ptr< GhostingFunctor > clone() const
A clone() is needed because GhostingFunctor can not be shared between different meshes.
virtual void delete_remote_elements()
GhostingFunctor subclasses with relatively long-lasting caches may want to delete the no-longer-relev...
virtual ~GhostingFunctor()=default
Virtual destructor; this is an abstract base class.