1#ifndef included_AMP_BoxMesh
2#define included_AMP_BoxMesh
4#include "AMP/geometry/Geometry.h"
5#include "AMP/mesh/Mesh.h"
6#include "AMP/mesh/MeshID.h"
7#include "AMP/mesh/MeshIterator.h"
8#include "AMP/utils/ArraySize.h"
9#include "AMP/utils/Utilities.h"
23class structuredMeshElement;
24class structuredMeshIterator;
91 constexpr explicit Box(
92 int ifirst,
int ilast,
int jfirst = 0,
int jlast = 0,
int kfirst = 0,
int klast = 0 );
209 static std::shared_ptr<BoxMesh>
generate( std::shared_ptr<const MeshParameters> params );
213 std::unique_ptr<Mesh>
clone()
const override = 0;
243 static size_t maxProcs( std::shared_ptr<const MeshParameters> params );
285 const
int gcw = 0 ) const override final;
307 const
int gcw = 0 ) const override final;
348 const
GeomType type ) const override final;
373 bool operator==( const
Mesh &mesh ) const override;
499 std::vector<
int> *startIndex,
500 std::vector<
int> minSize = {} );
504 const std::array<int, 6> &ids,
505 const std::vector<int> &minSize = {} );
508 void finalize(
const std::string &name,
const std::vector<double> &displacement );
518 const int *globalSize,
520 const std::vector<MeshElementIndex> &index,
521 std::vector<double> *
coord );
530 template<u
int8_t NDIM>
531 std::vector<MeshElementIndex>
createMap(
const std::vector<MeshElementIndex> )
const;
558 mutable std::vector<ListPtr>
d_bnd[4][6];
572#include "AMP/mesh/structured/BoxMesh.inline.h"
Simple class to store the array dimensions.
Class to manage reading/writing restart data.
Structure to identify a logical box.
int last[3]
Ending element.
constexpr ArraySize size() const
Return the size of the box.
int first[3]
Starting element.
constexpr Box()
Empty constructor.
constexpr Box(int ifirst, int ilast, int jfirst=0, int jlast=0, int kfirst=0, int klast=0)
Default constructor.
std::string print() const
MeshElementIndexIterator end() const
bool operator==(const MeshElementIndexIterator &rhs) const
MeshElementIndexIterator & operator++()
std::array< bool, 3 > d_isPeriodic
const auto & first() const
MeshElementIndexIterator(const MeshElementIndex &first, const MeshElementIndex &last, const AMP::Mesh::BoxMesh *mesh, size_t pos=0)
std::array< int, 3 > d_globalSize
MeshElementIndexIterator & operator+=(int N)
MeshElementIndexIterator & operator--()
std::random_access_iterator_tag iterator_category
MeshElementIndexIterator & operator[](int)
MeshElementIndexIterator & operator+=(const MeshElementIndexIterator &it)
MeshElementIndexIterator begin() const
const auto & last() const
MeshElementIndex operator*() const
bool operator!=(const MeshElementIndexIterator &rhs) const
MeshElementIndexIterator()=default
ptrdiff_t difference_type
Structure to uniquely identify an element.
uint8_t d_type
Mesh element type.
static constexpr size_t numElements(const MeshElementIndex &first, const MeshElementIndex &last)
constexpr bool operator>(const MeshElementIndex &rhs) const
Operator >
std::string print() const
constexpr int & index(int d)
constexpr bool operator<(const MeshElementIndex &rhs) const
Operator <.
constexpr GeomType type() const
constexpr int index(int d) const
constexpr void reset(GeomType type, uint8_t side, int x, int y=0, int z=0)
uint8_t d_side
Are we dealing with x, y, or z faces/edges.
constexpr bool operator>=(const MeshElementIndex &rhs) const
Operator >=.
constexpr bool operator<=(const MeshElementIndex &rhs) const
Operator <=.
constexpr MeshElementIndex(GeomType type, uint8_t side, int x, int y=0, int z=0)
Default constructor.
constexpr uint8_t side() const
constexpr bool isNull() const
constexpr bool operator!=(const MeshElementIndex &rhs) const
Operator !=.
constexpr int operator[](int d) const
constexpr int & operator[](int d)
std::array< int, 3 > d_index
Global x, y, z index (may be negative)
constexpr MeshElementIndex()=default
Empty constructor.
constexpr bool operator==(const MeshElementIndex &rhs) const
Operator ==.
constexpr const auto & index() const
A class used to represent a logically rectangular box mesh.
const std::array< int, 6 > d_surfaceId
std::vector< size_t > numBlocks() const
Return the number of blocks.
size_t numGhostElements(const GeomType type, const int gcw) const override final
size_t numLocalElements(const GeomType type) const override final
bool onSide(const MeshElementIndex &index, int d, int s) const
const std::array< int, 3 > d_numBlocks
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.
ElementBlocks getSurface(int surface, GeomType type) const
virtual bool isOnBoundary(const MeshElementIndex &index, int id) const
Check if the element is on the given boundary id.
const std::vector< int > d_endIndex[3]
static std::shared_ptr< BoxMesh > generate(std::shared_ptr< const MeshParameters > params)
Read in mesh files, partition domain, and prepare environment for simulation.
int getRank(const MeshElementIndex &id) const
Get the rank that owns the element.
size_t numGlobalElements(const GeomType type) const override final
const std::array< int, 3 > d_indexSize
std::tuple< IndexList, IndexList > SurfaceMapStruct
ArraySize localSize() const
Return the size of the mesh.
virtual void createBoundingBox()
virtual void coord(const MeshElementIndex &index, double *pos) const =0
Return a mesh element's coordinates given it's id.
std::vector< ListPtr > d_surface[4]
std::unique_ptr< Mesh > clone() const override=0
Virtual function to copy the mesh (allows use to proply copy the derived class)
ElementBlocks intersect(const ElementBlocks &v1, const ElementBlocks &v2) const
ArraySize size() const
Return the size of the mesh.
static void fillCartesianNodes(int dim, const int *globalSize, const double *range, const std::vector< MeshElementIndex > &index, std::vector< double > *coord)
MeshElementIndex getElementFromLogical(const AMP::Geometry::Point &x, GeomType type) const
Return the element containing the point.
std::array< int, 6 > getLocalBlock(int rank) const
std::shared_ptr< AMP::LinearAlgebra::Vector > createVector(const std::string &name, int gcw=0)
Create an ArrayVector over the mesh.
virtual MeshIterator getSurfaceIterator(const GeomType type, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects on the surface.
std::vector< int > getBoundaryIDs() const override final
Return the list of all boundary ID sets in the mesh.
static void loadBalance(std::array< int, 3 > size, int N_procs, std::vector< int > *startIndex, std::vector< int > minSize={})
Box getGlobalBox(int gcw=0) const
Return the global logical box.
void finalize(const std::string &name, const std::vector< double > &displacement)
MeshElementIndex getElementFromPhysical(const AMP::Geometry::Point &x, GeomType type) const
Return the element containing the point.
ElementBlocks getSurface2(int surface, GeomType type) const
static ArraySize estimateLogicalMeshSize(std::shared_ptr< const MeshParameters > params)
Estimate the number of elements in the mesh.
void initialize(const std::array< int, 3 > &size, const std::array< int, 6 > &ids, const std::vector< int > &minSize={})
const std::vector< int > d_startIndex[3]
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.
void fixPeriodic(MeshElementIndex &id) const
Fix periodic boundaries in the element index.
void writeRestart(int64_t) const override
Write restart data to file.
std::vector< double > getDisplacement(std::shared_ptr< const AMP::Database > db)
static size_t estimateMeshSize(std::shared_ptr< const MeshParameters > params)
Estimate the number of elements in the mesh.
ElementBlocks getIteratorRange(std::array< int, 6 > range, const GeomType type, const int gcw) const
std::vector< ListPtr > d_bnd[4][6]
BoxMesh(int64_t, AMP::IO::RestartManager *)
std::vector< int > getBlockIDs() const override final
Return the list of all boundary ID sets in the mesh.
virtual std::array< AMP::Array< double >, 3 > globalCoord() const =0
Return the vertex coordinates for the global box.
virtual bool isOnSurface(const MeshElementIndex &index) const
Check if the element is on the surface.
virtual AMP::Geometry::Point physicalToLogical(const AMP::Geometry::Point &x) const =0
Return the logical coordinates.
std::vector< bool > periodic() const
Return the bool vector indicating which directions are periodic.
const std::array< int, 6 > d_localIndex
std::vector< MeshElementIndex > IndexList
MeshElementID convert(const MeshElementIndex &id) const
Convert the MeshElementIndex to the MeshElementID.
const std::array< int, 3 > d_globalSize
static size_t maxProcs(std::shared_ptr< const MeshParameters > params)
Return the maximum number of processors that can be used with the mesh.
virtual ~BoxMesh()
Destructor.
std::shared_ptr< IndexList > ListPtr
int getSurfaceID(int surface) const
Box getLocalBox(int gcw=0) const
Return the local logical box.
SurfaceMapStruct d_surfaceMaps[3]
MeshElementPtr getElement(const MeshElementID &id) const override final
Return a mesh element given it's id.
MeshIterator getIterator(const GeomType type, const int gcw=0) const override final
Return an MeshIterator over the given geometric objects.
MeshIterator createIterator(const ElementBlocks &list) const
virtual ElementListPtr getElementParents(const MeshElement &elem, const GeomType type) const override final
Return the parent elements of the given mesh element.
std::vector< MeshElementIndex > createMap(const std::vector< MeshElementIndex >) const
virtual std::array< AMP::Array< double >, 3 > localCoord() const =0
Return the vertex coordinates for the local box.
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.
A derived class used to define a mesh element.
GeomType
Enumeration for basic mesh-based quantities.
std::ostream & operator<<(std::ostream &out, GeomType x)
A structure used to identify the mesh element.