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

The nodes of a high-order prism, and the vertices they sit against. More...

#include <HOAlignment.h>

Public Member Functions

 HOPrism (std::vector< int > pVertId, std::vector< T > pVolVerts, int pNumPts)
 
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.
 

Public Attributes

std::vector< int > vertId
 The prism vertex IDs.
 
std::vector< T > volVerts
 The nodes, in nodal prism ordering.
 
int numPts
 Points along an edge of the element.
 

Detailed Description

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

The nodes of a high-order prism, and the vertices they sit against.

A prism is a triangle extruded along an axis, and the only way one is ever reoriented is by turning that triangle: NekMesh's OrientPrism leaves the element unrotated or spins it one way or the other, and either way both triangular faces turn together and the axis is left alone. So a node is placed by how much of each corner of the triangle it is made of, carried along at whatever height up the axis it already had.

As with HOTetrahedron nothing is evaluated: aligning permutes the nodes that are already held.

Definition at line 493 of file HOAlignment.h.

Constructor & Destructor Documentation

◆ HOPrism()

template<typename T >
Nektar::SpatialDomains::HOPrism< T >::HOPrism ( std::vector< int >  pVertId,
std::vector< T >  pVolVerts,
int  pNumPts 
)
inline
Parameters
pVertIdThe six vertex IDs, in the standard element's order.
pVolVertsEvery node of the element, in the ordering a nodal prism puts them in.
pNumPtsPoints along an edge of the element.

Definition at line 501 of file HOAlignment.h.

502 : vertId(pVertId), volVerts(pVolVerts), numPts(pNumPts)
503 {
504 }
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.

Member Function Documentation

◆ Align()

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

Turn the prism so that its vertices read as vertId.

Definition at line 579 of file HOAlignment.h.

580 {
581 // The corners of the triangular face, in the standard element's
582 // numbering. Whichever of them the wanted first vertex is says how far
583 // the triangle has been turned.
584 static const int triVerts[3] = {0, 1, 4};
585
586 for (int r = 0; r < 3; ++r)
587 {
588 if (vertId[0] == this->vertId[triVerts[r]])
589 {
590 Rotate(r);
591 return;
592 }
593 }
594
595 ASSERTL0(false, "Prism vertices do not match.");
596 }
#define ASSERTL0(condition, msg)
void Rotate(int nrot)
Turn the triangular cross-section nrot thirds of a turn.

References ASSERTL0, Nektar::SpatialDomains::HOPrism< T >::Rotate(), and Nektar::SpatialDomains::HOPrism< T >::vertId.

◆ Rotate()

template<typename T >
void Nektar::SpatialDomains::HOPrism< T >::Rotate ( int  nrot)
inline

Turn the triangular cross-section nrot thirds of a turn.

Definition at line 518 of file HOAlignment.h.

519 {
520 nrot = ((nrot % 3) + 3) % 3;
521 if (nrot == 0 || volVerts.empty())
522 {
523 return;
524 }
525
526 const int np = numPts;
527 ASSERTL0(np * (np + 1) / 2 * np == (int)volVerts.size(),
528 "Number of nodes is not a prism number.");
529
530 LibUtilities::PointsKey pKey(np, LibUtilities::eNodalPrismEvenlySpaced);
531 Array<OneD, NekDouble> px, py, pz;
532 LibUtilities::PointsManager()[pKey]->GetPoints(px, py, pz);
533
534 // Where a node sits: how much of each corner of the triangular
535 // cross-section it is made of, and how far along the axis it is. The
536 // triangle lies in the first and third directions, the axis is the
537 // second.
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));
544 return w;
545 };
546 auto key = [np](const std::array<int, 4> &w) {
547 return ((w[0] * np + w[1]) * np + w[2]) * np + w[3];
548 };
549
550 std::map<int, int> slotOf;
551 for (size_t m = 0; m < volVerts.size(); ++m)
552 {
553 slotOf[key(place(m))] = m;
554 }
555
556 std::vector<T> tmp(volVerts.size());
557 for (size_t m = 0; m < volVerts.size(); ++m)
558 {
559 // Turning the triangle moves each corner's share round to the
560 // next; the height up the axis is untouched.
561 std::array<int, 4> want = place(m), have{};
562 for (int c = 0; c < 3; ++c)
563 {
564 have[(c + nrot) % 3] = want[c];
565 }
566 have[3] = want[3];
567
568 auto it = slotOf.find(key(have));
569 ASSERTL0(it != slotOf.end(), "Could not place a prism node.");
570 tmp[m] = volVerts[it->second];
571 }
572
573 volVerts = tmp;
574 }
PointsManagerT & PointsManager(void)
@ eNodalPrismEvenlySpaced
3D Evenly-spaced points on a Prism
Definition PointsType.h:86

References ASSERTL0, Nektar::LibUtilities::eNodalPrismEvenlySpaced, Nektar::SpatialDomains::HOPrism< T >::numPts, Nektar::LibUtilities::PointsManager(), and Nektar::SpatialDomains::HOPrism< T >::volVerts.

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

Member Data Documentation

◆ numPts

template<typename T >
int Nektar::SpatialDomains::HOPrism< T >::numPts

Points along an edge of the element.

Definition at line 513 of file HOAlignment.h.

Referenced by Nektar::SpatialDomains::HOPrism< T >::Rotate().

◆ vertId

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

The prism vertex IDs.

Definition at line 507 of file HOAlignment.h.

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

◆ volVerts

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