Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::LibUtilities::NodalUtilPrism:
Collaboration graph
[legend]

Public Member Functions

 NodalUtilPrism (int degree, Array< OneD, NekDouble > r, Array< OneD, NekDouble > s, Array< OneD, NekDouble > t)
 Construct the nodal utility class for a prism. More...
 
virtual ~NodalUtilPrism ()
 
- Public Member Functions inherited from Nektar::LibUtilities::NodalUtil
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)
 Return the value of the modal functions for the prismatic element at the nodal points m_xi for a given mode. More...
 
virtual NekVector< NekDoublev_OrthoBasisDeriv (const int dir, const int mode)
 Return the value of the derivative of the modal functions for the prismatic element at the nodal points m_xi for a given mode. More...
 
virtual boost::shared_ptr
< NodalUtil
v_CreateUtil (Array< OneD, Array< OneD, NekDouble > > &xi)
 Construct a NodalUtil object of the appropriate element type for a given set of points. More...
 
virtual NekDouble v_ModeZeroIntegral ()
 Return the value of the integral of the zero-th mode for this element. More...
 
virtual int v_NumModes ()
 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< Modem_ordering
 Mapping from the $ (i,j) $ 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
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...
 

Private Types

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

Detailed Description

Specialisation of the NodalUtil class to support nodal prismatic elements.

Definition at line 264 of file NodalUtil.h.

Member Typedef Documentation

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

Definition at line 266 of file NodalUtil.h.

Constructor & Destructor Documentation

Nektar::LibUtilities::NodalUtilPrism::NodalUtilPrism ( int  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 boost 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 655 of file NodalUtil.cpp.

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

659  : NodalUtil(degree, 3), m_eta(3)
660 {
661  m_numPoints = r.num_elements();
662  m_xi[0] = r;
663  m_xi[1] = s;
664  m_xi[2] = t;
665 
666  for (int i = 0; i <= m_degree; ++i)
667  {
668  for (int j = 0; j <= m_degree; ++j)
669  {
670  for (int k = 0; k <= m_degree - i; ++k)
671  {
672  m_ordering.push_back(Mode(i, j, k));
673  }
674  }
675  }
676 
677  // Calculate collapsed coordinates from r/s values
678  m_eta[0] = Array<OneD, NekDouble>(m_numPoints);
679  m_eta[1] = Array<OneD, NekDouble>(m_numPoints);
680  m_eta[2] = Array<OneD, NekDouble>(m_numPoints);
681 
682  for (int i = 0; i < m_numPoints; ++i)
683  {
684  if (fabs(m_xi[2][i] - 1.0) < NekConstants::kNekZeroTol)
685  {
686  // Very top point of the prism
687  m_eta[0][i] = -1.0;
688  m_eta[1][i] = m_xi[1][i];
689  m_eta[2][i] = 1.0;
690  }
691  else
692  {
693  // Third basis function collapsed to "pr" direction instead of "qr"
694  // direction
695  m_eta[0][i] = 2.0*(1.0 + m_xi[0][i])/(1.0 - m_xi[2][i]) - 1.0;
696  m_eta[1][i] = m_xi[1][i];
697  m_eta[2][i] = m_xi[2][i];
698  }
699  }
700 }
Array< OneD, Array< OneD, NekDouble > > m_eta
Collapsed coordinates of the nodal points.
Definition: NodalUtil.h:285
int m_degree
Degree of the nodal element.
Definition: NodalUtil.h:108
static const NekDouble kNekZeroTol
NodalUtil(int degree, int dim)
Set up the NodalUtil object.
Definition: NodalUtil.h:101
Array< OneD, Array< OneD, NekDouble > > m_xi
Coordinates of the nodal points defining the basis.
Definition: NodalUtil.h:112
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:281
int m_numPoints
Total number of nodal points.
Definition: NodalUtil.h:110
boost::tuple< int, int, int > Mode
Definition: NodalUtil.h:266
virtual Nektar::LibUtilities::NodalUtilPrism::~NodalUtilPrism ( )
inlinevirtual

Definition at line 274 of file NodalUtil.h.

275  {
276  }

Member Function Documentation

virtual boost::shared_ptr<NodalUtil> Nektar::LibUtilities::NodalUtilPrism::v_CreateUtil ( Array< OneD, Array< OneD, NekDouble > > &  xi)
inlineprotectedvirtual

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 291 of file NodalUtil.h.

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

293  {
295  m_degree, xi[0], xi[1], xi[2]);
296  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
int m_degree
Degree of the nodal element.
Definition: NodalUtil.h:108
virtual NekDouble Nektar::LibUtilities::NodalUtilPrism::v_ModeZeroIntegral ( )
inlineprotectedvirtual

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 298 of file NodalUtil.h.

299  {
300  return 4.0 * sqrt(2.0);
301  }
virtual int Nektar::LibUtilities::NodalUtilPrism::v_NumModes ( )
inlineprotectedvirtual

Calculate the number of degrees of freedom for this element.

Implements Nektar::LibUtilities::NodalUtil.

Definition at line 303 of file NodalUtil.h.

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

304  {
305  return (m_degree + 1) * (m_degree + 1) * (m_degree + 2) / 2;
306  }
int m_degree
Degree of the nodal element.
Definition: NodalUtil.h:108
NekVector< NekDouble > Nektar::LibUtilities::NodalUtilPrism::v_OrthoBasis ( const int  mode)
protectedvirtual

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

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

719 {
720  std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
721  std::vector<NekDouble> jacC(m_numPoints);
722  Mode modes = m_ordering[mode];
723 
724  const int I = modes.get<0>(), J = modes.get<1>(), K = modes.get<2>();
725 
726  // Calculate Jacobi polynomials
728  m_numPoints, &m_eta[0][0], &jacA[0], NULL, I, 0.0, 0.0);
730  m_numPoints, &m_eta[1][0], &jacB[0], NULL, J, 0.0, 0.0);
732  m_numPoints, &m_eta[2][0], &jacC[0], NULL, K, 2.0 * I + 1.0, 0.0);
733 
734  NekVector<NekDouble> ret(m_numPoints);
735  NekDouble sqrt2 = sqrt(2.0);
736 
737  for (int i = 0; i < m_numPoints; ++i)
738  {
739  ret[i] = sqrt2 * jacA[i] * jacB[i] * jacC[i] *
740  pow(1.0 - m_eta[2][i], I);
741  }
742 
743  return ret;
744 }
Array< OneD, Array< OneD, NekDouble > > m_eta
Collapsed coordinates of the nodal points.
Definition: NodalUtil.h:285
double NekDouble
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:281
int m_numPoints
Total number of nodal points.
Definition: NodalUtil.h:110
boost::tuple< int, int, int > Mode
Definition: NodalUtil.h:266
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:1951
NekVector< NekDouble > Nektar::LibUtilities::NodalUtilPrism::v_OrthoBasisDeriv ( const int  dir,
const int  mode 
)
protectedvirtual

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

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

762 {
763  std::vector<NekDouble> jacA(m_numPoints), jacB(m_numPoints);
764  std::vector<NekDouble> jacC(m_numPoints);
765  std::vector<NekDouble> jacDerivA(m_numPoints), jacDerivB(m_numPoints);
766  std::vector<NekDouble> jacDerivC(m_numPoints);
767  Mode modes = m_ordering[mode];
768 
769  const int I = modes.get<0>(), J = modes.get<1>(), K = modes.get<2>();
770 
771  // Calculate Jacobi polynomials
773  m_numPoints, &m_eta[0][0], &jacA[0], NULL, I, 0.0, 0.0);
775  m_numPoints, &m_eta[1][0], &jacB[0], NULL, J, 0.0, 0.0);
777  m_numPoints, &m_eta[2][0], &jacC[0], NULL, K, 2.0 * I + 1.0, 0.0);
779  m_numPoints, &m_eta[0][0], &jacDerivA[0], I, 0.0, 0.0);
781  m_numPoints, &m_eta[1][0], &jacDerivB[0], J, 0.0, 0.0);
783  m_numPoints, &m_eta[2][0], &jacDerivC[0], K, 2.0 * I + 1.0, 0.0);
784 
785  NekVector<NekDouble> ret(m_numPoints);
786  NekDouble sqrt2 = sqrt(2.0);
787 
788  if (dir == 1)
789  {
790  for (int i = 0; i < m_numPoints; ++i)
791  {
792  ret[i] = sqrt2 * jacA[i] * jacDerivB[i] * jacC[i] *
793  pow(1.0 - m_eta[2][i], I);
794  }
795  }
796  else
797  {
798  for (int i = 0; i < m_numPoints; ++i)
799  {
800  ret[i] = 2.0 * sqrt2 * jacDerivA[i] * jacB[i] * jacC[i];
801 
802  if (I > 0)
803  {
804  ret[i] *= pow(1.0 - m_eta[2][i], I - 1);
805  }
806  }
807 
808  if (dir == 0)
809  {
810  return ret;
811  }
812 
813  for (int i = 0; i < m_numPoints; ++i)
814  {
815  ret[i] *= 0.5 * (1.0 + m_eta[0][i]);
816 
817  NekDouble tmp = jacDerivC[i] * pow(1.0 - m_eta[2][i], I);
818 
819  if (I > 0)
820  {
821  tmp -= jacC[i] * I * pow(1.0 - m_eta[2][i], I - 1);
822  }
823 
824  ret[i] += sqrt2 * jacA[i] * jacB[i] * tmp;
825  }
826  }
827 
828  return ret;
829 }
Array< OneD, Array< OneD, NekDouble > > m_eta
Collapsed coordinates of the nodal points.
Definition: NodalUtil.h:285
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:2151
double NekDouble
std::vector< Mode > m_ordering
Mapping from the indexing of the basis to a continuous ordering.
Definition: NodalUtil.h:281
int m_numPoints
Total number of nodal points.
Definition: NodalUtil.h:110
boost::tuple< int, int, int > Mode
Definition: NodalUtil.h:266
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:1951

Member Data Documentation

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 285 of file NodalUtil.h.

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

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 281 of file NodalUtil.h.

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