1#ifndef included_AMP_TriangleMesh
2#define included_AMP_TriangleMesh
4#include "AMP/geometry/Geometry.h"
5#include "AMP/mesh/Mesh.h"
6#include "AMP/mesh/MeshID.h"
7#include "AMP/mesh/MeshIterator.h"
19class TriangleMeshIterator;
21class TriangleMeshElement;
25template<
class TYPE,
size_t N>
34 inline int size()
const {
return d_x.size(); }
41 inline const auto data()
const {
return d_x.data(); }
46 int rank =
id.owner_rank();
50 int find(
const std::array<TYPE, N> &x )
const;
64 std::vector<std::array<TYPE, N>>
d_x;
81 for (
size_t i = 0; i < data.size(); i++ )
83 d_size.resize( data.size() );
86 for (
size_t i = 0, k = 0; i < data.size(); i++ ) {
87 d_size[i] = data[i].size();
89 for (
size_t j = 0; j <
d_size[i]; j++, k++ )
121 static_assert( NG <= 3,
"Not programmed for higher dimensions yet" );
122 typedef std::array<double, 3>
Point;
123 typedef std::array<int, 2>
Edge;
124 typedef std::array<int, 3>
Face;
125 typedef std::array<int, NG + 1>
TRI;
146 std::vector<Point> vertices,
147 std::vector<TRI> triangles,
148 std::vector<TRI> tri_nab,
150 std::shared_ptr<Geometry::Geometry> geom = {},
151 std::vector<int> block = {},
160 std::unique_ptr<Mesh>
clone() const override final;
164 bool operator==( const
Mesh &mesh ) const override;
214 const
int gcw = 0 ) const override final;
236 const
int gcw = 0 ) const override final;
277 const
GeomType type ) const override final;
318 void displaceMesh( std::shared_ptr<const AMP::LinearAlgebra::Vector> x )
override;
364 template<u
int8_t TYPE>
366 template<u
int8_t TYPE>
372 const std::vector<TRI> &tri,
373 const std::vector<TRI> &tri_nab,
374 const std::vector<int> &block );
Provides C++ wrapper around MPI routines.
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.
std::unique_ptr< MeshElement > MeshElementPtr
Pointer to MeshElement and MeshElementVector.
Movable
Enumeration for basic mesh-based quantities.
const ElementID * begin(size_t i) const
std::vector< size_t > d_offset
const ElementID * end(size_t i) const
std::vector< TYPE > d_data
StoreCompressedList(size_t N)
std::vector< size_t > d_size
StoreCompressedList(const std::vector< std::vector< TYPE > > &data)
auto & operator[](const ElementID &id)
ElementID getID(int i) const
auto & operator[](const ElementID &id) const
const auto & operator()() const
std::vector< int > d_offset
StoreTriData(std::vector< std::array< TYPE, N > > x, std::vector< int > offset, int rank, GeomType type)
std::vector< std::array< TYPE, N > > d_x
int find(const std::array< TYPE, N > &x) const
int index(const ElementID &id) const
auto & operator[](int i) const
A class used to represent an unstructured mesh of Triangles/Tetrahedrals.
TriangleMesh(int NP, std::vector< Point > vertices, std::vector< TRI > triangles, std::vector< TRI > tri_nab, const AMP_MPI &comm, std::shared_ptr< Geometry::Geometry > geom={}, std::vector< int > block={}, int max_gcw=2)
Primary constructor.
ElementList d_parents[NG+1][NG+1]
Parent data.
std::array< size_t, 4 > d_N_global
The number of global elements.
static bool inIterator(const ElementID &id, const TriangleMeshIterator< NG > *it)
Movable isMeshMovable() const override
Is the mesh movable.
std::pair< const ElementID *, const ElementID * > getElementParents(const ElementID &id, const GeomType type) const
StoreTriData< int, 2 > d_childEdge
The list of local children edges.
std::unique_ptr< Mesh > clone() const override final
Virtual function to copy the mesh (allows use to proply copy the derived class)
std::vector< IteratorSet > createBlockIterators(int block)
void writeRestart(int64_t fid) const override
Write restart data to file.
virtual MeshIterator getSurfaceIterator(const GeomType type, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects on the surface.
StoreCompressedList< ElementID > ElementList
std::vector< IteratorSet > d_iterators
[gcw][type]
MeshElement * getElement2(const MeshElementID &id) const
void initializeIterators()
std::vector< std::vector< IteratorSet > > d_boundary_it
[id][gcw][type]
bool isOnSurface(const ElementID &elemID) const
void initializeBoundingBox()
TriangleMeshIterator< NG > createIterator(GeomType type, int gcw) const
ElementList computeNodeParents(int parentType)
std::array< TriangleMeshIterator< NG >, NG+1 > IteratorSet
std::array< int, TYPE+1 > getElem(const ElementID &id) const
virtual MeshIterator getBlockIDIterator(const GeomType type, const int id, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects on the given block ID set.
std::vector< TRI > d_globalNab
Store the global triangle neighbors.
uint64_t positionHash() const override
Identify if the position has moved.
std::vector< std::vector< int > > d_remoteTri
The unique ghost triangles for each gcw.
ElementListPtr getElementParents(const MeshElement &elem, const GeomType type) const override final
Return the parent elements of the given mesh element.
void loadBalance(const std::vector< Point > &vertices, const std::vector< TRI > &tri, const std::vector< TRI > &tri_nab, const std::vector< int > &block)
void getElementsIDs(const ElementID &id, const GeomType type, ElementID *IDs) const
std::vector< int > d_boundary_ids
The global list of boundary ids.
size_t numGlobalElements(const GeomType type) const override final
std::vector< IteratorSet > d_surface_it
[gcw][type]
void displaceMesh(const std::vector< double > &x) override
Displace the entire mesh.
std::vector< int > getBoundaryIDs() const override final
Return the list of all boundary ID sets in the mesh.
void getNeighborIDs(const ElementID &id, std::vector< ElementID > &IDs) const
std::vector< std::vector< IteratorSet > > d_block_it
[id][gcw][type]
virtual MeshIterator getBoundaryIDIterator(const GeomType type, const int id, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects on the given boundary ID set.
std::vector< bool > d_isSurface[NG+1]
Global list of surface elements.
std::string meshClass() const override
Return a string with the mesh class name.
std::array< int, 3 > Face
bool isOnBoundary(const ElementID &elemID, int id) const
ElementList getParents(int childType, int parentType)
MeshIterator getIterator(const GeomType type, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects.
uint64_t d_pos_hash
Number of times position has changed.
std::vector< int > d_blockID
The block id index for each triangle.
StoreTriData< double, 3 > d_vertex
Store the global coordinates.
StoreTriData< int, 3 > d_childFace
The list of local children faces.
std::array< double, 3 > Point
size_t numLocalElements(const GeomType type) const override final
StoreTriData< int, NG+1 > d_globalTri
Store the global triangles.
void displaceMesh(std::shared_ptr< const AMP::LinearAlgebra::Vector > x) override
Displace the entire mesh.
size_t numGhostElements(const GeomType type, const int gcw) const override final
std::array< int, 2 > Edge
ElementID getID(const std::array< int, TYPE+1 > &id) const
bool isInBlock(const ElementID &elemID, int id) const
void createSurfaceIterators()
TriangleMesh(std::shared_ptr< const MeshParameters >)
std::array< int, NG+1 > TRI
void getVertexCoord(const ElementID &id, std::array< double, 3 > *x) const
std::vector< int > getBlockIDs() const override final
Return the list of all boundary ID sets in the mesh.
MeshElementPtr getElement(const MeshElementID &id) const override final
Return a mesh element given it's id.
std::vector< int > d_block_ids
The global list of block ids.
#define AMP_DEBUG_ASSERT(EXP)
Assert error (debug only)
GeomType
Enumeration for basic mesh-based quantities.
A structure used to identify an element within a mesh.
A structure used to identify the mesh element.