Advanced Multi-Physics (AMP)
On-Line Documentation
MultiMesh.h
Go to the documentation of this file.
1#ifndef included_AMP_MultiMesh
2#define included_AMP_MultiMesh
3
4#include "AMP/mesh/Mesh.h"
5#include "AMP/mesh/loadBalance/loadBalanceSimulator.h"
6
7namespace AMP::Mesh {
8
9
26class MultiMesh final : public Mesh
27{
28public:
37 explicit MultiMesh( std::shared_ptr<const MeshParameters> params );
38
39
49 MultiMesh( const std::string &name,
50 const AMP_MPI &comm,
51 const std::vector<std::shared_ptr<Mesh>> &meshes,
52 bool checkComm = true );
53
54
56 virtual ~MultiMesh();
57
58
60 std::string meshClass() const override;
61
62
64 std::unique_ptr<Mesh> clone() const override;
65
74 static size_t estimateMeshSize( std::shared_ptr<const MeshParameters> params );
75
82 static size_t maxProcs( std::shared_ptr<const MeshParameters> params );
83
84 /* Return the number of local element of the given type
85 * \param type Geometric type
86 */
87 size_t numLocalElements( const GeomType type ) const override;
88
89
90 /* Return the global number of elements of the given type.
91 * Note: for a multimesh this will require global communication.
92 * To avoid this in the future we would need to cache the value, and register
93 * some type of listener to check if the value changed on any sub meshes.
94 * \param type Geometric type
95 */
96 size_t numGlobalElements( const GeomType type ) const override;
97
98
99 /* Return the number of ghost elements of the given type on the current processor
100 * \param type Geometric type
101 */
102 size_t numGhostElements( const GeomType type, const int gcw ) const override;
103
104
113 std::shared_ptr<Mesh> Subset( MeshID meshID ) const override;
114
115
124 virtual std::shared_ptr<Mesh> Subset( const MeshIterator &iterator,
125 bool isGlobal = true ) const override;
126
127
139 std::shared_ptr<Mesh> Subset( std::string name ) const override;
140
141
148 MeshIterator getIterator( const GeomType type, const int gcw = 0 ) const override;
149
150
158 const int gcw = 0 ) const override;
159
160
166 std::vector<int> getBoundaryIDs() const override;
167
168
178 virtual MeshIterator
179 getBoundaryIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
180
186 std::vector<int> getBlockIDs() const override;
187
188
196 virtual MeshIterator
197 getBlockIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
198
199
206 bool isMember( const MeshElementID &id ) const override;
207
208
215 MeshIterator isMember( const MeshIterator &it ) const override;
216
217
227 MeshElementPtr getElement( const MeshElementID &id ) const override;
228
229
238 const GeomType type ) const override;
239
240
242 inline bool isBaseMesh() const override { return false; }
243
244
246 bool operator==( const Mesh &mesh ) const override;
247
248
253 std::vector<MeshID> getAllMeshIDs() const override;
254
255
261 std::vector<MeshID> getBaseMeshIDs() const override;
262
263
268 std::vector<MeshID> getLocalMeshIDs() const override;
269
270
275 std::vector<MeshID> getLocalBaseMeshIDs() const override;
276
277
281 bool containsElement( const MeshElementID &id ) const override;
282
283
287 virtual std::vector<std::shared_ptr<AMP::Mesh::Mesh>> getMeshes();
288
289
293 virtual std::vector<std::shared_ptr<const AMP::Mesh::Mesh>> getMeshes() const;
294
295
303 Mesh::Movable isMeshMovable() const override;
304
305
315 uint64_t positionHash() const override;
316
317
326 void displaceMesh( const std::vector<double> &x ) override;
327
336 void displaceMesh( std::shared_ptr<const AMP::LinearAlgebra::Vector> x ) override;
337
338
339 // Needed to prevent problems with virtual functions
340 using Mesh::Subset;
341
342
343public: // Default constructors
344 MultiMesh() = delete;
345 explicit MultiMesh( MultiMesh &&rhs ) = default;
346 explicit MultiMesh( const MultiMesh &rhs );
347 MultiMesh &operator=( MultiMesh &&rhs ) = delete;
348 MultiMesh &operator=( const MultiMesh &rhs ) = delete;
349
350public: // Functions to help with load balancing
357 static std::vector<AMP_MPI> createComms( const AMP_MPI &comm,
358 const std::vector<std::vector<int>> &groups );
359
360
361public:
363 static std::vector<std::shared_ptr<AMP::Database>>
364 createDatabases( std::shared_ptr<const AMP::Database> database );
365
366
367public: // Write/read restart data
368 void registerChildObjects( AMP::IO::RestartManager *manager ) const override;
369 void writeRestart( int64_t ) const override;
371
372
373private:
375
376private:
377 std::vector<std::shared_ptr<Mesh>> d_meshes;
379};
380
381} // namespace AMP::Mesh
382
383#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
Class to manage reading/writing restart data.
A pointer class to wrap a MeshElementVector.
A class used to iterate over elements in a Mesh.
A class used to abstract away mesh from an application.
Definition Mesh.h:57
std::unique_ptr< MeshElement > MeshElementPtr
Pointer to MeshElement and MeshElementVector.
Definition Mesh.h:69
MeshID meshID() const
Get the mesh ID.
Definition Mesh.h:344
Movable
Enumeration for basic mesh-based quantities.
Definition Mesh.h:73
virtual std::shared_ptr< Mesh > Subset(MeshID meshID) const
Subset a mesh given a MeshID.
A concrete mesh class for a multi-mesh.
Definition MultiMesh.h:27
MeshIterator isMember(const MeshIterator &it) const override
Check if elements are in the mesh.
std::vector< int > getBoundaryIDs() const override
Return the list of all boundary ID sets in the mesh.
MeshElementPtr getElement(const MeshElementID &id) const override
Return a mesh element given it's id.
virtual std::shared_ptr< Mesh > Subset(const MeshIterator &iterator, bool isGlobal=true) const override
Subset a mesh given a MeshIterator.
static size_t estimateMeshSize(std::shared_ptr< const MeshParameters > params)
Estimate the number of elements in the mesh.
MultiMesh(int64_t, AMP::IO::RestartManager *)
std::vector< MeshID > getAllMeshIDs() const override
std::string meshClass() const override
Return a string with the mesh class name.
Mesh::Movable isMeshMovable() const override
Is the mesh movable.
void displaceMesh(std::shared_ptr< const AMP::LinearAlgebra::Vector > x) override
Displace the entire mesh.
virtual MeshIterator getSurfaceIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects on the surface.
static std::vector< AMP_MPI > createComms(const AMP_MPI &comm, const std::vector< std::vector< int > > &groups)
A function to compute the AMP_MPI comms for each mesh.
std::shared_ptr< Mesh > Subset(MeshID meshID) const override
Subset a mesh given a MeshID.
uint64_t positionHash() const override
Identify if the position has moved.
static std::vector< std::shared_ptr< AMP::Database > > createDatabases(std::shared_ptr< const AMP::Database > database)
Function to create the databases for the meshes within the multimesh.
std::unique_ptr< Mesh > clone() const override
Function to clone the mesh (allows use to properly copy the derived class)
void writeRestart(int64_t) const override
Write restart data to file.
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register child objects.
bool operator==(const Mesh &mesh) const override
Check if two meshes are equal.
std::vector< std::shared_ptr< Mesh > > d_meshes
A list of all meshes in the multimesh.
Definition MultiMesh.h:377
MultiMesh(std::shared_ptr< const MeshParameters > params)
Default constructor.
MultiMesh & operator=(MultiMesh &&rhs)=delete
MultiMesh(const std::string &name, const AMP_MPI &comm, const std::vector< std::shared_ptr< Mesh > > &meshes, bool checkComm=true)
Constructor to create a MultiMesh from existing meshes.
virtual std::vector< std::shared_ptr< AMP::Mesh::Mesh > > getMeshes()
bool containsElement(const MeshElementID &id) const override
Mesh::Movable d_isMovable
Are all meshes movable.
Definition MultiMesh.h:378
MeshIterator getIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects.
bool isMember(const MeshElementID &id) const override
Check if an element is in the mesh.
MultiMesh(const MultiMesh &rhs)
static size_t maxProcs(std::shared_ptr< const MeshParameters > params)
Return the maximum number of processors that can be used with the mesh.
MultiMesh(MultiMesh &&rhs)=default
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.
virtual std::vector< std::shared_ptr< const AMP::Mesh::Mesh > > getMeshes() const
std::vector< int > getBlockIDs() const override
Return the list of all boundary ID sets in the mesh.
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.
virtual ~MultiMesh()
Deconstructor.
size_t numLocalElements(const GeomType type) const override
std::shared_ptr< Mesh > Subset(std::string name) const override
Subset a mesh given a mesh name.
size_t numGhostElements(const GeomType type, const int gcw) const override
std::vector< MeshID > getBaseMeshIDs() const override
virtual ElementListPtr getElementParents(const MeshElement &elem, const GeomType type) const override
Return the parent elements of the given mesh element.
MultiMesh & operator=(const MultiMesh &rhs)=delete
void displaceMesh(const std::vector< double > &x) override
Displace the entire mesh.
size_t numGlobalElements(const GeomType type) const override
std::vector< MeshID > getLocalBaseMeshIDs() const override
std::vector< MeshID > getLocalMeshIDs() const override
bool isBaseMesh() const override
Is the current mesh a base mesh.
Definition MultiMesh.h:242
GeomType
Enumeration for basic mesh-based quantities.
Definition MeshID.h:12
A structure used to identify the mesh element.
Definition MeshID.h:156
A structure used to identify the mesh.
Definition MeshID.h:31



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