Advanced Multi-Physics (AMP)
On-Line Documentation
MeshElement.h
Go to the documentation of this file.
1#ifndef included_AMP_MeshElement
2#define included_AMP_MeshElement
3
4#include "AMP/mesh/MeshElementVector.h"
5#include "AMP/mesh/MeshID.h"
6#include "AMP/utils/MeshPoint.h"
7#include "AMP/utils/typeid.h"
8
9#include <memory>
10#include <vector>
11
12
13namespace AMP::Mesh {
14
15
16class Mesh;
17
18
27{
28public:
30
31public: // non-virtual functions
33 MeshElement() = default;
34
36 inline bool isNull() const { return globalID().isNull(); }
37
39 inline GeomType elementType() const { return globalID().type(); }
40
41 // Overload operators
42 inline bool operator==( const MeshElement &rhs ) const { return globalID() == rhs.globalID(); }
43 inline bool operator!=( const MeshElement &rhs ) const { return globalID() != rhs.globalID(); }
44 inline bool operator<( const MeshElement &rhs ) const { return globalID() < rhs.globalID(); }
45 inline bool operator>( const MeshElement &rhs ) const { return globalID() > rhs.globalID(); }
46 inline bool operator<=( const MeshElement &rhs ) const { return globalID() <= rhs.globalID(); }
47 inline bool operator>=( const MeshElement &rhs ) const { return globalID() >= rhs.globalID(); }
48 inline bool operator==( const MeshElementID &rhs ) const { return globalID() == rhs; }
49 inline bool operator!=( const MeshElementID &rhs ) const { return globalID() != rhs; }
50 inline bool operator<( const MeshElementID &rhs ) const { return globalID() < rhs; }
51 inline bool operator>( const MeshElementID &rhs ) const { return globalID() > rhs; }
52 inline bool operator<=( const MeshElementID &rhs ) const { return globalID() <= rhs; }
53 inline bool operator>=( const MeshElementID &rhs ) const { return globalID() >= rhs; }
54
61 inline double coord( int i ) const { return coord()[i]; }
62
63
72 bool containsPoint( const std::vector<double> &pos, double TOL = 1e-12 ) const;
73
74
80 std::string print( uint8_t indent = 0 ) const;
81
82
83public: // Virtual functions
85 virtual const typeID &getTypeID() const;
86
88 virtual MeshElementID globalID() const;
89
91 unsigned int globalOwnerRank( const Mesh &mesh ) const;
92
94 virtual std::string elementClass() const;
95
97 virtual Point coord() const;
98
105 virtual Point centroid() const;
106
108 virtual double volume() const;
109
111 virtual Point norm() const;
112
121 virtual bool containsPoint( const Point &pos, double TOL = 1e-12 ) const;
122
128 virtual Point nearest( const Point &pos ) const;
129
138 virtual double distance( const Point &pos, const Point &dir ) const;
139
141 virtual bool isOnSurface() const;
142
148 virtual bool isOnBoundary( int id ) const;
149
155 virtual bool isInBlock( int id ) const;
156
157
159 virtual ElementListPtr getElements( const GeomType type ) const;
160
169
170
171public: // Advanced functions
173 virtual int getElementsID( const GeomType type, MeshElementID *ID ) const;
174
182 virtual void getVertices( std::vector<Point> &vertices ) const;
183
190 virtual void getNeighborVertices( std::vector<Point> &vertices ) const;
191
193 virtual std::unique_ptr<MeshElement> clone() const;
194
196 virtual ~MeshElement() = default;
197
198
199protected: // Constructors
200 MeshElement( const MeshElement & ) = default;
201 MeshElement( MeshElement && ) = default;
202 MeshElement &operator=( const MeshElement & ) = default;
204};
205
206
207} // namespace AMP::Mesh
208
209
210#endif
A pointer class to wrap a MeshElementVector.
virtual MeshElementID globalID() const
Return the unique global ID of the element.
bool operator!=(const MeshElement &rhs) const
Definition MeshElement.h:43
bool operator<=(const MeshElement &rhs) const
Definition MeshElement.h:46
bool operator<(const MeshElementID &rhs) const
Definition MeshElement.h:50
virtual bool isOnSurface() const
Check if the element is on the surface.
virtual void getNeighborVertices(std::vector< Point > &vertices) const
virtual Point centroid() const
Return the centroid of the element.
bool operator>(const MeshElement &rhs) const
Definition MeshElement.h:45
virtual Point nearest(const Point &pos) const
Calculate the nearest point on the element.
virtual double distance(const Point &pos, const Point &dir) const
Calculate the distance to the element given a ray.
std::string print(uint8_t indent=0) const
Print info about the element.
bool operator!=(const MeshElementID &rhs) const
Definition MeshElement.h:49
virtual Point coord() const
Return the coordinates of the vertex (only applies to vertices)
bool operator>=(const MeshElement &rhs) const
Definition MeshElement.h:47
bool operator>(const MeshElementID &rhs) const
Definition MeshElement.h:51
virtual std::string elementClass() const
Return the element class.
virtual std::unique_ptr< MeshElement > clone() const
Clone the element.
bool containsPoint(const std::vector< double > &pos, double TOL=1e-12) const
Return true if the element contains the point.
virtual int getElementsID(const GeomType type, MeshElementID *ID) const
Return the IDs of the elements composing the current element.
GeomType elementType() const
Return the element type.
Definition MeshElement.h:39
virtual double volume() const
Return the volume of the current element (does not apply to vertices)
MeshElement & operator=(MeshElement &&)=default
bool operator>=(const MeshElementID &rhs) const
Definition MeshElement.h:53
virtual ElementListPtr getElements(const GeomType type) const
Return the elements composing the current element.
virtual ElementListPtr getNeighbors() const
virtual bool isOnBoundary(int id) const
Check if the current element is on the given boundary.
bool isNull() const
Is the mesh element null.
Definition MeshElement.h:36
virtual const typeID & getTypeID() const
Return the typeID of the underlying element.
virtual bool containsPoint(const Point &pos, double TOL=1e-12) const
Return true if the element contains the point.
unsigned int globalOwnerRank(const Mesh &mesh) const
Return the owner rank according to AMP_COMM_WORLD.
virtual void getVertices(std::vector< Point > &vertices) const
bool operator==(const MeshElement &rhs) const
Definition MeshElement.h:42
virtual bool isInBlock(int id) const
Check if the current element is in the given block.
bool operator==(const MeshElementID &rhs) const
Definition MeshElement.h:48
virtual ~MeshElement()=default
Destructor for a MeshElement.
MeshElement()=default
Empty constructor for a MeshElement.
bool operator<(const MeshElement &rhs) const
Definition MeshElement.h:44
double coord(int i) const
Return the coordinate of the vertex.
Definition MeshElement.h:61
bool operator<=(const MeshElementID &rhs) const
Definition MeshElement.h:52
MeshElement(const MeshElement &)=default
MeshElement & operator=(const MeshElement &)=default
MeshElement(MeshElement &&)=default
virtual Point norm() const
Return the normal to the current element (does not apply to all elements)
A class used to abstract away mesh from an application.
Definition Mesh.h:57
GeomType
Enumeration for basic mesh-based quantities.
Definition MeshID.h:12
A structure used to identify the mesh element.
Definition MeshID.h:156
constexpr GeomType type() const
Definition MeshID.h:206
constexpr bool isNull() const
Definition MeshID.h:212
Class to store type info.
Definition typeid.h:210



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