Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
Nektar::LibUtilities::NodalUtilTetrahedron Class Reference

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

#include <NodalUtil.h>

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Private Types

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

Detailed Description

Specialisation of the NodalUtil class to support nodal tetrahedral elements.

Definition at line 210 of file NodalUtil.h.

Member Typedef Documentation

◆ Mode

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

Definition at line 212 of file NodalUtil.h.

Constructor & Destructor Documentation

◆ NodalUtilTetrahedron()

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

Construct the nodal utility class for a tetrahedron.

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

  • NodalUtilTetrahedron::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.
  • NodalUtilTetrahedron::m_ordering constructs a mapping from the index set \( I = \{ (i,j,k)\ |\ 0\leq i,j,k \leq P, i+j \leq P, i+j+k \leq P \}\) to an ordering \( 0 \leq m(ijk) \leq (P+1)(P+2)(P+3)/6 \) that defines the monomials \( \xi_1^i \xi_2^j \xi_3^k \) that span the tetrahedral 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 410 of file NodalUtil.cpp.

414 : NodalUtil(degree, 3), m_eta(3)
415{
416 m_numPoints = r.size();
417 m_xi[0] = r;
418 m_xi[1] = s;
419 m_xi[2] = t;
420
421 for (size_t i = 0; i <= m_degree; ++i)
422 {
423 for (size_t j = 0; j <= m_degree - i; ++j)
424 {
425 for (size_t k = 0; k <= m_degree - i - j; ++k)
426 {
427 m_ordering.push_back(Mode(i, j, k));
428 }
429 }
430 }
431
432 // Calculate collapsed coordinates from r/s values
433 m_eta[0] = Array<OneD, NekDouble>(m_numPoints);
434 m_eta[1] = Array<OneD, NekDouble>(m_numPoints);
435 m_eta[2] = Array<OneD, NekDouble>(m_numPoints);
436
437 for (size_t i = 0; i < m_numPoints; ++i)
438 {
439 if (fabs(m_xi[2][i] - 1.0) < NekConstants::kNekZeroTol)
440 {
441 // Very top point of the tetrahedron
442 m_eta[0][i] = -1.0;
443 m_eta[1][i] = -1.0;
444 m_eta[2][i] = m_xi[2][i];
445 }
446 else
447 {
448 if (fabs(m_xi[1][i] - 1.0) < NekConstants::kNekZeroTol)
449 {
450 // Distant diagonal edge shared by all eta_x coordinate planes:
451 // the xi_y == -xi_z line
452 m_eta[0][i] = -1.0;
453 }
454 else if (fabs(m_xi[1][i] + m_xi[2][i]) < NekConstants::kNekZeroTol)
455 {
456 m_eta[0][i] = -1.0;
457 }
458 else
459 {
460 m_eta[0][i] =
461 2.0 * (1.0 + m_xi[0][i]) / (-m_xi[1][i] - m_xi[2][i]) - 1.0;
462 }
463 m_eta[1][i] = 2.0 * (1.0 + m_xi[1][i]) / (1.0 - m_xi[2][i]) - 1.0;
464 m_eta[2][i] = m_xi[2][i];
465 }
466 }
467}
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
std::tuple< int, int, int > Mode
Definition: NodalUtil.h:212
Array< OneD, Array< OneD, NekDouble > > m_eta
Collapsed coordinates of the nodal points.
Definition: NodalUtil.h:231
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:227
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.

◆ ~NodalUtilTetrahedron()

Nektar::LibUtilities::NodalUtilTetrahedron::~NodalUtilTetrahedron ( )
inlineoverride

Definition at line 220 of file NodalUtil.h.

221 {
222 }

Member Function Documentation

◆ v_CreateUtil()

std::shared_ptr< NodalUtil > Nektar::LibUtilities::NodalUtilTetrahedron::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 237 of file NodalUtil.h.

239 {
241 m_degree, xi[0], xi[1], xi[2]);
242 }
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::NodalUtilTetrahedron::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 244 of file NodalUtil.h.

245 {
246 return 8.0 * sqrt(2.0) / 3.0;
247 }
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References tinysimd::sqrt().

◆ v_NumModes()

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

Calculate the number of degrees of freedom for this element.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 249 of file NodalUtil.h.

250 {
251 return (m_degree + 1) * (m_degree + 2) * (m_degree + 3) / 6;
252 }

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

◆ v_OrthoBasis()

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

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

In a tetrahedron, we use the orthogonal basis

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

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 485 of file NodalUtil.cpp.

486{
487 std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
488 std::vector<NekDouble> jacC(m_numPoints);
489
490 size_t I, J, K;
491 std::tie(I, J, K) = m_ordering[mode];
492
493 // Calculate Jacobi polynomials
494 Polylib::jacobfd(m_numPoints, &m_eta[0][0], &jacA[0], nullptr, I, 0.0, 0.0);
495 Polylib::jacobfd(m_numPoints, &m_eta[1][0], &jacB[0], nullptr, J,
496 2.0 * I + 1.0, 0.0);
497 Polylib::jacobfd(m_numPoints, &m_eta[2][0], &jacC[0], nullptr, K,
498 2.0 * (I + J) + 2.0, 0.0);
499
500 NekVector<NekDouble> ret(m_numPoints);
501 NekDouble sqrt8 = sqrt(8.0);
502
503 for (size_t i = 0; i < m_numPoints; ++i)
504 {
505 ret[i] = sqrt8 * jacA[i] * jacB[i] * jacC[i] *
506 pow(1.0 - m_eta[1][i], I) * pow(1.0 - m_eta[2][i], I + J);
507 }
508
509 return ret;
510}
double NekDouble
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:1248

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

◆ v_OrthoBasisDeriv()

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

Return the value of the derivative of the modal functions for the tetrahedral 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
dirCoordinate direction in which to evaluate the derivative.
modeThe mode of the orthogonal basis to evaluate.
Returns
Vector containing the derivative of the orthogonal basis evaluated at the points m_xi.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 526 of file NodalUtil.cpp.

528{
529 std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
530 std::vector<NekDouble> jacC(m_numPoints);
531 std::vector<NekDouble> jacDerivA(m_numPoints), jacDerivB(m_numPoints);
532 std::vector<NekDouble> jacDerivC(m_numPoints);
533
534 size_t I, J, K;
535 std::tie(I, J, K) = m_ordering[mode];
536
537 // Calculate Jacobi polynomials
538 Polylib::jacobfd(m_numPoints, &m_eta[0][0], &jacA[0], nullptr, I, 0.0, 0.0);
539 Polylib::jacobfd(m_numPoints, &m_eta[1][0], &jacB[0], nullptr, J,
540 2.0 * I + 1.0, 0.0);
541 Polylib::jacobfd(m_numPoints, &m_eta[2][0], &jacC[0], nullptr, K,
542 2.0 * (I + J) + 2.0, 0.0);
543 Polylib::jacobd(m_numPoints, &m_eta[0][0], &jacDerivA[0], I, 0.0, 0.0);
544 Polylib::jacobd(m_numPoints, &m_eta[1][0], &jacDerivB[0], J, 2.0 * I + 1.0,
545 0.0);
546 Polylib::jacobd(m_numPoints, &m_eta[2][0], &jacDerivC[0], K,
547 2.0 * (I + J) + 2.0, 0.0);
548
549 NekVector<NekDouble> ret(m_numPoints);
550 NekDouble sqrt8 = sqrt(8.0);
551
552 // Always compute x-derivative since this term appears in the latter two
553 // terms.
554 for (size_t i = 0; i < m_numPoints; ++i)
555 {
556 ret[i] = 4.0 * sqrt8 * jacDerivA[i] * jacB[i] * jacC[i];
557
558 if (I > 0)
559 {
560 ret[i] *= pow(1 - m_eta[1][i], I - 1);
561 }
562
563 if (I + J > 0)
564 {
565 ret[i] *= pow(1 - m_eta[2][i], I + J - 1);
566 }
567 }
568
569 if (dir >= 1)
570 {
571 // Multiply by (1+a)/2
572 NekVector<NekDouble> tmp(m_numPoints);
573
574 for (size_t i = 0; i < m_numPoints; ++i)
575 {
576 ret[i] *= 0.5 * (m_eta[0][i] + 1.0);
577
578 tmp[i] = 2.0 * sqrt8 * jacA[i] * jacC[i];
579 if (I + J > 0)
580 {
581 tmp[i] *= pow(1.0 - m_eta[2][i], I + J - 1);
582 }
583
584 NekDouble tmp2 = jacDerivB[i] * pow(1.0 - m_eta[1][i], I);
585 if (I > 0)
586 {
587 tmp2 -= I * jacB[i] * pow(1.0 - m_eta[1][i], I - 1);
588 }
589
590 tmp[i] *= tmp2;
591 }
592
593 if (dir == 1)
594 {
595 ret += tmp;
596 return ret;
597 }
598
599 for (size_t i = 0; i < m_numPoints; ++i)
600 {
601 ret[i] += 0.5 * (1.0 + m_eta[1][i]) * tmp[i];
602
603 NekDouble tmp2 = jacDerivC[i] * pow(1.0 - m_eta[2][i], I + J);
604 if (I + J > 0)
605 {
606 tmp2 -= jacC[i] * (I + J) * pow(1.0 - m_eta[2][i], I + J - 1);
607 }
608
609 ret[i] +=
610 sqrt8 * jacA[i] * jacB[i] * pow(1.0 - m_eta[1][i], I) * tmp2;
611 }
612 }
613
614 return ret;
615}
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:1378

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::NodalUtilTetrahedron::m_eta
protected

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

Definition at line 231 of file NodalUtil.h.

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

◆ m_ordering

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

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

Definition at line 227 of file NodalUtil.h.

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