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

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

#include <NodalUtil.h>

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

Public Member Functions

 NodalUtilQuad (int degree, Array< OneD, NekDouble > r, Array< OneD, NekDouble > s)
 Construct the nodal utility class for a quadrilateral. More...
 
virtual ~NodalUtilQuad ()
 
- 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 (int dir)
 Return the Vandermonde matrix of the derivative of the basis functions for the nodal distribution. More...
 
SharedMatrix GetDerivMatrix (int 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

virtual NekVector< NekDoublev_OrthoBasis (const int mode) override
 Return the value of the modal functions for the quad element at the nodal points m_xi for a given mode. More...
 
virtual NekVector< NekDoublev_OrthoBasisDeriv (const int dir, const int mode) override
 Return the value of the derivative of the modal functions for the quadrilateral element at the nodal points m_xi for a given mode. More...
 
virtual 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...
 
virtual NekDouble v_ModeZeroIntegral () override
 Return the value of the integral of the zero-th mode for this element. More...
 
virtual int v_NumModes () override
 Calculate the number of degrees of freedom for this element. More...
 
- Protected Member Functions inherited from Nektar::LibUtilities::NodalUtil
 NodalUtil (int degree, int dim)
 Set up the NodalUtil object. More...
 

Protected Attributes

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

Detailed Description

Specialisation of the NodalUtil class to support nodal quad elements.

Definition at line 309 of file NodalUtil.h.

Constructor & Destructor Documentation

◆ NodalUtilQuad()

Nektar::LibUtilities::NodalUtilQuad::NodalUtilQuad ( int  degree,
Array< OneD, NekDouble r,
Array< OneD, NekDouble s 
)

Construct the nodal utility class for a quadrilateral.

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

828  : NodalUtil(degree, 2)
829 {
830  // Set up parent variables.
831  m_numPoints = r.size();
832  m_xi[0] = r;
833  m_xi[1] = s;
834 
835  // Construct a mapping (i,j) -> m from the tensor product space (i,j) to a
836  // single ordering m.
837  for (int j = 0; j <= m_degree; ++j)
838  {
839  for (int i = 0; i <= m_degree; ++i)
840  {
841  m_ordering.push_back(std::make_pair(i, j));
842  }
843  }
844 }
int m_degree
Degree of the nodal element.
Definition: NodalUtil.h:107
NodalUtil(int degree, int dim)
Set up the NodalUtil object.
Definition: NodalUtil.h:100
int m_numPoints
Total number of nodal points.
Definition: NodalUtil.h:109
Array< OneD, Array< OneD, NekDouble > > m_xi
Coordinates of the nodal points defining the basis.
Definition: NodalUtil.h:111
std::vector< std::pair< int, int > > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:322

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

◆ ~NodalUtilQuad()

virtual Nektar::LibUtilities::NodalUtilQuad::~NodalUtilQuad ( )
inlinevirtual

Definition at line 315 of file NodalUtil.h.

316  {
317  }

Member Function Documentation

◆ v_CreateUtil()

virtual std::shared_ptr<NodalUtil> Nektar::LibUtilities::NodalUtilQuad::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 328 of file NodalUtil.h.

330  {
332  xi[1]);
333  }
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()

virtual NekDouble Nektar::LibUtilities::NodalUtilQuad::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 335 of file NodalUtil.h.

336  {
337  return 4.0;
338  }

◆ v_NumModes()

virtual int Nektar::LibUtilities::NodalUtilQuad::v_NumModes ( )
inlineoverrideprotectedvirtual

Calculate the number of degrees of freedom for this element.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 340 of file NodalUtil.h.

341  {
342  return (m_degree + 1) * (m_degree + 1);
343  }

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

◆ v_OrthoBasis()

NekVector< NekDouble > Nektar::LibUtilities::NodalUtilQuad::v_OrthoBasis ( const int  mode)
overrideprotectedvirtual

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

In a quad, we use the orthogonal basis

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

Parameters
modeThe mode of the orthogonal basis to evaluate.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 859 of file NodalUtil.cpp.

860 {
861  std::vector<NekDouble> jacobi_i(m_numPoints), jacobi_j(m_numPoints);
862  std::pair<int, int> modes = m_ordering[mode];
863 
864  // Calculate Jacobi polynomials
865  Polylib::jacobfd(m_numPoints, &m_xi[0][0], &jacobi_i[0], NULL, modes.first,
866  0.0, 0.0);
867  Polylib::jacobfd(m_numPoints, &m_xi[1][0], &jacobi_j[0], NULL, modes.second,
868  0.0, 0.0);
869 
870  NekVector<NekDouble> ret(m_numPoints);
871 
872  for (int i = 0; i < m_numPoints; ++i)
873  {
874  ret[i] = jacobi_i[i] * jacobi_j[i];
875  }
876 
877  return ret;
878 }
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:1181

References Polylib::jacobfd(), Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, Nektar::LibUtilities::NodalUtil::m_xi, and CG_Iterations::modes.

◆ v_OrthoBasisDeriv()

NekVector< NekDouble > Nektar::LibUtilities::NodalUtilQuad::v_OrthoBasisDeriv ( const int  dir,
const int  mode 
)
overrideprotectedvirtual

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

Parameters
modeThe mode of the orthogonal basis to evaluate.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 886 of file NodalUtil.cpp.

888 {
889  std::vector<NekDouble> jacobi_i(m_numPoints), jacobi_j(m_numPoints);
890  std::vector<NekDouble> jacobi_di(m_numPoints), jacobi_dj(m_numPoints);
891  std::pair<int, int> modes = m_ordering[mode];
892 
893  // Calculate Jacobi polynomials and their derivatives. Note that we use both
894  // jacobfd and jacobd since jacobfd is only valid for derivatives in the
895  // open interval (-1,1).
896  Polylib::jacobfd(m_numPoints, &m_xi[0][0], &jacobi_i[0], NULL, modes.first,
897  0.0, 0.0);
898  Polylib::jacobfd(m_numPoints, &m_xi[1][0], &jacobi_j[0], NULL, modes.second,
899  0.0, 0.0);
900  Polylib::jacobd(m_numPoints, &m_xi[0][0], &jacobi_di[0], modes.first, 0.0,
901  0.0);
902  Polylib::jacobd(m_numPoints, &m_xi[1][0], &jacobi_dj[0], modes.second, 0.0,
903  0.0);
904 
905  NekVector<NekDouble> ret(m_numPoints);
906 
907  if (dir == 0)
908  {
909  for (int i = 0; i < m_numPoints; ++i)
910  {
911  ret[i] = jacobi_di[i] * jacobi_j[i];
912  }
913  }
914  else
915  {
916  for (int i = 0; i < m_numPoints; ++i)
917  {
918  ret[i] = jacobi_i[i] * jacobi_dj[i];
919  }
920  }
921 
922  return ret;
923 }
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:1293

References Polylib::jacobd(), Polylib::jacobfd(), Nektar::LibUtilities::NodalUtil::m_numPoints, m_ordering, Nektar::LibUtilities::NodalUtil::m_xi, and CG_Iterations::modes.

Member Data Documentation

◆ m_ordering

std::vector<std::pair<int, int> > Nektar::LibUtilities::NodalUtilQuad::m_ordering
protected

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

Definition at line 322 of file NodalUtil.h.

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