6#ifndef STRUCTURED_GRID_BASE_H
7#define STRUCTURED_GRID_BASE_H
23 typedef std::shared_ptr<Class>
ptr;
25 static std::shared_ptr<const Class>
as(std::shared_ptr<const Object>
ptr)
27 return std::dynamic_pointer_cast<const Class>(
ptr);
29 static std::shared_ptr<Class>
as(std::shared_ptr<Object>
ptr) {
return std::dynamic_pointer_cast<Class>(
ptr); }
32 static constexpr std::array<Index, 8> HexahedronIndices[3] = {
52 return (ix * dims[1] + iy) * dims[2] + iz;
56 return vertexIndex(i[0], i[1], i[2], dims);
60 std::array<Index, 3> coords;
61 coords[2] = v % dims[2];
63 coords[1] = v % dims[1];
66 assert(coords[0] < dims[0]);
67 assert(coords[1] < dims[1]);
68 assert(coords[2] < dims[2]);
74 assert(ix < dims[0] - 1 || ix == 0);
75 assert(iy < dims[1] - 1 || iy == 0);
76 assert(iz < dims[2] - 1 || iz == 0);
77 return (ix * std::max(dims[1] - 1,
Index(1)) + iy) * std::max(dims[2] - 1,
Index(1)) + iz;
82 std::array<Index, 3> coords;
84 coords[2] = el % div2;
87 coords[1] = el % div1;
90 assert(coords[0] < dims[0] - 1 || coords[0] == 0);
91 assert(coords[1] < dims[1] - 1 || coords[1] == 0);
92 assert(coords[2] < dims[2] - 1 || coords[2] == 0);
97 auto &H = HexahedronIndices;
98 std::array<Index, 3> n = cellCoordinates(el, dims);
99 std::array<Index, 8> cl;
101 for (
int i = 0; i < 8; ++i) {
102 cl[i] = vertexIndex(n[0] + H[0][i], n[1] + H[1][i], n[2] + H[2][i], dims);
104 }
else if (dims[1] > 1) {
106 for (
int i = 0; i < 4; ++i) {
107 cl[i + 4] = cl[i] = vertexIndex(n[0] + H[0][i], n[1] + H[1][i], n[2] + H[2][i], dims);
109 }
else if (dims[0] > 1) {
110 for (
int i = 0; i < 2; ++i) {
111 cl[i + 6] = cl[i + 4] = cl[i + 2] = cl[i] =
112 vertexIndex(n[0] + H[0][i], n[1] + H[1][i], n[2] + H[2][i], dims);
118 virtual bool isGhostCell(
Index elem)
const override;
123 return (std::max(getNumDivisions(0) - 1,
Index(1)) * std::max(getNumDivisions(1) - 1,
Index(1)) *
124 std::max(getNumDivisions(2) - 1,
Index(1)));
128 return (std::max(getNumDivisions(0) - 1,
Index(1)) * std::max(getNumDivisions(1) - 1,
Index(1)) *
129 std::max(getNumDivisions(2) - 1,
Index(1)));
142 virtual Scalar cellDiameter(
Index elem)
const override;
143 virtual Vector cellCenter(
Index elem)
const override;
144 virtual std::vector<Index> getNeighborElements(
Index elem)
const override;
147 std::vector<Index> cellVertices(
Index elem)
const override;
#define ARCHIVE_ASSUME_ABSTRACT(obj)
Definition: archives_config.h:466
Definition: structuredgridbase.h:20
virtual Index getNumElements() override
Definition: structuredgridbase.h:121
GhostLayerPosition
Definition: structuredgridbase.h:31
@ Bottom
Definition: structuredgridbase.h:31
std::shared_ptr< const Class > const_ptr
Definition: structuredgridbase.h:24
static std::array< Index, 3 > vertexCoordinates(Index v, const Index dims[3])
Definition: structuredgridbase.h:58
virtual void setNumGhostLayers(unsigned dim, GhostLayerPosition pos, unsigned value)
Definition: structuredgridbase.h:140
static Index cellIndex(const Index ix, const Index iy, const Index iz, const Index dims[3])
Definition: structuredgridbase.h:72
static std::shared_ptr< Class > as(std::shared_ptr< Object > ptr)
Definition: structuredgridbase.h:29
static Index vertexIndex(const Index i[3], const Index dims[3])
Definition: structuredgridbase.h:54
std::shared_ptr< Class > ptr
Definition: structuredgridbase.h:23
virtual Index getNumDivisions(int d) const
Definition: structuredgridbase.h:132
virtual void setGlobalIndexOffset(int d, Index offset)=0
static std::array< Index, 3 > cellCoordinates(Index el, const Index dims[3])
Definition: structuredgridbase.h:80
virtual Index getNumGhostLayers(unsigned dim, GhostLayerPosition pos)
Definition: structuredgridbase.h:133
static Index vertexIndex(const Index ix, const Index iy, const Index iz, const Index dims[3])
Definition: structuredgridbase.h:47
static std::array< Index, 8 > cellVertices(Index el, const Index dims[3])
Definition: structuredgridbase.h:95
static Index cellIndex(const Index i[3], const Index dims[3])
Definition: structuredgridbase.h:79
StructuredGridBase Class
Definition: structuredgridbase.h:22
static std::shared_ptr< const Class > as(std::shared_ptr< const Object > ptr)
Definition: structuredgridbase.h:25
virtual Index getGlobalIndexOffset(int d) const
Definition: structuredgridbase.h:136
Index cellNumFaces(Index elem) const override
Definition: structuredgridbase.h:146
static int dimensionality(const Index dims[3])
Definition: structuredgridbase.h:35
virtual Index getNumDivisions(int d)
Definition: structuredgridbase.h:131
virtual Index getNumElements() const override
Definition: structuredgridbase.h:126
virtual Index getNumGhostLayers(unsigned dim, GhostLayerPosition pos) const
Definition: structuredgridbase.h:134
#define V_COREEXPORT
Definition: export.h:9
Definition: allobjects.cpp:30
Vector3 Vector
Definition: vector.h:36
float Scalar
Definition: scalar.h:14
uint32_t Index
Definition: index.h:13