Advanced Multi-Physics (AMP)
On-Line Documentation
libmeshMesh.h
Go to the documentation of this file.
1#ifndef included_AMP_LibMesh
2#define included_AMP_LibMesh
3
4#include "AMP/mesh/Mesh.h"
5#include "AMP/mesh/libmesh/initializeLibMesh.h"
6
7// LibMesh include
9#include "libmesh/libmesh_config.h"
10#undef LIBMESH_ENABLE_REFERENCE_COUNTING
11#include "libmesh/mesh.h"
12#include "libmesh/node.h"
14
15
16namespace AMP::Mesh {
17
18
19class libmeshMeshElement;
20class libmeshElemIterator;
21
22
45class libmeshMesh final : public Mesh
46{
47public:
55 explicit libmeshMesh( std::shared_ptr<const MeshParameters> params );
56
67 explicit libmeshMesh( std::shared_ptr<libMesh::Mesh> mesh,
68 const std::string &name,
69 std::shared_ptr<libMesh::Parallel::Communicator> libMeshComm = nullptr );
70
72 virtual ~libmeshMesh();
73
74
76 std::string meshClass() const override;
77
78
80 std::unique_ptr<Mesh> clone() const override;
81
82
91 static size_t estimateMeshSize( std::shared_ptr<const MeshParameters> params );
92
93
100 static size_t maxProcs( std::shared_ptr<const MeshParameters> params );
101
102
103 /* Return the number of local element of the given type
104 * \param type Geometric type
105 */
106 size_t numLocalElements( const GeomType type ) const override;
107
108
109 /* Return the global number of elements of the given type
110 * \param type Geometric type
111 */
112 size_t numGlobalElements( const GeomType type ) const override;
113
114
115 /* Return the number of ghost elements of the given type on the current processor
116 * \param type Geometric type
117 * \param gcw Desired ghost cell width
118 */
119 size_t numGhostElements( const GeomType type, const int gcw ) const override;
120
121
123 bool operator==( const Mesh &mesh ) const override;
124
125
132 MeshIterator getIterator( const GeomType type, const int gcw = 0 ) const override;
133
134
142 const int gcw = 0 ) const override;
143
144
150 std::vector<int> getBoundaryIDs() const override;
151
152
162 virtual MeshIterator
163 getBoundaryIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
164
170 std::vector<int> getBlockIDs() const override;
171
172
180 virtual MeshIterator
181 getBlockIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
182
183
192 std::unique_ptr<MeshElement> getElement( const MeshElementID &id ) const override;
193
194
202 Mesh::Movable isMeshMovable() const override;
203
204
214 uint64_t positionHash() const override;
215
216
225 void displaceMesh( const std::vector<double> &x ) override;
226
227
229 inline std::shared_ptr<libMesh::Mesh> getlibMesh() const { return d_libMesh; }
230
231
240 void displaceMesh( std::shared_ptr<const AMP::LinearAlgebra::Vector> x ) override;
241
242
248 void writeRestart( int64_t fid ) const override;
249
250
251protected:
257 std::vector<libMesh::Node *> getNeighborNodes( const MeshElementID & ) const;
258
259
260private:
261 // Friend functions to access protected functions
262 friend class libmeshMeshElement;
263
264 typedef std::shared_ptr<std::vector<libmeshMeshElement>> ElemListPtr;
265
266
267private: // Functions use for initialization
275
276private:
277 // Index indicating number of times the position has changed
278 uint64_t d_pos_hash;
279
280 // libMesh objects
281 std::shared_ptr<libMesh::Mesh> d_libMesh;
282 std::shared_ptr<libMesh::Parallel::Communicator> d_libMeshComm;
283
284 // Some basic internal data
285 std::vector<size_t> n_local, n_global, n_ghost;
286 std::shared_ptr<initializeLibMesh> libmeshInit;
287
288 // Data used to store the node neighbor lists
289 std::vector<unsigned int> neighborNodeIDs;
290 std::vector<std::vector<libMesh::Node *>> neighborNodes;
291
292 // Data used to store elements that libmesh doesn't create
295
296 // Data used to store the boundary elements
297 std::map<std::pair<int, GeomType>, ElemListPtr> d_boundarySets;
298
299 // Data used to store the surface elements
300 std::vector<ElemListPtr> d_localSurfaceElements;
301 std::vector<ElemListPtr> d_ghostSurfaceElements;
302
303 // Data used to store block info
304 std::vector<int> d_block_ids;
305};
306
307} // namespace AMP::Mesh
308
309#endif
A class used to iterate over elements in a Mesh.
A class used to abstract away mesh from an application.
Definition Mesh.h:57
Movable
Enumeration for basic mesh-based quantities.
Definition Mesh.h:73
A derived class used to define a mesh element.
A concrete mesh class for libMesh.
Definition libmeshMesh.h:46
std::unique_ptr< MeshElement > getElement(const MeshElementID &id) const override
Return a mesh element given it's id.
std::shared_ptr< initializeLibMesh > libmeshInit
std::vector< size_t > n_local
size_t numLocalElements(const GeomType type) const override
void writeRestart(int64_t fid) const override
Write restart data to file.
std::vector< unsigned int > neighborNodeIDs
uint64_t positionHash() const override
Identify if the position has moved.
Mesh::Movable isMeshMovable() const override
Is the mesh movable.
std::shared_ptr< libMesh::Mesh > d_libMesh
std::unique_ptr< Mesh > clone() const override
Function to copy the mesh (allows use to proply copy the derived class)
std::vector< ElemListPtr > d_localSurfaceElements
virtual ~libmeshMesh()
Deconstructor.
libmeshMesh(std::shared_ptr< const MeshParameters > params)
Read in mesh files, partition domain, and prepare environment for simulation.
void displaceMesh(std::shared_ptr< const AMP::LinearAlgebra::Vector > x) override
Displace the entire mesh.
std::vector< size_t > n_ghost
libmeshMesh(std::shared_ptr< libMesh::Mesh > mesh, const std::string &name, std::shared_ptr< libMesh::Parallel::Communicator > libMeshComm=nullptr)
Constructor to create a libmeshMesh object from a libMesh mesh.
virtual MeshIterator getSurfaceIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects on the surface.
ElemListPtr d_localElements[4]
std::shared_ptr< libMesh::Mesh > getlibMesh() const
Return the underlying libMesh object.
static size_t estimateMeshSize(std::shared_ptr< const MeshParameters > params)
Estimate the number of elements in the mesh.
ElemListPtr generateGhosts() const
bool operator==(const Mesh &mesh) const override
Check if two meshes are equal.
static size_t maxProcs(std::shared_ptr< const MeshParameters > params)
Return the maximum number of processors that can be used with the mesh.
std::vector< ElemListPtr > d_ghostSurfaceElements
void displaceMesh(const std::vector< double > &x) override
Displace the entire mesh.
MeshIterator getIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects.
ElemListPtr d_ghostElements[4]
virtual MeshIterator getBoundaryIDIterator(const GeomType type, const int id, const int gcw=0) const override
Return an MeshIterator over the given geometric objects on the given boundary ID set.
size_t numGhostElements(const GeomType type, const int gcw) const override
std::vector< libMesh::Node * > getNeighborNodes(const MeshElementID &) const
std::shared_ptr< std::vector< libmeshMeshElement > > ElemListPtr
ElemListPtr generateGhostElements(GeomType) const
std::vector< size_t > n_global
std::string meshClass() const override
Return a string with the mesh class name.
size_t numGlobalElements(const GeomType type) const override
virtual MeshIterator getBlockIDIterator(const GeomType type, const int id, const int gcw=0) const override
Return an MeshIterator over the given geometric objects on the given block ID set.
std::vector< std::vector< libMesh::Node * > > neighborNodes
std::vector< int > getBoundaryIDs() const override
Return the list of all boundary ID sets in the mesh.
std::vector< int > d_block_ids
std::vector< int > getBlockIDs() const override
Return the list of all boundary ID sets in the mesh.
ElemListPtr generateLocalElements(GeomType) const
libmeshElemIterator localElements() const
std::map< std::pair< int, GeomType >, ElemListPtr > d_boundarySets
std::shared_ptr< libMesh::Parallel::Communicator > d_libMeshComm
#define DISABLE_WARNINGS
Re-enable warnings.
#define ENABLE_WARNINGS
Suppress all warnings.
GeomType
Enumeration for basic mesh-based quantities.
Definition MeshID.h:12
A structure used to identify the mesh element.
Definition MeshID.h:156



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:40.
Comments on this page