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

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

#include <NodalUtil.h>

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

Public Member Functions

 NodalUtilHex (size_t degree, Array< OneD, NekDouble > r, Array< OneD, NekDouble > s, Array< OneD, NekDouble > t)
 Construct the nodal utility class for a hexahedron. More...
 
 ~NodalUtilHex () 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 hex 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 values of the derivative of the orthogonal basis at the nodal points 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...
 
- 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 hex elements.

Definition at line 346 of file NodalUtil.h.

Member Typedef Documentation

◆ Mode

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

Definition at line 348 of file NodalUtil.h.

Constructor & Destructor Documentation

◆ NodalUtilHex()

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

Construct the nodal utility class for a hexahedron.

The constructor of this class sets up the m_ordering member variable used in the evaluation of the orthogonal basis.

Parameters
degreePolynomial order of this nodal hexahedron.
r\( \xi_1 \)-coordinates of nodal points in the standard element.
s\( \xi_2 \)-coordinates of nodal points in the standard element.

Definition at line 934 of file NodalUtil.cpp.

936 : NodalUtil(degree, 3)
937{
938 // Set up parent variables.
939 m_numPoints = r.size();
940 m_xi[0] = r;
941 m_xi[1] = s;
942 m_xi[2] = t;
943
944 // Construct a mapping (i,j,k) -> m from the tensor product space (i,j,k) to
945 // a single ordering m.
946 for (size_t k = 0; k <= m_degree; ++k)
947 {
948 for (size_t j = 0; j <= m_degree; ++j)
949 {
950 for (size_t i = 0; i <= m_degree; ++i)
951 {
952 m_ordering.push_back(Mode(i, j, k));
953 }
954 }
955 }
956}
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:362
std::tuple< int, int, int > Mode
Definition: NodalUtil.h:348
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

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

◆ ~NodalUtilHex()

Nektar::LibUtilities::NodalUtilHex::~NodalUtilHex ( )
inlineoverride

Definition at line 355 of file NodalUtil.h.

356 {
357 }

Member Function Documentation

◆ v_CreateUtil()

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

370 {
372 xi[1], xi[2]);
373 }
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::NodalUtilHex::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 375 of file NodalUtil.h.

376 {
377 return 8.0;
378 }

◆ v_NumModes()

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

Calculate the number of degrees of freedom for this element.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 380 of file NodalUtil.h.

381 {
382 return (m_degree + 1) * (m_degree + 1) * (m_degree + 1);
383 }

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

◆ v_OrthoBasis()

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

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

In a quad, we use the orthogonal basis

\[ \psi_{m(ijk)} = P^{(0,0)}_i(\xi_1) P_j^{(0,0)}(\xi_2) P_k^{(0,0)}(\xi_3) \]

Parameters
modeThe mode of the orthogonal basis to evaluate.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 970 of file NodalUtil.cpp.

971{
972 std::vector<NekDouble> jacobi_i(m_numPoints), jacobi_j(m_numPoints);
973 std::vector<NekDouble> jacobi_k(m_numPoints);
974
975 size_t I, J, K;
976 std::tie(I, J, K) = m_ordering[mode];
977
978 // Calculate Jacobi polynomials
979 Polylib::jacobfd(m_numPoints, &m_xi[0][0], &jacobi_i[0], nullptr, I, 0.0,
980 0.0);
981 Polylib::jacobfd(m_numPoints, &m_xi[1][0], &jacobi_j[0], nullptr, J, 0.0,
982 0.0);
983 Polylib::jacobfd(m_numPoints, &m_xi[2][0], &jacobi_k[0], nullptr, K, 0.0,
984 0.0);
985
986 NekVector<NekDouble> ret(m_numPoints);
987
988 for (size_t i = 0; i < m_numPoints; ++i)
989 {
990 ret[i] = jacobi_i[i] * jacobi_j[i] * jacobi_k[i];
991 }
992
993 return ret;
994}
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(), Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, and Nektar::LibUtilities::NodalUtil::m_xi.

◆ v_OrthoBasisDeriv()

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

Return the values of the derivative of the orthogonal basis at the nodal points for a given mode.

Parameters
dirCoordinate direction of derivative.
modeMode number, which is between 0 and NodalUtil::v_NumModes()
  • 1.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 996 of file NodalUtil.cpp.

998{
999 std::vector<NekDouble> jacobi_i(m_numPoints), jacobi_j(m_numPoints);
1000 std::vector<NekDouble> jacobi_k(m_numPoints);
1001 std::vector<NekDouble> jacobi_di(m_numPoints), jacobi_dj(m_numPoints);
1002 std::vector<NekDouble> jacobi_dk(m_numPoints);
1003
1004 size_t I, J, K;
1005 std::tie(I, J, K) = m_ordering[mode];
1006
1007 // Calculate Jacobi polynomials and their derivatives. Note that we use both
1008 // jacobfd and jacobd since jacobfd is only valid for derivatives in the
1009 // open interval (-1,1).
1010 Polylib::jacobfd(m_numPoints, &m_xi[0][0], &jacobi_i[0], nullptr, I, 0.0,
1011 0.0);
1012 Polylib::jacobfd(m_numPoints, &m_xi[1][0], &jacobi_j[0], nullptr, J, 0.0,
1013 0.0);
1014 Polylib::jacobfd(m_numPoints, &m_xi[2][0], &jacobi_k[0], nullptr, K, 0.0,
1015 0.0);
1016 Polylib::jacobd(m_numPoints, &m_xi[0][0], &jacobi_di[0], I, 0.0, 0.0);
1017 Polylib::jacobd(m_numPoints, &m_xi[1][0], &jacobi_dj[0], J, 0.0, 0.0);
1018 Polylib::jacobd(m_numPoints, &m_xi[2][0], &jacobi_dk[0], K, 0.0, 0.0);
1019
1020 NekVector<NekDouble> ret(m_numPoints);
1021
1022 if (dir == 0)
1023 {
1024 for (size_t i = 0; i < m_numPoints; ++i)
1025 {
1026 ret[i] = jacobi_di[i] * jacobi_j[i] * jacobi_k[i];
1027 }
1028 }
1029 else if (dir == 1)
1030 {
1031 for (size_t i = 0; i < m_numPoints; ++i)
1032 {
1033 ret[i] = jacobi_dj[i] * jacobi_i[i] * jacobi_k[i];
1034 }
1035 }
1036 else
1037 {
1038 for (size_t i = 0; i < m_numPoints; ++i)
1039 {
1040 ret[i] = jacobi_i[i] * jacobi_j[i] * jacobi_dk[i];
1041 }
1042 }
1043
1044 return ret;
1045}
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(), Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, and Nektar::LibUtilities::NodalUtil::m_xi.

Member Data Documentation

◆ m_ordering

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

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

Definition at line 362 of file NodalUtil.h.

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