Advanced Multi-Physics (AMP)
On-Line Documentation
SubsetMesh.h
Go to the documentation of this file.
1#ifndef included_AMP_SubsetMesh
2#define included_AMP_SubsetMesh
3
4#include "AMP/mesh/Mesh.h"
5
6#include <memory>
7
8#include <map>
9
10namespace AMP::Mesh {
11
12
18class SubsetMesh : public Mesh
19{
20public:
30 static std::shared_ptr<Mesh> create( std::shared_ptr<const Mesh> mesh,
31 const AMP::Mesh::MeshIterator &iterator,
32 bool isGlobal );
33
34
36 virtual ~SubsetMesh();
37
38
47 std::shared_ptr<Mesh> Subset( MeshID meshID ) const override;
48
49
61 std::shared_ptr<Mesh> Subset( std::string name ) const override;
62
63
65 std::string meshClass() const override;
66
67
69 std::unique_ptr<Mesh> clone() const override;
70
71
72 /* Return the number of local element of the given type
73 * \param type Geometric type
74 */
75 size_t numLocalElements( const GeomType type ) const override;
76
77
78 /* Return the global number of elements of the given type
79 * Note: depending on the mesh this routine may require global communication across the mesh.
80 * \param type Geometric type
81 */
82 size_t numGlobalElements( const GeomType type ) const override;
83
84
85 /* Return the number of ghost elements of the given type on the current processor
86 * \param type Geometric type
87 */
88 size_t numGhostElements( const GeomType type, const int gcw ) const override;
89
90
97 MeshIterator getIterator( const GeomType type, const int gcw = 0 ) const override;
98
99
107 const int gcw = 0 ) const override;
108
109
115 std::vector<int> getBoundaryIDs() const override;
116
117
127 virtual MeshIterator
128 getBoundaryIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
129
130
136 std::vector<int> getBlockIDs() const override;
137
138
146 virtual MeshIterator
147 getBlockIDIterator( const GeomType type, const int id, const int gcw = 0 ) const override;
148
149
156 bool isMember( const MeshElementID &id ) const override;
157
158
165 MeshIterator isMember( const MeshIterator &it ) const override;
166
167
177 MeshElementPtr getElement( const MeshElementID &id ) const override;
178
179
187 ElementListPtr getElementParents( const MeshElement &elem, const GeomType type ) const override;
188
189
191 inline bool isBaseMesh() const override { return false; }
192
193
195 bool operator==( const Mesh &mesh ) const override;
196
197
202 std::vector<MeshID> getAllMeshIDs() const override;
203
204
210 std::vector<MeshID> getBaseMeshIDs() const override;
211
212
217 std::vector<MeshID> getLocalMeshIDs() const override;
218
219
224 std::vector<MeshID> getLocalBaseMeshIDs() const override;
225
226
230 bool containsElement( const MeshElementID &id ) const override;
231
232
240 Mesh::Movable isMeshMovable() const override;
241
242
252 uint64_t positionHash() const override;
253
254
263 void displaceMesh( const std::vector<double> &x ) override;
264
265
274 void displaceMesh( std::shared_ptr<const AMP::LinearAlgebra::Vector> x ) override;
275
276
282 void writeRestart( int64_t fid ) const override;
283
284
285 // Needed to prevent problems with virtual functions
286 using Mesh::Subset;
287
288
289protected:
291 SubsetMesh( std::shared_ptr<const Mesh> mesh,
292 const AMP::Mesh::MeshIterator &iterator,
293 bool isGlobal );
294
295
296protected:
297 using ElementList = std::vector<std::unique_ptr<MeshElement>>;
298 using ElementListPtr = std::shared_ptr<ElementList>;
299
300 // Data to store the id sets
302 int id;
304 int gcw;
305 inline bool operator==( const map_id_struct &rhs ) const
306 {
307 return id == rhs.id && type == rhs.type && gcw == rhs.gcw;
308 }
309 inline bool operator!=( const map_id_struct &rhs ) const
310 {
311 return id != rhs.id && type != rhs.type && gcw != rhs.gcw;
312 }
313 inline bool operator>=( const map_id_struct &rhs ) const
314 {
315 if ( id != rhs.id ) {
316 return id > rhs.id;
317 }
318 if ( type != rhs.type ) {
319 return type > rhs.type;
320 }
321 return gcw >= rhs.gcw;
322 }
323 inline bool operator>( const map_id_struct &rhs ) const
324 {
325 if ( id != rhs.id ) {
326 return id > rhs.id;
327 }
328 if ( type != rhs.type ) {
329 return type > rhs.type;
330 }
331 return gcw > rhs.gcw;
332 }
333 inline bool operator<( const map_id_struct &rhs ) const { return !operator>=( rhs ); }
334 inline bool operator<=( const map_id_struct &rhs ) const { return !operator>( rhs ); }
335 };
336
337
338protected: // Member data
339 std::shared_ptr<const Mesh> d_parentMesh; // Parent mesh for the subset
340 MeshID d_parentMeshID; // Parent mesh id
341 std::vector<size_t> N_global; // Number of global elements
342 std::vector<std::vector<ElementListPtr>> d_elements; // Elements in the subset [type][gcw][elem]
343 std::vector<std::vector<ElementListPtr>> d_surface; // Elements on the surface [type][gcw][elem]
344 std::vector<int> d_boundaryIdSets;
345 std::map<map_id_struct, ElementListPtr> d_boundarySets;
346 std::vector<int> d_blockIdSets;
347 std::map<map_id_struct, ElementListPtr> d_blockSets;
348};
349
350} // namespace AMP::Mesh
351
352#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
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 class used to handle a subset mesh.
Definition SubsetMesh.h:19
std::vector< int > getBoundaryIDs() const override
Return the list of all boundary ID sets in the mesh.
size_t numLocalElements(const GeomType type) const override
void displaceMesh(const std::vector< double > &x) override
Displace the entire mesh.
SubsetMesh(std::shared_ptr< const Mesh > mesh, const AMP::Mesh::MeshIterator &iterator, bool isGlobal)
Default constructor.
std::shared_ptr< Mesh > Subset(MeshID meshID) const override
Subset a mesh given a MeshID.
bool isMember(const MeshElementID &id) const override
Check if an element is in the mesh.
virtual ~SubsetMesh()
Deconstructor.
std::vector< MeshID > getAllMeshIDs() const override
std::map< map_id_struct, ElementListPtr > d_blockSets
Definition SubsetMesh.h:347
std::vector< MeshID > getBaseMeshIDs() const override
std::shared_ptr< Mesh > Subset(std::string name) const override
Subset a mesh given a mesh name.
Mesh::Movable isMeshMovable() const override
Is the mesh movable.
std::vector< MeshID > getLocalMeshIDs() const override
std::map< map_id_struct, ElementListPtr > d_boundarySets
Definition SubsetMesh.h:345
void displaceMesh(std::shared_ptr< const AMP::LinearAlgebra::Vector > x) override
Displace the entire mesh.
bool operator==(const Mesh &mesh) const override
Check if two meshes are equal.
uint64_t positionHash() const override
Identify if the position has moved.
std::vector< int > d_blockIdSets
Definition SubsetMesh.h:346
void writeRestart(int64_t fid) const override
Write restart data to file.
bool isBaseMesh() const override
Is the current mesh a base mesh.
Definition SubsetMesh.h:191
MeshElementPtr getElement(const MeshElementID &id) const override
Return a mesh element given it's id.
size_t numGhostElements(const GeomType type, const int gcw) const override
std::shared_ptr< ElementList > ElementListPtr
Definition SubsetMesh.h:298
MeshIterator getIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects.
std::vector< MeshID > getLocalBaseMeshIDs() const override
std::vector< int > getBlockIDs() const override
Return the list of all boundary ID sets in the mesh.
bool containsElement(const MeshElementID &id) const override
std::unique_ptr< Mesh > clone() const override
Function to copy the mesh (allows use to properly copy the derived class)
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.
ElementListPtr getElementParents(const MeshElement &elem, const GeomType type) const override
Return the parent elements of the given mesh element.
std::vector< int > d_boundaryIdSets
Definition SubsetMesh.h:344
std::vector< size_t > N_global
Definition SubsetMesh.h:341
MeshIterator isMember(const MeshIterator &it) const override
Check if elements are in the mesh.
size_t numGlobalElements(const GeomType type) const override
static std::shared_ptr< Mesh > create(std::shared_ptr< const Mesh > mesh, const AMP::Mesh::MeshIterator &iterator, bool isGlobal)
Create a subset 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.
std::vector< std::unique_ptr< MeshElement > > ElementList
Definition SubsetMesh.h:297
std::shared_ptr< const Mesh > d_parentMesh
Definition SubsetMesh.h:339
std::vector< std::vector< ElementListPtr > > d_surface
Definition SubsetMesh.h:343
std::string meshClass() const override
Return a string with the mesh class name.
std::vector< std::vector< ElementListPtr > > d_elements
Definition SubsetMesh.h:342
virtual MeshIterator getSurfaceIterator(const GeomType type, const int gcw=0) const override
Return an MeshIterator over the given geometric objects on the surface.
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
bool operator>=(const map_id_struct &rhs) const
Definition SubsetMesh.h:313
bool operator!=(const map_id_struct &rhs) const
Definition SubsetMesh.h:309
bool operator<(const map_id_struct &rhs) const
Definition SubsetMesh.h:333
bool operator<=(const map_id_struct &rhs) const
Definition SubsetMesh.h:334
bool operator>(const map_id_struct &rhs) const
Definition SubsetMesh.h:323
bool operator==(const map_id_struct &rhs) const
Definition SubsetMesh.h:305



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