Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
Nektar::LibUtilities::NodalUtilPrism Class Reference

Specialisation of the NodalUtil class to support nodal prismatic elements. More...

#include <NodalUtil.h>

Inheritance diagram for Nektar::LibUtilities::NodalUtilPrism:
[legend]

Public Member Functions

 NodalUtilPrism (size_t degree, Array< OneD, NekDouble > r, Array< OneD, NekDouble > s, Array< OneD, NekDouble > t)
 Construct the nodal utility class for a prism.
 
 ~NodalUtilPrism () override
 
- Public Member Functions inherited from Nektar::LibUtilities::NodalUtil
virtual ~NodalUtil ()=default
 
NekVector< NekDouble > GetWeights ()
 Obtain the integration weights for the given nodal distribution.
 
SharedMatrix GetVandermonde ()
 Return the Vandermonde matrix for the nodal distribution.
 
SharedMatrix GetVandermondeForDeriv (size_t dir)
 Return the Vandermonde matrix of the derivative of the basis functions for the nodal distribution.
 
SharedMatrix GetDerivMatrix (size_t dir)
 Return the derivative matrix for the nodal distribution.
 
SharedMatrix GetInterpolationMatrix (Array< OneD, Array< OneD, NekDouble > > &xi)
 Construct the interpolation matrix used to evaluate the basis at the points xi inside the element.
 

Static Public Member Functions

static void CartesianOrdering (const int nq, Array< OneD, int > &sorted)
 

Protected Member Functions

NekVector< NekDouble > v_OrthoBasis (const size_t mode) override
 Return the value of the modal functions for the prismatic element at the nodal points m_xi for a given mode.
 
NekVector< NekDouble > v_OrthoBasisDeriv (const size_t dir, const size_t mode) override
 Return the value of the derivative of the modal functions for the prismatic element at the nodal points m_xi for a given mode.
 
std::shared_ptr< NodalUtil > v_CreateUtil (Array< OneD, Array< OneD, NekDouble > > &xi) override
 Construct a NodalUtil object of the appropriate element type for a given set of points.
 
NekDouble v_ModeZeroIntegral () override
 Return the value of the integral of the zero-th mode for this element.
 
size_t v_NumModes () override
 Calculate the number of degrees of freedom for this element.
 
- Protected Member Functions inherited from Nektar::LibUtilities::NodalUtil
 NodalUtil (size_t degree, size_t dim)
 Set up the NodalUtil object.
 

Protected Attributes

std::vector< Mode > m_ordering
 Mapping from the \( (i,j) \) indexing of the basis to a continuous ordering.
 
Array< OneD, Array< OneD, NekDouble > > m_eta
 Collapsed coordinates \( (\eta_1, \eta_2, \eta_3) \) of the nodal points.
 
- Protected Attributes inherited from Nektar::LibUtilities::NodalUtil
size_t m_dim
 Dimension of the nodal element.
 
size_t m_degree
 Degree of the nodal element.
 
size_t m_numPoints
 Total number of nodal points.
 
Array< OneD, Array< OneD, NekDouble > > m_xi
 Coordinates of the nodal points defining the basis.
 

Private Types

typedef std::tuple< int, int, int > Mode
 

Detailed Description

Specialisation of the NodalUtil class to support nodal prismatic elements.

Definition at line 347 of file NodalUtil.h.

Member Typedef Documentation

◆ Mode

typedef std::tuple<int, int, int> Nektar::LibUtilities::NodalUtilPrism::Mode
private

Definition at line 349 of file NodalUtil.h.

Constructor & Destructor Documentation

◆ NodalUtilPrism()

Nektar::LibUtilities::NodalUtilPrism::NodalUtilPrism ( size_t  degree,
Array< OneD, NekDouble >  r,
Array< OneD, NekDouble >  s,
Array< OneD, NekDouble >  t 
)

Construct the nodal utility class for a prism.

The constructor of this class sets up two member variables used in the evaluation of the orthogonal basis:

  • NodalUtilPrism::m_eta is used to construct the collapsed coordinate locations of the nodal points \( (\eta_1, \eta_2, \eta_3) \) inside the cube \([-1,1]^3\) on which the orthogonal basis functions are defined.
  • NodalUtilPrism::m_ordering constructs a mapping from the index set \( I = \{ (i,j,k)\ |\ 0\leq i,j,k \leq P, i+k \leq P \}\) to an ordering \( 0 \leq m(ijk) \leq (P+1)(P+1)(P+2)/2 \) that defines the monomials \( \xi_1^i \xi_2^j \xi_3^k \) that span the prismatic space. This is then used to calculate which \( (i,j,k) \) triple (represented as a tuple) corresponding to a column of the Vandermonde matrix when calculating the orthogonal polynomials.
Parameters
degreePolynomial order of this nodal tetrahedron
r\( \xi_1 \)-coordinates of nodal points in the standard element.
s\( \xi_2 \)-coordinates of nodal points in the standard element.
t\( \xi_3 \)-coordinates of nodal points in the standard element.

Definition at line 643 of file NodalUtil.cpp.

646 : NodalUtil(degree, 3), m_eta(3)
647{
648 m_numPoints = r.size();
649 m_xi[0] = r;
650 m_xi[1] = s;
651 m_xi[2] = t;
652
653 for (size_t i = 0; i <= m_degree; ++i)
654 {
655 for (size_t j = 0; j <= m_degree; ++j)
656 {
657 for (size_t k = 0; k <= m_degree - i; ++k)
658 {
659 m_ordering.push_back(Mode(i, j, k));
660 }
661 }
662 }
663
664 // Calculate collapsed coordinates from r/s values
665 m_eta[0] = Array<OneD, NekDouble>(m_numPoints);
666 m_eta[1] = Array<OneD, NekDouble>(m_numPoints);
667 m_eta[2] = Array<OneD, NekDouble>(m_numPoints);
668
669 for (size_t i = 0; i < m_numPoints; ++i)
670 {
671 if (fabs(m_xi[2][i] - 1.0) < NekConstants::kNekZeroTol)
672 {
673 // Very top point of the prism
674 m_eta[0][i] = -1.0;
675 m_eta[1][i] = m_xi[1][i];
676 m_eta[2][i] = 1.0;
677 }
678 else
679 {
680 // Third basis function collapsed to "pr" direction instead of "qr"
681 // direction
682 m_eta[0][i] = 2.0 * (1.0 + m_xi[0][i]) / (1.0 - m_xi[2][i]) - 1.0;
683 m_eta[1][i] = m_xi[1][i];
684 m_eta[2][i] = m_xi[2][i];
685 }
686 }
687}
Array< OneD, Array< OneD, NekDouble > > m_xi
Coordinates of the nodal points defining the basis.
Definition NodalUtil.h:107
size_t m_degree
Degree of the nodal element.
Definition NodalUtil.h:103
size_t m_numPoints
Total number of nodal points.
Definition NodalUtil.h:105
NodalUtil(size_t degree, size_t dim)
Set up the NodalUtil object.
Definition NodalUtil.h:95
Array< OneD, Array< OneD, NekDouble > > m_eta
Collapsed coordinates of the nodal points.
Definition NodalUtil.h:446
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition NodalUtil.h:442
std::tuple< int, int, int > Mode
Definition NodalUtil.h:349
static const NekDouble kNekZeroTol

References Nektar::NekConstants::kNekZeroTol, Nektar::LibUtilities::NodalUtil::m_degree, m_eta, Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, and Nektar::LibUtilities::NodalUtil::m_xi.

◆ ~NodalUtilPrism()

Nektar::LibUtilities::NodalUtilPrism::~NodalUtilPrism ( )
inlineoverride

Definition at line 356 of file NodalUtil.h.

357 {
358 }

Member Function Documentation

◆ CartesianOrdering()

static void Nektar::LibUtilities::NodalUtilPrism::CartesianOrdering ( const int  nq,
Array< OneD, int > &  sorted 
)
inlinestatic

Definition at line 362 of file NodalUtil.h.

364 {
365 sorted = Array<OneD, int>(nq * nq * (nq + 11) / 2, -1);
366 int cnt = 0;
367 sorted[cnt++] = 0; /* vertex 0 */
368 for (int i = 0; i < nq - 2; ++i) // edge 0
369 {
370 sorted[cnt++] = 6 + i;
371 }
372 sorted[cnt++] = 1; // vertex 1
373 int cnt1 = 0;
374 for (int j = 0; j < nq - 2; ++j)
375 {
376 sorted[cnt++] = 6 + 3 * (nq - 2) + j; // edge 3
377 for (int i = 0; i < nq - 2; ++i) // face 0
378 {
379 sorted[cnt++] = 6 + 9 * (nq - 2) + cnt1++;
380 }
381 sorted[cnt++] = 6 + (nq - 2) + j; // edge 1
382 }
383 sorted[cnt++] = 3; /* vertex 3 */
384 for (int i = 0; i < nq - 2; ++i) // edge 2
385 {
386 sorted[cnt++] = 6 + 2 * (nq - 2) + i;
387 }
388 sorted[cnt++] = 2; /* vertex 2 */
389
390 cnt1 = 0;
391 int cnt2 = 0;
392 int cnt3 = 0;
393 int cnt4 = 0;
394 int cint = 0;
395 for (int k = 0; k < nq - 2; ++k)
396 {
397 sorted[cnt++] = 6 + 4 * (nq - 2) + k; // edge 4
398 for (int i = 0; i < nq - 3 - k; ++i) // face 1
399 {
400 sorted[cnt++] = 6 + 9 * (nq - 2) + (nq - 2) * (nq - 2) + cnt1++;
401 }
402 sorted[cnt++] = 6 + 5 * (nq - 2) + k; // edge 5
403
404 for (int j = 0; j < nq - 2; ++j)
405 {
406 sorted[cnt++] = 6 + 9 * (nq - 2) + 2 * (nq - 3) * (nq - 2) / 2 +
407 2 * (nq - 2) * (nq - 2) + cnt4++; // face 4
408
409 for (int i = 0; i < nq - 3 - k; ++i) /* int */
410 {
411 sorted[cnt++] = 6 + 9 * (nq - 2) +
412 2 * (nq - 3) * (nq - 2) / 2 +
413 3 * (nq - 2) * (nq - 2) + cint++;
414 }
415 sorted[cnt++] = 6 + 9 * (nq - 2) + (nq - 3) * (nq - 2) / 2 +
416 (nq - 2) * (nq - 2) + cnt2++; // face 2
417 }
418
419 sorted[cnt++] = 6 + 7 * (nq - 2) + k; // edge 7
420 for (int i = 0; i < nq - 3 - k; ++i) // face 3
421 {
422 sorted[cnt++] = 6 + 9 * (nq - 2) + (nq - 3) * (nq - 2) / 2 +
423 2 * (nq - 2) * (nq - 2) + cnt3++;
424 }
425 sorted[cnt++] = 6 + 6 * (nq - 2) + k; // edge 6
426 }
427
428 sorted[cnt++] = 4; /* vertex 4 */
429 for (int j = 0; j < nq - 2; ++j) // edge 8
430 {
431 sorted[cnt++] = 6 + 8 * (nq - 2) + j;
432 }
433 sorted[cnt++] = 5; /* vertex 5 */
434
435 ASSERTL1(cnt == nq * nq * (nq + 1) / 2,
436 "No of sorted points not the same as number in expansion");
437 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....

References ASSERTL1.

Referenced by Nektar::QuadEquiSpaced::BOOST_AUTO_TEST_CASE(), Nektar::QuadEquiSpaced::BOOST_AUTO_TEST_CASE(), and Nektar::StdRegions::StdPrismExp::v_GenMatrix().

◆ v_CreateUtil()

std::shared_ptr< NodalUtil > Nektar::LibUtilities::NodalUtilPrism::v_CreateUtil ( Array< OneD, Array< OneD, NekDouble > > &  xi)
inlineoverrideprotectedvirtual

Construct a NodalUtil object of the appropriate element type for a given set of points.

This function is used inside NodalUtil::GetInterpolationMatrix so that the (potentially non-square) Vandermonde matrix can be constructed to create the interpolation matrix at an arbitrary set of points in the domain.

Parameters
xiDistribution of nodal points to create utility with.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 452 of file NodalUtil.h.

454 {
456 xi[1], xi[2]);
457 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and Nektar::LibUtilities::NodalUtil::m_degree.

◆ v_ModeZeroIntegral()

NekDouble Nektar::LibUtilities::NodalUtilPrism::v_ModeZeroIntegral ( )
inlineoverrideprotectedvirtual

Return the value of the integral of the zero-th mode for this element.

Note that for the orthogonal basis under consideration, all modes integrate to zero asides from the zero-th mode. This function is used in NodalUtil::GetWeights to determine integration weights.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 459 of file NodalUtil.h.

460 {
461 return 4.0 * sqrt(2.0);
462 }
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289

References tinysimd::sqrt().

◆ v_NumModes()

size_t Nektar::LibUtilities::NodalUtilPrism::v_NumModes ( )
inlineoverrideprotectedvirtual

Calculate the number of degrees of freedom for this element.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 464 of file NodalUtil.h.

465 {
466 return (m_degree + 1) * (m_degree + 1) * (m_degree + 2) / 2;
467 }

References Nektar::LibUtilities::NodalUtil::m_degree.

◆ v_OrthoBasis()

NekVector< NekDouble > Nektar::LibUtilities::NodalUtilPrism::v_OrthoBasis ( const size_t  mode)
overrideprotectedvirtual

Return the value of the modal functions for the prismatic element at the nodal points m_xi for a given mode.

In a prism, we use the orthogonal basis

\[ \psi_{m(ijk)} = \sqrt{2} P^{(0,0)}_i(\xi_1) P_j^{(0,0)}(\xi_2) P_k^{(2i+1,0)}(\xi_3) (1-\xi_3)^i \]

where \( m(ijk) \) is the mapping defined in m_ordering and \( J_n^{(\alpha,\beta)}(z) \) denotes the standard Jacobi polynomial.

Parameters
modeThe mode of the orthogonal basis to evaluate.
Returns
Vector containing orthogonal basis evaluated at the points m_xi.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 705 of file NodalUtil.cpp.

706{
707 std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
708 std::vector<NekDouble> jacC(m_numPoints);
709
710 size_t I, J, K;
711 std::tie(I, J, K) = m_ordering[mode];
712
713 // Calculate Jacobi polynomials
714 Polylib::jacobfd(m_numPoints, &m_eta[0][0], &jacA[0], nullptr, I, 0.0, 0.0);
715 Polylib::jacobfd(m_numPoints, &m_eta[1][0], &jacB[0], nullptr, J, 0.0, 0.0);
716 Polylib::jacobfd(m_numPoints, &m_eta[2][0], &jacC[0], nullptr, K,
717 2.0 * I + 1.0, 0.0);
718
719 NekVector<NekDouble> ret(m_numPoints);
720 NekDouble sqrt2 = sqrt(2.0);
721
722 for (size_t i = 0; i < m_numPoints; ++i)
723 {
724 ret[i] =
725 sqrt2 * jacA[i] * jacB[i] * jacC[i] * pow(1.0 - m_eta[2][i], I);
726 }
727
728 return ret;
729}
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
Definition Polylib.cpp:1249

References Polylib::jacobfd(), m_eta, Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, and tinysimd::sqrt().

◆ v_OrthoBasisDeriv()

NekVector< NekDouble > Nektar::LibUtilities::NodalUtilPrism::v_OrthoBasisDeriv ( const size_t  dir,
const size_t  mode 
)
overrideprotectedvirtual

Return the value of the derivative of the modal functions for the prismatic element at the nodal points m_xi for a given mode.

Note that this routine must use the chain rule combined with the collapsed coordinate derivatives as described in Sherwin & Karniadakis (2nd edition), pg 152.

Parameters
modeThe mode of the orthogonal basis to evaluate.
dirCoordinate direction in which to evaluate the derivative.
Returns
Vector containing the derivative of the orthogonal basis evaluated at the points m_xi.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 745 of file NodalUtil.cpp.

747{
748 std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
749 std::vector<NekDouble> jacC(m_numPoints);
750 std::vector<NekDouble> jacDerivA(m_numPoints), jacDerivB(m_numPoints);
751 std::vector<NekDouble> jacDerivC(m_numPoints);
752
753 size_t I, J, K;
754 std::tie(I, J, K) = m_ordering[mode];
755
756 // Calculate Jacobi polynomials
757 Polylib::jacobfd(m_numPoints, &m_eta[0][0], &jacA[0], nullptr, I, 0.0, 0.0);
758 Polylib::jacobfd(m_numPoints, &m_eta[1][0], &jacB[0], nullptr, J, 0.0, 0.0);
759 Polylib::jacobfd(m_numPoints, &m_eta[2][0], &jacC[0], nullptr, K,
760 2.0 * I + 1.0, 0.0);
761 Polylib::jacobd(m_numPoints, &m_eta[0][0], &jacDerivA[0], I, 0.0, 0.0);
762 Polylib::jacobd(m_numPoints, &m_eta[1][0], &jacDerivB[0], J, 0.0, 0.0);
763 Polylib::jacobd(m_numPoints, &m_eta[2][0], &jacDerivC[0], K, 2.0 * I + 1.0,
764 0.0);
765
766 NekVector<NekDouble> ret(m_numPoints);
767 NekDouble sqrt2 = sqrt(2.0);
768
769 if (dir == 1)
770 {
771 for (size_t i = 0; i < m_numPoints; ++i)
772 {
773 ret[i] = sqrt2 * jacA[i] * jacDerivB[i] * jacC[i] *
774 pow(1.0 - m_eta[2][i], I);
775 }
776 }
777 else
778 {
779 for (size_t i = 0; i < m_numPoints; ++i)
780 {
781 ret[i] = 2.0 * sqrt2 * jacDerivA[i] * jacB[i] * jacC[i];
782
783 if (I > 0)
784 {
785 ret[i] *= pow(1.0 - m_eta[2][i], I - 1);
786 }
787 }
788
789 if (dir == 0)
790 {
791 return ret;
792 }
793
794 for (size_t i = 0; i < m_numPoints; ++i)
795 {
796 ret[i] *= 0.5 * (1.0 + m_eta[0][i]);
797
798 NekDouble tmp = jacDerivC[i] * pow(1.0 - m_eta[2][i], I);
799
800 if (I > 0)
801 {
802 tmp -= jacC[i] * I * pow(1.0 - m_eta[2][i], I - 1);
803 }
804
805 ret[i] += sqrt2 * jacA[i] * jacB[i] * tmp;
806 }
807 }
808
809 return ret;
810}
void jacobd(const int np, const double *z, double *polyd, const int n, const double alpha, const double beta)
Calculate the derivative of Jacobi polynomials.
Definition Polylib.cpp:1379

References Polylib::jacobd(), Polylib::jacobfd(), m_eta, Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, and tinysimd::sqrt().

Member Data Documentation

◆ m_eta

Array<OneD, Array<OneD, NekDouble> > Nektar::LibUtilities::NodalUtilPrism::m_eta
protected

Collapsed coordinates \( (\eta_1, \eta_2, \eta_3) \) of the nodal points.

Definition at line 446 of file NodalUtil.h.

Referenced by NodalUtilPrism(), v_OrthoBasis(), and v_OrthoBasisDeriv().

◆ m_ordering

std::vector<Mode> Nektar::LibUtilities::NodalUtilPrism::m_ordering
protected

Mapping from the \( (i,j) \) indexing of the basis to a continuous ordering.

Definition at line 442 of file NodalUtil.h.

Referenced by NodalUtilPrism(), v_OrthoBasis(), and v_OrthoBasisDeriv().