Mesh¶
StructuredBase.h¶
-
template<typename
TReal
, size_tDIM
>
classCubism::Mesh
::
StructuredBase
Structured mesh base class.
Defines the (pure virtual) interface for a structured mesh.
- Template Parameters
TReal
: Float type for mesh entitiesDIM
: Mesh dimension
Subclassed by Cubism::Mesh::StructuredUniform< TReal, DIM >
Public Types
-
using
RealType
= typename RangeType::DataType Float type to describe mesh entities.
-
using
PointType
= typename RangeType::PointType Point type in mesh.
-
using
IndexRangeType
= Core::IndexRange<DIM> Index range used to address discrete mesh entities.
-
using
MultiIndex
= typename IndexRangeType::MultiIndex Multi-dimensional index.
-
using
EntityType
= Cubism::EntityType Mesh entity type.
-
using
MeshIntegrity
= Cubism::MeshIntegrity Mesh integrity.
-
using
iterator
= typename EntityIterator::iterator Mesh entity iterator.
Public Functions
-
inline
StructuredBase
(const PointType &begin, const PointType &end, const MultiIndex &cells, const MeshIntegrity type) Standard mesh constructor.
- Parameters
begin
: Lower left point of physical domainend
: Upper right point of physical domaincells
: Number of cells in meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredBase
(const PointType &end, const MultiIndex &cells, const MeshIntegrity type) Standard mesh constructor.
Physical begin at 0
- Parameters
end
: Upper right point of physical domaincells
: Number of cells in meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredBase
(const MultiIndex &cells) Standard mesh constructor.
Physical domain [0, 1], always a full mesh type
- Parameters
cells
: Number of cells in mesh
-
inline
StructuredBase
(const RangeType &grange, const RangeType &range, const IndexRangeType &crange, const MeshIntegrity type) Standard mesh constructor.
Used for MPI subdomains
- Parameters
grange
: Global domain range spanned by this meshrange
: Domain range spanned by this meshcrange
: Cell range spanned by this meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredBase
(const RangeType &grange, const RangeType &range, const IndexRangeType &crange, const IndexRangeType &nrange, const std::vector<IndexRangeType> &frange, const MeshIntegrity type) Low-level mesh constructor.
Used for grid topology classes and sub-meshes
- Parameters
grange
: Global domain range spanned by this meshrange
: Domain range spanned by this meshcrange
: Cell range spanned by this meshnrange
: Node range spanned by this meshfrange
: Face range spanned by this meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline EntityIterator
getIterator
(const EntityType t, const size_t d = 0) Get iterator for a mesh entity.
- Return
Entity iterator class
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline EntityIteratorgetIterator
(const EntityType t, const Dir d) Get iterator for a mesh entity.
Can be used with
Cubism::Dir::X
for example.- Return
Entity iterator class
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
inline Entity
operator[]
(const EntityType t) const Iterable mesh entities.
Assume
m
is a mesh instance. The access operator can be used in the following manner:for (auto c : m[EntityType::Cell]) {} // c is a cell index auto faces = m[EntityType::Face]; // iterators for faces for (auto fx : faces) {} // fx is a X-face index for (auto fx : faces[Dir::X]) {} // fx is a X-face index for (auto fy : faces[Dir::Y]) {} // fy is a Y-face index for (auto fz : faces[Dir::Z]) {} // fz is a Z-face index
- Return
Entity iterator container
- Parameters
t
: Entity type
-
inline size_t
size
(const EntityType t, const size_t d = 0) const Total size of mesh entities.
- Return
Number of entities
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline size_tsize
(const EntityType t, const Dir d) const Total size of mesh entities.
- Return
Number of entities
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
inline MultiIndex
getSize
(const EntityType t, const size_t d = 0) const Size of mesh entities.
- Return
Number of entities along all directions
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline MultiIndexgetSize
(const EntityType t, const Dir d) const Size of mesh entities.
- Return
Number of entities along all directions
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
inline IndexRangeType
getIndexRange
(const EntityType t, const size_t d = 0) const Index range for an entity type.
- Return
Index range
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline IndexRangeTypegetIndexRange
(const EntityType t, const Dir d) const Index range for an entity type.
- Return
Index range
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
t
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getExtent
() const Mesh extent.
- Return
Extent of mesh in all directions
-
inline RealType
getVolume
() const Mesh volume.
- Return
Total mesh volume
-
inline PointType
getBegin
() const Get mesh begin.
- Return
Local begin of mesh
-
inline PointType
getEnd
() const Get mesh end.
- Return
Local end of mesh
-
inline PointType
getGlobalBegin
() const Get mesh begin.
- Return
Global begin of mesh
-
inline PointType
getGlobalEnd
() const Get mesh end.
- Return
Global end of mesh
-
inline RangeType
getRange
() const Get mesh range.
- Return
Mesh range
-
inline RangeType
getGlobalRange
() const Get mesh range.
- Return
Global mesh range
-
inline bool
isSubMesh
() const Test if this is a sub-mesh.
- Return
True if this is a sub-mesh of some full mesh
-
inline MultiIndex
getMultiIndex
(const size_t i, const EntityType t, const size_t d = 0) const Convert local flat index to multi-dimensional index.
- Return
Local multi-dimensional index
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline MultiIndexgetMultiIndex
(const size_t i, const EntityType t, const Dir d) const Convert local flat index to multi-dimensional index.
- Return
Local multi-dimensional index
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline MultiIndex
getGlobalIndex
(const size_t i, const EntityType t, const size_t d = 0) const Convert local flat index to global multi-dimensional index.
- Return
Global multi-dimensional index
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline MultiIndexgetGlobalIndex
(const size_t i, const EntityType t, const Dir d) const Convert local flat index to global multi-dimensional index.
- Return
Global multi-dimensional index
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline MultiIndex
getGlobalIndex
(const MultiIndex &p, const EntityType t, const size_t d = 0) const Convert local multi-dimensional index to global multi-dimensional index.
- Return
Global multi-dimensional index
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline MultiIndexgetGlobalIndex
(const MultiIndex &p, const EntityType t, const Dir d) const Convert local multi-dimensional index to global multi-dimensional index.
- Return
Global multi-dimensional index
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getGlobalCoords
(const size_t i, const EntityType t, const size_t d = 0) const Convert local flat index to global coordinates.
- Return
Global coordinates
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline PointTypegetGlobalCoords
(const size_t i, const EntityType t, const Dir d) const Convert local flat index to global coordinates.
- Return
Global coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getGlobalCoords
(const MultiIndex &p, const EntityType t, const size_t d = 0) const Convert local multi-dimensional index to global coordinates.
- Return
Global coordinates
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline PointTypegetGlobalCoords
(const MultiIndex &p, const EntityType t, const Dir d) const Convert local multi-dimensional index to global coordinates.
- Return
Global coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getGlobalCoords
(const iterator &it) const Convert entity iterator to global coordinates.
- Return
Global coordinates
- Parameters
it
: Entity iterator
-
inline PointType
getCoords
(const size_t i, const EntityType t, const size_t d = 0) const Convert local flat index to local coordinates.
- Return
Local coordinates
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline PointTypegetCoords
(const size_t i, const EntityType t, const Dir d) const Convert local flat index to local coordinates.
- Return
Local coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getCoords
(const MultiIndex &p, const EntityType t, const size_t d = 0) const Convert local multi-dimensional index to local coordinates.
- Return
Local coordinates
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
template<typename
Dir
>
inline PointTypegetCoords
(const MultiIndex &p, const EntityType t, const Dir d) const Convert local multi-dimensional index to local coordinates.
- Return
Local coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional indext
: Entity typed
: Direction indicator (for Face entities only)
-
inline PointType
getCoords
(const iterator &it) const Convert entity iterator to local coordinates.
- Return
Local coordinates
- Parameters
it
: Entity iterator
-
inline PointType
getGlobalCoordsCell
(const MultiIndex &p) const Get global cell coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Global cell coordinates
- Parameters
p
: Local multi-dimensional cell index
-
inline PointType
getGlobalCoordsNode
(const MultiIndex &p) const Get global node coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Global node coordinates
- Parameters
p
: Local multi-dimensional node index
-
template<typename
Dir
= size_t>
inline PointTypegetGlobalCoordsFace
(const MultiIndex &p, const Dir dir) const Get global face coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Global face coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexdir
: Face direction identifier
-
inline PointType
getCoordsCell
(const MultiIndex &p) const Get local cell coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Local cell coordinates
- Parameters
p
: Local multi-dimensional cell index
-
inline PointType
getCoordsNode
(const MultiIndex &p) const Get local node coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Local node coordinates
- Parameters
p
: Local multi-dimensional node index
-
template<typename
Dir
= size_t>
inline PointTypegetCoordsFace
(const MultiIndex &p, const Dir dir) const Get local face coordinates.
Contains one virtual call. This method is overloaded in the derived class without virtual calls. Prefer this method for excessive coordinate lookup in loops.
- Return
Local face coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexdir
: Face direction identifier
-
inline RealType
getCellVolume
(const size_t i) const Get cell volume.
- Return
Cell volume
- Parameters
i
: Local flat cell index
-
inline RealType
getCellVolume
(const MultiIndex &p) const Get cell volume.
- Return
Cell volume
- Parameters
p
: Local multi-dimensional cell index
-
inline RealType
getCellVolume
(const iterator &it) const Get cell volume.
- Return
Cell volume
- Parameters
it
: Cell entity iterator
-
inline PointType
getCellSize
(const size_t i) const Get cell size.
- Return
Cell size
- Parameters
i
: Local flat cell index
-
inline PointType
getCellSize
(const MultiIndex &p) const Get cell size.
- Return
Cell size
- Parameters
p
: Local multi-dimensional cell index
-
inline PointType
getCellSize
(const iterator &it) const Get cell size.
- Return
Cell size
- Parameters
it
: Cell entity iterator
-
inline PointType
getSurface
(const size_t i, const size_t ci, const size_t d) const Get surface vector for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface vector
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
template<typename
Dir
>
inline PointTypegetSurface
(const size_t i, const size_t ci, const Dir d) const Get surface vector for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface vector
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
inline PointType
getSurface
(const MultiIndex &p, const MultiIndex &ci, const size_t d) const Get surface vector for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface vector
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
-
template<typename
Dir
>
inline PointTypegetSurface
(const MultiIndex &p, const MultiIndex &ci, const Dir d) const Get surface vector for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface vector
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
-
inline RealType
getSurfaceArea
(const size_t i, const size_t ci, const size_t d) const Get surface area for a face.
- Return
Face surface area
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
template<typename
Dir
>
inline RealTypegetSurfaceArea
(const size_t i, const size_t ci, const Dir d) const Get surface area for a face.
- Return
Face surface area
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
inline RealType
getSurfaceArea
(const MultiIndex &p, const MultiIndex &ci, const size_t d) const Get surface area for a face.
- Return
Face surface area
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
-
template<typename
Dir
>
inline RealTypegetSurfaceArea
(const MultiIndex &p, const MultiIndex &ci, const Dir d) const Get surface area for a face.
- Return
Face surface area
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
-
inline PointType
getSurfaceNormal
(const size_t i, const size_t ci, const size_t d) const Get surface normal for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface normal
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
template<typename
Dir
>
inline PointTypegetSurfaceNormal
(const size_t i, const size_t ci, const Dir d) const Get surface normal for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface normal
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
i
: Local flat face indexci
: Local flat index of reference celld
: Direction of face
-
inline PointType
getSurfaceNormal
(const MultiIndex &p, const MultiIndex &ci, const size_t d) const Get surface normal for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface normal
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
-
template<typename
Dir
>
inline PointTypegetSurfaceNormal
(const MultiIndex &p, const MultiIndex ci, const Dir d) const Get surface normal for a face.
The vector points outward* of the specified reference cell
ci
.- Return
Face surface normal
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexci
: Local multi-dimensional index of reference celld
: Direction of face
StructuredUniform.h¶
-
template<typename
TReal
, size_tDIM
>
classCubism::Mesh
::
StructuredUniform
: public Cubism::Mesh::StructuredBase<TReal, DIM> Structured uniform mesh.
- Template Parameters
TReal
: Float type for mesh entitiesDIM
: Mesh dimension
Public Types
-
using
BaseMesh
= StructuredBase<TReal, DIM> Base mesh type.
-
using
EntityType
= Cubism::EntityType Mesh entity type.
-
using
IndexRangeType
= Core::IndexRange<DIM> Index range used to address discrete mesh entities.
-
using
MeshIntegrity
= Cubism::MeshIntegrity Mesh integrity.
-
using
MultiIndex
= typename IndexRangeType::MultiIndex Multi-dimensional index.
-
using
PointType
= typename RangeType::PointType Point type in mesh.
-
using
RealType
= typename RangeType::DataType Float type to describe mesh entities.
Public Functions
-
inline
StructuredUniform
(const PointType &begin, const PointType &end, const MultiIndex &cells, const MeshIntegrity type) Standard mesh constructor.
- Parameters
begin
: Lower left point of physical domainend
: Upper right point of physical domaincells
: Number of cells in meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredUniform
(const PointType &end, const MultiIndex &cells, const MeshIntegrity type) Standard mesh constructor.
Physical begin at 0
- Parameters
end
: Upper right point of physical domaincells
: Number of cells in meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredUniform
(const MultiIndex &cells) Standard mesh constructor.
Physical domain [0, 1], always a full mesh type
- Parameters
cells
: Number of cells in mesh
-
inline
StructuredUniform
(const RangeType &grange, const RangeType &range, const IndexRangeType &crange, const MeshIntegrity type) Standard mesh constructor.
Used for MPI subdomains
- Parameters
grange
: Global domain range spanned by this meshrange
: Domain range spanned by this meshcrange
: Cell range spanned by this meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline
StructuredUniform
(const RangeType &grange, const RangeType &range, const IndexRangeType &crange, const IndexRangeType &nrange, const std::vector<IndexRangeType> &frange, const MeshIntegrity type) Low-level mesh constructor.
Used for grid topology classes and sub-meshes
- Parameters
grange
: Global domain range spanned by this meshrange
: Domain range spanned by this meshcrange
: Cell range spanned by this meshnrange
: Node range spanned by this meshfrange
: Face range spanned by this meshtype
: Mesh integrity type (full mesh or sub-mesh)
-
inline virtual std::unique_ptr<StructuredUniform>
getSubMesh
(const IndexRangeType &range, const EntityType entity, const size_t d = 0) const Get sub-mesh instance.
An empty mesh is returned if there is no common intersection. If
range
is larger it will be clipped to the boundaries of this mesh.Note
This method is not part of the
BaseMesh
interface.- Return
New sub-mesh instance
- Parameters
range
: Index range of new meshentity
: Entity type corresponding torange
d
: Direction indicator (for Face entities only)
-
inline virtual std::unique_ptr<StructuredUniform>
getSubMesh
(const PointType &begin, const PointType &end) const Get sub-mesh instance.
If
begin
orend
is outside of the physical range spanned by this mesh, then they will be adjusted to the begin and/or end points of the range corresponding to this mesh, respectively. The extracted discrete mesh is always guaranteed to include thebegin
andend
points. Therefore,getRange().getBegin()
of the extracted sub-mesh may be smaller in any component thanbegin
and vice versagetRange().getEnd()
may be larger in any component thanend
.Note
This method is not part of the
BaseMesh
interface.- Return
New sub-mesh instance
- Parameters
begin
: Lower left point of physical domain for sub-meshend
: Upper right point of physical domain for sub-mesh
-
inline PointType
getGlobalCoordsCell
(const MultiIndex &p) const Get global cell coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Global cell coordinates
- Parameters
p
: Local multi-dimensional cell index
-
inline PointType
getGlobalCoordsNode
(const MultiIndex &p) const Get global node coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Global node coordinates
- Parameters
p
: Local multi-dimensional node index
-
template<typename
Dir
= size_t>
inline PointTypegetGlobalCoordsFace
(const MultiIndex &p, const Dir dir) const Get global face coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Global face coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexdir
: Face direction identifier
-
inline PointType
getCoordsCell
(const MultiIndex &p) const Get local cell coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Local cell coordinates
- Parameters
p
: Local multi-dimensional cell index
-
inline PointType
getCoordsNode
(const MultiIndex &p) const Get local node coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Local node coordinates
- Parameters
p
: Local multi-dimensional node index
-
template<typename
Dir
= size_t>
inline PointTypegetCoordsFace
(const MultiIndex &p, const Dir dir) const Get local face coordinates.
This is a non-virtual method. Prefer this method for excessive coordinate lookup in loops.
- Return
Local face coordinates
- Template Parameters
Dir
: Special type that defines a cast tosize_t
- Parameters
p
: Local multi-dimensional face indexdir
: Face direction identifier