libMesh
ghosting_functor.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_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 
192 
197 
203  _mesh (other._mesh)
204  {}
205 
209  virtual ~GhostingFunctor() = default;
210 
215  virtual std::unique_ptr<GhostingFunctor> clone () const
216 #ifndef LIBMESH_ENABLE_DEPRECATED
217  = 0;
218 #else
219  // Return nullptr for backward compatibility.
220  { libmesh_deprecated(); return nullptr; }
221 #endif
222 
227  virtual void set_mesh(const MeshBase * mesh) { _mesh = mesh; }
228 
229 #ifdef LIBMESH_ENABLE_PERIODIC
230  // Set PeriodicBoundaries to couple
232 #endif
233 
237  const MeshBase * get_mesh() const { libmesh_assert(_mesh); return _mesh; }
238 
243  typedef std::map<const Elem*, const CouplingMatrix*, CompareDofObjectsByPIDAndThenID> map_type;
244 
255  virtual void operator() (const MeshBase::const_element_iterator & range_begin,
256  const MeshBase::const_element_iterator & range_end,
258  map_type & coupled_elements) = 0;
259 
266  virtual void mesh_reinit () {};
267 
274  virtual void dofmap_reinit () {};
275 
286  virtual void redistribute () {};
287 
293  virtual void delete_remote_elements () {};
294 
295 protected:
296  const MeshBase * _mesh;
297 };
298 
299 } // namespace libMesh
300 
301 #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:2521
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 std::unique_ptr< GhostingFunctor > clone() const =0
A clone() is needed because GhostingFunctor can not be shared between different meshes.
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:80
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 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.