35#ifndef NEKTAR_SPATIALDOMAINS_HOALIGNMENT
36#define NEKTAR_SPATIALDOMAINS_HOALIGNMENT
54 HOTriangle(std::vector<int> pVertId, std::vector<T> pSurfVerts)
79 std::vector<T> tmp(np * np);
81 for (n = 0; n < nrot; ++n)
83 for (cnt = i = 0; i < np; ++i)
85 for (j = 0; j < np - i; ++j, cnt++)
90 for (cnt = i = 0; i < np; ++i)
92 for (j = 0; j < np - i; ++j, cnt++)
94 surfVerts[cnt] = tmp[(np - 1 - i - j) * np + i];
115 std::vector<T> tmp(np * np);
117 for (cnt = i = 0; i < np; ++i)
119 for (j = 0; j < np - i; ++j, cnt++)
121 tmp[i * np + np - i - 1 - j] =
surfVerts[cnt];
125 for (cnt = i = 0; i < np; ++i)
127 for (j = 0; j < np - i; ++j, cnt++)
139 if (
vertId[0] == this->vertId[0])
141 if (
vertId[1] == this->vertId[1] ||
vertId[1] == this->vertId[2])
143 if (
vertId[1] == this->vertId[2])
150 else if (
vertId[0] == this->vertId[1])
152 if (
vertId[1] == this->vertId[0] ||
vertId[1] == this->vertId[2])
154 if (
vertId[1] == this->vertId[0])
164 else if (
vertId[0] == this->vertId[2])
166 if (
vertId[1] == this->vertId[0] ||
vertId[1] == this->vertId[1])
168 if (
vertId[1] == this->vertId[1])
207 for (
int i = 0; i < np; ++i)
209 for (
int j = 0; j < np / 2; ++j)
221 for (
int j = 0; j < np; ++j)
223 for (
int i = 0; i < np / 2; ++i)
236 for (
int i = 0; i < np; ++i)
238 for (
int j = 0; j < np; ++j)
253 int vmap[4] = {-1, -1, -1, -1};
256 for (
int i = 0; i < 4; ++i)
258 for (
int j = 0; j < 4; ++j)
260 if (this->vertId[j] ==
vertId[i])
268 "Could not determine mapping between vertex IDs");
273 if (vmap[1] == (vmap[0] + 1) % 4)
399 std::array<int, 4> vmap = {-1, -1, -1, -1};
400 for (
int i = 0; i < 4; ++i)
402 for (
int j = 0; j < 4; ++j)
404 if (
vertId[i] == this->vertId[j])
410 ASSERTL0(vmap[i] != -1,
"Tetrahedron vertices do not match.");
422 while ((np - 4) * (np - 3) * (np - 2) / 6 < nInt)
426 ASSERTL0((np - 4) * (np - 3) * (np - 2) / 6 == nInt,
427 "Number of interior nodes is not a tetrahedral number.");
430 const int nTot = np * (np + 1) * (np + 2) / 6;
431 ASSERTL0(nInt <= nTot,
"More nodes than the element can hold.");
435 const int first = nTot - nInt;
443 auto weights = [&](
int m) {
444 std::array<int, 4> w;
445 w[1] = (int)std::lround(0.5 * (1.0 + px[m]) * (np - 1));
446 w[2] = (int)std::lround(0.5 * (1.0 +
py[m]) * (np - 1));
447 w[3] = (int)std::lround(0.5 * (1.0 + pz[m]) * (np - 1));
448 w[0] = (np - 1) - w[1] - w[2] - w[3];
451 auto key = [np](
const std::array<int, 4> &w) {
452 return ((w[0] * np + w[1]) * np + w[2]) * np + w[3];
455 std::map<int, int> slotOf;
456 for (
int s = 0; s < nInt; ++s)
458 slotOf[key(weights(first + s))] = s;
461 std::vector<T> tmp(nInt);
462 for (
int s = 0; s < nInt; ++s)
465 std::array<int, 4> want = weights(first + s), have{};
466 for (
int i = 0; i < 4; ++i)
468 have[vmap[i]] = want[i];
471 auto it = slotOf.find(key(have));
472 ASSERTL0(it != slotOf.end(),
"Could not place a tetrahedron node.");
501 HOPrism(std::vector<int> pVertId, std::vector<T> pVolVerts,
int pNumPts)
520 nrot = ((nrot % 3) + 3) % 3;
528 "Number of nodes is not a prism number.");
538 auto place = [&](
int m) {
539 std::array<int, 4> w;
540 w[1] = (int)std::lround(0.5 * (1.0 + px[m]) * (np - 1));
541 w[2] = (int)std::lround(0.5 * (1.0 + pz[m]) * (np - 1));
542 w[0] = (np - 1) - w[1] - w[2];
543 w[3] = (int)std::lround(0.5 * (1.0 +
py[m]) * (np - 1));
546 auto key = [np](
const std::array<int, 4> &w) {
547 return ((w[0] * np + w[1]) * np + w[2]) * np + w[3];
550 std::map<int, int> slotOf;
551 for (
size_t m = 0; m <
volVerts.size(); ++m)
553 slotOf[key(place(m))] = m;
556 std::vector<T> tmp(
volVerts.size());
557 for (
size_t m = 0; m <
volVerts.size(); ++m)
561 std::array<int, 4> want = place(m), have{};
562 for (
int c = 0; c < 3; ++c)
564 have[(c + nrot) % 3] = want[c];
568 auto it = slotOf.find(key(have));
569 ASSERTL0(it != slotOf.end(),
"Could not place a prism node.");
584 static const int triVerts[3] = {0, 1, 4};
586 for (
int r = 0; r < 3; ++r)
588 if (
vertId[0] == this->vertId[triVerts[r]])
595 ASSERTL0(
false,
"Prism vertices do not match.");
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Defines a specification for a set of points.
PointsManagerT & PointsManager(void)
@ eNodalPrismEvenlySpaced
3D Evenly-spaced points on a Prism
@ eNodalTetEvenlySpaced
3D Evenly-spaced points on a Tetrahedron
@ eDir1BwdDir2_Dir2BwdDir1
@ eDir1FwdDir1_Dir2FwdDir2
@ eDir1BwdDir1_Dir2BwdDir2
@ eDir1BwdDir2_Dir2FwdDir1
@ eDir1FwdDir1_Dir2BwdDir2
@ eDir1BwdDir1_Dir2FwdDir2
@ eDir1FwdDir2_Dir2FwdDir1
@ eDir1FwdDir2_Dir2BwdDir1
scalarT< T > sqrt(scalarT< T > in)
The nodes of a high-order prism, and the vertices they sit against.
std::vector< T > volVerts
The nodes, in nodal prism ordering.
std::vector< int > vertId
The prism vertex IDs.
int numPts
Points along an edge of the element.
void Rotate(int nrot)
Turn the triangular cross-section nrot thirds of a turn.
void Align(std::vector< int > vertId)
Turn the prism so that its vertices read as vertId.
HOPrism(std::vector< int > pVertId, std::vector< T > pVolVerts, int pNumPts)
A lightweight struct for dealing with high-order quadrilateral alignment.
void Align(std::vector< int > vertId)
Align this surface to a given vertex ID.
std::vector< T > surfVerts
The quadrilateral surface vertices – templated so that this can either be nodes or IDs.
HOQuadrilateral(std::vector< int > pVertId, std::vector< T > pSurfVerts)
std::vector< int > vertId
The quadrilateral vertex IDs.
HOQuadrilateral(std::vector< int > pVertId)
The interior nodes of a high-order tetrahedron, and the vertices they are positioned against.
void Align(std::vector< int > vertId)
Reorder volVerts into the frame in which the vertices are numbered as vertId.
std::vector< int > vertId
The tetrahedron vertex IDs.
HOTetrahedron(std::vector< int > pVertId)
HOTetrahedron(std::vector< int > pVertId, std::vector< T > pVolVerts, int pNumPts=0)
std::vector< T > volVerts
The interior nodes, in the ordering a nodal tetrahedron of this order puts them in – templated so tha...
int numPts
Points along an edge of the element, or zero if volVerts is only its interior and the order should be...
A lightweight struct for dealing with high-order triangle alignment.
void Reflect()
Reflect data points inside surfVerts.
std::vector< int > vertId
The triangle vertex IDs.
HOTriangle(std::vector< int > pVertId)
std::vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs.
void Rotate(int nrot)
Rotates the triangle of data points inside surfVerts counter-clockwise nrot times.
void Align(std::vector< int > vertId)
Align this surface to a given vertex ID.
HOTriangle(std::vector< int > pVertId, std::vector< T > pSurfVerts)