Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Nektar::SpatialDomains::HOTetrahedron< T > Struct Template Reference

The interior nodes of a high-order tetrahedron, and the vertices they are positioned against. More...

#include <HOAlignment.h>

Public Member Functions

 HOTetrahedron (std::vector< int > pVertId, std::vector< T > pVolVerts, int pNumPts=0)
 
 HOTetrahedron (std::vector< int > pVertId)
 
void Align (std::vector< int > vertId)
 Reorder volVerts into the frame in which the vertices are numbered as vertId.
 

Public Attributes

std::vector< int > vertId
 The tetrahedron vertex IDs.
 
std::vector< T > volVerts
 The interior nodes, in the ordering a nodal tetrahedron of this order puts them in – templated so that this can be either nodes or IDs.
 
int numPts = 0
 Points along an edge of the element, or zero if volVerts is only its interior and the order should be worked out from that.
 

Detailed Description

template<typename T>
struct Nektar::SpatialDomains::HOTetrahedron< T >

The interior nodes of a high-order tetrahedron, and the vertices they are positioned against.

The counterpart of HOTriangle for the inside of an element rather than a face. A tetrahedron's nodes are a nodal distribution rather than a grid, so there is no axis to rotate about and no pair of directions to reflect; what there is instead is each node's barycentric position, how much of each of the four vertices it is made of. Those weights belong to the vertices themselves rather than to any numbering of them, so relabelling the vertices is enough to say where every node goes.

Nothing here evaluates a point. Aligning is a permutation of the nodes already held, so a node read from a file keeps the position the file gave it.

Definition at line 351 of file HOAlignment.h.

Constructor & Destructor Documentation

◆ HOTetrahedron() [1/2]

template<typename T >
Nektar::SpatialDomains::HOTetrahedron< T >::HOTetrahedron ( std::vector< int >  pVertId,
std::vector< T >  pVolVerts,
int  pNumPts = 0 
)
inline
Parameters
pVertIdThe four vertex IDs these nodes are positioned against.
pVolVertsThe nodes, in the ordering a nodal tetrahedron puts them in.
pNumPtsPoints along an edge of the element the nodes came from, when pVolVerts holds every node of it. Leave this out when it holds only the interior: the two cannot be told apart by counting, since the interior of one order has as many nodes as the whole of another.

Definition at line 363 of file HOAlignment.h.

365 : vertId(pVertId), volVerts(pVolVerts), numPts(pNumPts)
366 {
367 }
std::vector< int > vertId
The tetrahedron vertex IDs.
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...

◆ HOTetrahedron() [2/2]

template<typename T >
Nektar::SpatialDomains::HOTetrahedron< T >::HOTetrahedron ( std::vector< int >  pVertId)
inline

Definition at line 368 of file HOAlignment.h.

368 : vertId(pVertId)
369 {
370 }

Member Function Documentation

◆ Align()

template<typename T >
void Nektar::SpatialDomains::HOTetrahedron< T >::Align ( std::vector< int >  vertId)
inline

Reorder volVerts into the frame in which the vertices are numbered as vertId.

Parameters
vertIdThe vertex IDs to align to, in the desired order.

Definition at line 389 of file HOAlignment.h.

390 {
391 // One node sits at the centre and any number below that is no node at
392 // all; either way there is nothing a relabelling could move.
393 if (volVerts.size() < 2)
394 {
395 return;
396 }
397
398 // Which of the stored vertices each of the wanted ones is.
399 std::array<int, 4> vmap = {-1, -1, -1, -1};
400 for (int i = 0; i < 4; ++i)
401 {
402 for (int j = 0; j < 4; ++j)
403 {
404 if (vertId[i] == this->vertId[j])
405 {
406 vmap[i] = j;
407 break;
408 }
409 }
410 ASSERTL0(vmap[i] != -1, "Tetrahedron vertices do not match.");
411 }
412
413 const int nInt = volVerts.size();
414
415 // Recover the order. Told the element's own size, the nodes are all of
416 // it; otherwise they are the interior of an element with np points
417 // along each edge, of which there are (np-4)(np-3)(np-2)/6.
418 int np = numPts;
419 if (np == 0)
420 {
421 np = 4;
422 while ((np - 4) * (np - 3) * (np - 2) / 6 < nInt)
423 {
424 ++np;
425 }
426 ASSERTL0((np - 4) * (np - 3) * (np - 2) / 6 == nInt,
427 "Number of interior nodes is not a tetrahedral number.");
428 }
429
430 const int nTot = np * (np + 1) * (np + 2) / 6;
431 ASSERTL0(nInt <= nTot, "More nodes than the element can hold.");
432
433 // Where in the distribution the nodes we were given start: the
434 // interior is its tail, and a whole element is all of it.
435 const int first = nTot - nInt;
436
437 LibUtilities::PointsKey pKey(np, LibUtilities::eNodalTetEvenlySpaced);
438 Array<OneD, NekDouble> px, py, pz;
439 LibUtilities::PointsManager()[pKey]->GetPoints(px, py, pz);
440
441 // Barycentric weights of a node, as whole numbers of 1/(np-1) so that
442 // they can be compared exactly.
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];
449 return w;
450 };
451 auto key = [np](const std::array<int, 4> &w) {
452 return ((w[0] * np + w[1]) * np + w[2]) * np + w[3];
453 };
454
455 std::map<int, int> slotOf;
456 for (int s = 0; s < nInt; ++s)
457 {
458 slotOf[key(weights(first + s))] = s;
459 }
460
461 std::vector<T> tmp(nInt);
462 for (int s = 0; s < nInt; ++s)
463 {
464 // The same mix of the same four corners, with the labels moved.
465 std::array<int, 4> want = weights(first + s), have{};
466 for (int i = 0; i < 4; ++i)
467 {
468 have[vmap[i]] = want[i];
469 }
470
471 auto it = slotOf.find(key(have));
472 ASSERTL0(it != slotOf.end(), "Could not place a tetrahedron node.");
473 tmp[s] = volVerts[it->second];
474 }
475
476 volVerts = tmp;
477 }
#define ASSERTL0(condition, msg)
PointsManagerT & PointsManager(void)
@ eNodalTetEvenlySpaced
3D Evenly-spaced points on a Tetrahedron
Definition PointsType.h:84

References ASSERTL0, Nektar::LibUtilities::eNodalTetEvenlySpaced, Nektar::SpatialDomains::HOTetrahedron< T >::numPts, Nektar::LibUtilities::PointsManager(), Nektar::SpatialDomains::HOTetrahedron< T >::vertId, and Nektar::SpatialDomains::HOTetrahedron< T >::volVerts.

Referenced by Nektar::NekMeshHOAlignmentUnitTest::BOOST_AUTO_TEST_CASE(), and Nektar::NekMeshHOAlignmentUnitTest::BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ numPts

template<typename T >
int Nektar::SpatialDomains::HOTetrahedron< T >::numPts = 0

Points along an edge of the element, or zero if volVerts is only its interior and the order should be worked out from that.

Definition at line 381 of file HOAlignment.h.

Referenced by Nektar::SpatialDomains::HOTetrahedron< T >::Align().

◆ vertId

template<typename T >
std::vector<int> Nektar::SpatialDomains::HOTetrahedron< T >::vertId

The tetrahedron vertex IDs.

Definition at line 373 of file HOAlignment.h.

Referenced by Nektar::SpatialDomains::HOTetrahedron< T >::Align().

◆ volVerts

template<typename T >
std::vector<T> Nektar::SpatialDomains::HOTetrahedron< T >::volVerts

The interior nodes, in the ordering a nodal tetrahedron of this order puts them in – templated so that this can be either nodes or IDs.

Definition at line 377 of file HOAlignment.h.

Referenced by Nektar::SpatialDomains::HOTetrahedron< T >::Align(), Nektar::NekMeshHOAlignmentUnitTest::BOOST_AUTO_TEST_CASE(), and Nektar::NekMeshHOAlignmentUnitTest::BOOST_AUTO_TEST_CASE().