Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Nektar::SpatialDomains::GeomFactors Class Reference

Calculation and storage of geometric factors associated with the mapping from StdRegions reference elements to a given LocalRegions physical element in the mesh. More...

#include <GeomFactors.h>

Public Member Functions

 GeomFactors (const GeomType gtype, const int coordim, const StdRegions::StdExpansionSharedPtr &xmap, const Array< OneD, Array< OneD, NekDouble > > &coords)
 Constructor for GeomFactors class. More...
 
 GeomFactors (const GeomFactors &S)
 Copy constructor. More...
 
 ~GeomFactors ()
 Destructor. More...
 
DerivStorage GetDeriv (const LibUtilities::PointsKeyVector &keyTgt)
 Return the derivative of the mapping with respect to the reference coordinates, \(\frac{\partial \chi_i}{\partial \xi_j}\). More...
 
const Array< OneD, const NekDoubleGetJac (const LibUtilities::PointsKeyVector &keyTgt)
 Return the Jacobian of the mapping and cache the result. More...
 
const Array< TwoD, const NekDoubleGetGmat (const LibUtilities::PointsKeyVector &keyTgt)
 Return the Laplacian coefficients \(g_{ij}\). More...
 
const Array< TwoD, const NekDoubleGetDerivFactors (const LibUtilities::PointsKeyVector &keyTgt)
 Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\). More...
 
void GetMovingFrames (const LibUtilities::PointsKeyVector &keyTgt, const SpatialDomains::GeomMMF MMFdir, const Array< OneD, const NekDouble > &CircCentre, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Returns moving frames. More...
 
GeomType GetGtype ()
 Returns whether the geometry is regular or deformed. More...
 
bool IsValid () const
 Determine if element is valid and not self-intersecting. More...
 
int GetCoordim () const
 Return the number of dimensions of the coordinate system. More...
 
size_t GetHash ()
 Computes a hash of this GeomFactors element. More...
 

Protected Member Functions

StdRegions::StdExpansionSharedPtrGetXmap ()
 Return the Xmap;. More...
 

Protected Attributes

GeomType m_type
 Type of geometry (e.g. eRegular, eDeformed, eMovingRegular). More...
 
int m_expDim
 Dimension of expansion. More...
 
int m_coordDim
 Dimension of coordinate system. More...
 
bool m_valid
 Validity of element (Jacobian positive) More...
 
enum GeomMMF m_MMFDir
 Principle tangent direction for MMF. More...
 
StdRegions::StdExpansionSharedPtr m_xmap
 Stores information about the expansion. More...
 
Array< OneD, Array< OneD, NekDouble > > m_coords
 Stores coordinates of the geometry. More...
 
std::map< LibUtilities::PointsKeyVector, Array< OneD, NekDouble > > m_jacCache
 Jacobian vector cache. More...
 
std::map< LibUtilities::PointsKeyVector, Array< TwoD, NekDouble > > m_derivFactorCache
 DerivFactors vector cache. More...
 

Private Member Functions

void CheckIfValid ()
 Tests if the element is valid and not self-intersecting. More...
 
DerivStorage ComputeDeriv (const LibUtilities::PointsKeyVector &keyTgt) const
 
Array< OneD, NekDoubleComputeJac (const LibUtilities::PointsKeyVector &keyTgt) const
 Return the Jacobian of the mapping and cache the result. More...
 
Array< TwoD, NekDoubleComputeGmat (const LibUtilities::PointsKeyVector &keyTgt) const
 Computes the Laplacian coefficients \(g_{ij}\). More...
 
Array< TwoD, NekDoubleComputeDerivFactors (const LibUtilities::PointsKeyVector &keyTgt) const
 Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\). More...
 
void ComputeMovingFrames (const LibUtilities::PointsKeyVector &keyTgt, const SpatialDomains::GeomMMF MMFdir, const Array< OneD, const NekDouble > &CircCentre, Array< OneD, Array< OneD, NekDouble > > &movingframes)
 
void Interp (const LibUtilities::PointsKeyVector &src_points, const Array< OneD, const NekDouble > &src, const LibUtilities::PointsKeyVector &tgt_points, Array< OneD, NekDouble > &tgt) const
 Perform interpolation of data between two point distributions. More...
 
void Adjoint (const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
 Compute the transpose of the cofactors matrix. More...
 
void ComputePrincipleDirection (const LibUtilities::PointsKeyVector &keyTgt, const SpatialDomains::GeomMMF MMFdir, const Array< OneD, const NekDouble > &CircCentre, Array< OneD, Array< OneD, NekDouble > > &output)
 
void VectorNormalise (Array< OneD, Array< OneD, NekDouble > > &array)
 
void VectorCrossProd (const Array< OneD, const Array< OneD, NekDouble > > &v1, const Array< OneD, const Array< OneD, NekDouble > > &v2, Array< OneD, Array< OneD, NekDouble > > &v3)
 Computes the vector cross-product in 3D of v1 and v2, storing the result in v3. More...
 

Friends

bool operator== (const GeomFactors &lhs, const GeomFactors &rhs)
 Tests if two GeomFactors classes are equal. More...
 

Detailed Description

Calculation and storage of geometric factors associated with the mapping from StdRegions reference elements to a given LocalRegions physical element in the mesh.

This class stores the various geometric factors associated with a specific element, necessary for fundamental integration and differentiation operations as well as edge and surface normals.

Initially, these algorithms are provided with a mapping from the reference region element to the physical element. Practically, this is represented using a corresponding reference region element for each coordinate component. Note that for straight-sided elements, these elements will be of linear order. Curved elements are represented using higher-order coordinate mappings. This geometric order is in contrast to the order of the spectral/hp expansion order on the element.

For application of the chain rule during differentiation we require the partial derivatives

\[\frac{\partial \xi_i}{\partial \chi_j}\]

evaluated at the physical points of the expansion basis. We also construct the inverse metric tensor \(g^{ij}\) which, in the case of a domain embedded in a higher-dimensional space, supports the conversion of covariant quantities to contravariant quantities. When the expansion dimension is equal to the coordinate dimension the Jacobian of the mapping \(\chi_j\) is a square matrix and consequently the required terms are the entries of the inverse of the Jacobian. However, in general this is not the case, so we therefore implement the construction of these terms following the derivation in Cantwell, et. al. [CaYaKiPeSh13]. Given the coordinate maps \(\chi_i\), this comprises of five steps

  1. Compute the terms of the Jacobian \(\frac{\partial \chi_i}{\partial \xi_j}\).
  2. Compute the metric tensor \(g_{ij}=\mathbf{t}_{(i)}\cdot\mathbf{t}_{(j)}\).
  3. Compute the square of the Jacobian determinant \(g=|\mathbf{g}|\).
  4. Compute the inverse metric tensor \(g^{ij}\).
  5. Compute the terms \(\frac{\partial \xi_i}{\partial \chi_j}\).

Definition at line 75 of file GeomFactors.h.

Constructor & Destructor Documentation

◆ GeomFactors() [1/2]

Nektar::SpatialDomains::GeomFactors::GeomFactors ( const GeomType  gtype,
const int  coordim,
const StdRegions::StdExpansionSharedPtr xmap,
const Array< OneD, Array< OneD, NekDouble > > &  coords 
)

Constructor for GeomFactors class.

Parameters
gtypeSpecified whether the geometry is regular or deformed.
coordimSpecifies the dimension of the coordinate system.
CoordsCoordinate maps of the element.

Definition at line 88 of file GeomFactors.cpp.

References CheckIfValid().

92  :
93  m_type(gtype),
94  m_expDim(xmap->GetShapeDimension()),
95  m_coordDim(coordim),
96  m_valid(true),
97  m_xmap(xmap),
98  m_coords(coords)
99  {
100  CheckIfValid();
101  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void CheckIfValid()
Tests if the element is valid and not self-intersecting.
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
bool m_valid
Validity of element (Jacobian positive)
Definition: GeomFactors.h:141
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
Array< OneD, Array< OneD, NekDouble > > m_coords
Stores coordinates of the geometry.
Definition: GeomFactors.h:149
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147

◆ GeomFactors() [2/2]

Nektar::SpatialDomains::GeomFactors::GeomFactors ( const GeomFactors S)

Copy constructor.

Parameters
SAn instance of a GeomFactors class from which to construct a new instance.

Definition at line 108 of file GeomFactors.cpp.

108  :
109  m_type(S.m_type),
110  m_expDim(S.m_expDim),
111  m_coordDim(S.m_coordDim),
112  m_valid(S.m_valid),
113  m_xmap(S.m_xmap),
114  m_coords(S.m_coords)
115  {
116  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
bool m_valid
Validity of element (Jacobian positive)
Definition: GeomFactors.h:141
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
Array< OneD, Array< OneD, NekDouble > > m_coords
Stores coordinates of the geometry.
Definition: GeomFactors.h:149
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147

◆ ~GeomFactors()

Nektar::SpatialDomains::GeomFactors::~GeomFactors ( )

Destructor.

Definition at line 122 of file GeomFactors.cpp.

123  {
124  }

Member Function Documentation

◆ Adjoint()

void Nektar::SpatialDomains::GeomFactors::Adjoint ( const Array< TwoD, const NekDouble > &  src,
Array< TwoD, NekDouble > &  tgt 
) const
private

Compute the transpose of the cofactors matrix.

Input and output arrays are of dimension (m_expDim*m_expDim) x num_points. The first index of the input and output arrays are ordered row-by-row.

Parameters
srcInput data array.
tgtStorage for adjoint matrix data.

Definition at line 716 of file GeomFactors.cpp.

References ASSERTL1, Vmath::Fill(), m_expDim, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Vvtvvtm().

Referenced by ComputeDerivFactors(), ComputeGmat(), and ComputeJac().

719  {
720  ASSERTL1(src.num_elements() == tgt.num_elements(),
721  "Source matrix is of different size to destination"
722  "matrix for computing adjoint.");
723 
724  int n = src[0].num_elements();
725  switch (m_expDim)
726  {
727  case 1:
728  Vmath::Fill (n, 1.0, &tgt[0][0], 1);
729  break;
730  case 2:
731  Vmath::Vcopy(n, &src[3][0], 1, &tgt[0][0], 1);
732  Vmath::Smul (n, -1.0, &src[1][0], 1, &tgt[1][0], 1);
733  Vmath::Smul (n, -1.0, &src[2][0], 1, &tgt[2][0], 1);
734  Vmath::Vcopy(n, &src[0][0], 1, &tgt[3][0], 1);
735  break;
736  case 3:
737  {
738  int a, b, c, d, e, i, j;
739 
740  // Compute g^{ij} by computing Cofactors(g_ij)^T
741  for (i = 0; i < m_expDim; ++i)
742  {
743  for (j = 0; j < m_expDim; ++j)
744  {
745  a = ((i+1)%m_expDim) * m_expDim + ((j+1)%m_expDim);
746  b = ((i+1)%m_expDim) * m_expDim + ((j+2)%m_expDim);
747  c = ((i+2)%m_expDim) * m_expDim + ((j+1)%m_expDim);
748  d = ((i+2)%m_expDim) * m_expDim + ((j+2)%m_expDim);
749  e = j*m_expDim + i;
750  Vmath::Vvtvvtm(n, &src[a][0], 1, &src[d][0], 1,
751  &src[b][0], 1, &src[c][0], 1,
752  &tgt[e][0], 1);
753  }
754  }
755  break;
756  }
757  }
758  }
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
void Vvtvvtm(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtm (vector times vector minus vector times vector):
Definition: Vmath.cpp:567
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ CheckIfValid()

void Nektar::SpatialDomains::GeomFactors::CheckIfValid ( )
private

Tests if the element is valid and not self-intersecting.

Constructs the Jacobian as per Spencer's book p158 and tests if negative.

Definition at line 608 of file GeomFactors.cpp.

References Nektar::SpatialDomains::eMovingRegular, Nektar::SpatialDomains::eRegular, GetDeriv(), m_coordDim, m_expDim, m_type, m_valid, m_xmap, CellMLToNektar.cellml_metadata::p, Vmath::Vmin(), Vmath::Vvtvp(), and Vmath::Vvtvvtm().

Referenced by GeomFactors().

609  {
610  // Jacobian test only makes sense when expdim = coorddim
611  // If one-dimensional then element is valid.
612  if (m_coordDim != m_expDim || m_expDim == 1)
613  {
614  m_valid = true;
615  return;
616  }
617 
619  int nqtot = 1;
620  for (int i = 0; i < m_expDim; ++i)
621  {
622  p[i] = m_xmap->GetBasis(i)->GetPointsKey();
623  nqtot *= p[i].GetNumPoints();
624  }
625  int pts = (m_type == eRegular || m_type == eMovingRegular)
626  ? 1 : nqtot;
627  Array<OneD, NekDouble> jac(pts, 0.0);
628 
629  DerivStorage deriv = GetDeriv(p);
630 
631  switch (m_expDim)
632  {
633  case 2:
634  {
635  Vmath::Vvtvvtm(pts, &deriv[0][0][0], 1, &deriv[1][1][0], 1,
636  &deriv[1][0][0], 1, &deriv[0][1][0], 1,
637  &jac[0], 1);
638  break;
639  }
640  case 3:
641  {
642  Array<OneD, NekDouble> tmp(pts, 0.0);
643 
644  Vmath::Vvtvvtm(pts, &deriv[1][1][0], 1, &deriv[2][2][0], 1,
645  &deriv[2][1][0], 1, &deriv[1][2][0], 1,
646  &tmp[0], 1);
647  Vmath::Vvtvp (pts, &deriv[0][0][0], 1, &tmp[0], 1,
648  &jac[0], 1, &jac[0], 1);
649 
650  Vmath::Vvtvvtm(pts, &deriv[2][1][0], 1, &deriv[0][2][0], 1,
651  &deriv[0][1][0], 1, &deriv[2][2][0], 1,
652  &tmp[0], 1);
653  Vmath::Vvtvp (pts, &deriv[1][0][0], 1, &tmp[0], 1,
654  &jac[0], 1, &jac[0], 1);
655 
656  Vmath::Vvtvvtm(pts, &deriv[0][1][0], 1, &deriv[1][2][0], 1,
657  &deriv[1][1][0], 1, &deriv[0][2][0], 1,
658  &tmp[0], 1);
659  Vmath::Vvtvp (pts, &deriv[2][0][0], 1, &tmp[0], 1,
660  &jac[0], 1, &jac[0], 1);
661 
662  break;
663  }
664  }
665 
666  if (Vmath::Vmin(pts, &jac[0], 1) < 0)
667  {
668  m_valid = false;
669  }
670  }
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.cpp:874
DerivStorage GetDeriv(const LibUtilities::PointsKeyVector &keyTgt)
Return the derivative of the mapping with respect to the reference coordinates, . ...
Definition: GeomFactors.h:232
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
bool m_valid
Validity of element (Jacobian positive)
Definition: GeomFactors.h:141
void Vvtvvtm(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtm (vector times vector minus vector times vector):
Definition: Vmath.cpp:567
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
Geometry is straight-sided with constant geometric factors.
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147

◆ ComputeDeriv()

DerivStorage Nektar::SpatialDomains::GeomFactors::ComputeDeriv ( const LibUtilities::PointsKeyVector keyTgt) const
private

Derivatives are computed at the geometry point distributions and interpolated to the target point distributions.

Parameters
tpointsTarget point distributions.
Returns
Derivative of coordinate map evaluated at target point distributions.

Definition at line 169 of file GeomFactors.cpp.

References ASSERTL1, Interp(), m_coordDim, m_coords, m_expDim, and m_xmap.

Referenced by ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), and GetDeriv().

171  {
172  ASSERTL1(keyTgt.size() == m_expDim,
173  "Dimension of target point distribution does not match "
174  "expansion dimension.");
175 
176  int i = 0, j = 0;
177  int nqtot_map = 1;
178  int nqtot_tbasis = 1;
182 
183  // Allocate storage and compute number of points
184  for (i = 0; i < m_expDim; ++i)
185  {
186  map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
187  nqtot_map *= map_points[i].GetNumPoints();
188  nqtot_tbasis *= keyTgt[i].GetNumPoints();
189  deriv[i] = Array<OneD, Array<OneD,NekDouble> >(m_coordDim);
190  d_map[i] = Array<OneD, Array<OneD,NekDouble> >(m_coordDim);
191  }
192 
193  // Calculate local derivatives
194  for(i = 0; i < m_coordDim; ++i)
195  {
196  Array<OneD, NekDouble> tmp(nqtot_map);
197  // Transform from coefficient space to physical space
198  m_xmap->BwdTrans(m_coords[i], tmp);
199 
200  // Allocate storage and take the derivative (calculated at the
201  // points as specified in 'Coords')
202  for (j = 0; j < m_expDim; ++j)
203  {
204  d_map[j][i] = Array<OneD,NekDouble>(nqtot_map);
205  deriv[j][i] = Array<OneD,NekDouble>(nqtot_tbasis);
206  m_xmap->StdPhysDeriv(j, tmp, d_map[j][i]);
207  }
208  }
209 
210  for (i = 0; i < m_coordDim; ++i)
211  {
212  // Interpolate the derivatives:
213  // - from the points as defined in the mapping ('Coords')
214  // - to the points we at which we want to know the metrics
215  // ('tbasis')
216  bool same = true;
217  for (j = 0; j < m_expDim; ++j)
218  {
219  same = same && (map_points[j] == keyTgt[j]);
220  }
221  if( same )
222  {
223  for (j = 0; j < m_expDim; ++j)
224  {
225  deriv[j][i] = d_map[j][i];
226  }
227  }
228  else
229  {
230  for (j = 0; j < m_expDim; ++j)
231  {
232  Interp(map_points, d_map[j][i], keyTgt, deriv[j][i]);
233  }
234  }
235  }
236 
237  return deriv;
238  }
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
void Interp(const LibUtilities::PointsKeyVector &src_points, const Array< OneD, const NekDouble > &src, const LibUtilities::PointsKeyVector &tgt_points, Array< OneD, NekDouble > &tgt) const
Perform interpolation of data between two point distributions.
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
Array< OneD, Array< OneD, NekDouble > > m_coords
Stores coordinates of the geometry.
Definition: GeomFactors.h:149
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ ComputeDerivFactors()

Array< TwoD, NekDouble > Nektar::SpatialDomains::GeomFactors::ComputeDerivFactors ( const LibUtilities::PointsKeyVector keyTgt) const
private

Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\).

Parameters
keyTgtTarget point distributions.
Returns
Derivative factors evaluated at the target point distributions.

Definition at line 397 of file GeomFactors.cpp.

References Adjoint(), ASSERTL1, ComputeDeriv(), Nektar::SpatialDomains::eDeformed, m_coordDim, m_expDim, m_type, Vmath::Vdiv(), Vmath::Vsqrt(), and Vmath::Vvtvp().

Referenced by GetDerivFactors().

399  {
400  ASSERTL1(keyTgt.size() == m_expDim,
401  "Dimension of target point distribution does not match "
402  "expansion dimension.");
403 
404  int i = 0, j = 0, k = 0, l = 0;
405  int ptsTgt = 1;
406 
407  if (m_type == eDeformed)
408  {
409  // Allocate storage and compute number of points
410  for (i = 0; i < m_expDim; ++i)
411  {
412  ptsTgt *= keyTgt[i].GetNumPoints();
413  }
414  }
415 
416  // Get derivative at geometry points
417  DerivStorage deriv = ComputeDeriv(keyTgt);
418 
419  Array<TwoD, NekDouble> tmp (m_expDim*m_expDim, ptsTgt, 0.0);
420  Array<TwoD, NekDouble> gmat(m_expDim*m_expDim, ptsTgt, 0.0);
421  Array<OneD, NekDouble> jac (ptsTgt, 0.0);
422  Array<TwoD, NekDouble> factors(m_expDim*m_coordDim, ptsTgt, 0.0);
423 
424  // Compute g_{ij} as t_i \cdot t_j and store in tmp
425  for (i = 0, l = 0; i < m_expDim; ++i)
426  {
427  for (j = 0; j < m_expDim; ++j, ++l)
428  {
429  for (k = 0; k < m_coordDim; ++k)
430  {
431  Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1,
432  &deriv[j][k][0], 1,
433  &tmp[l][0], 1,
434  &tmp[l][0], 1);
435  }
436  }
437  }
438 
439  Adjoint(tmp, gmat);
440 
441  // Compute g = det(g_{ij}) (= Jacobian squared) and store
442  // temporarily in m_jac.
443  for (i = 0; i < m_expDim; ++i)
444  {
445  Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i*m_expDim][0], 1,
446  &jac[0], 1, &jac[0], 1);
447  }
448 
449  for (i = 0; i < m_expDim*m_expDim; ++i)
450  {
451  Vmath::Vdiv(ptsTgt, &gmat[i][0], 1, &jac[0], 1, &gmat[i][0], 1);
452  }
453 
454  // Compute the Jacobian = sqrt(g)
455  Vmath::Vsqrt(ptsTgt, &jac[0], 1, &jac[0], 1);
456 
457  // Compute the derivative factors
458  for (k = 0, l = 0; k < m_coordDim; ++k)
459  {
460  for (j = 0; j < m_expDim; ++j, ++l)
461  {
462  for (i = 0; i < m_expDim; ++i)
463  {
464  Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1,
465  &gmat[m_expDim*i+j][0], 1,
466  &factors[l][0], 1,
467  &factors[l][0], 1);
468  }
469  }
470  }
471 
472  return factors;
473  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:244
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
void Adjoint(const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
Compute the transpose of the cofactors matrix.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
Geometry is curved or has non-constant factors.

◆ ComputeGmat()

Array< TwoD, NekDouble > Nektar::SpatialDomains::GeomFactors::ComputeGmat ( const LibUtilities::PointsKeyVector keyTgt) const
private

Computes the Laplacian coefficients \(g_{ij}\).

This routine returns a two-dimensional array of values specifying the inverse metric terms associated with the coordinate mapping of the corresponding reference region to the physical element. These terms correspond to the \(g^{ij}\) terms in [CaYaKiPeSh13] and, in the case of an embedded manifold, map covariant quantities to contravariant quantities. The leading index of the array is the index of the term in the tensor numbered as

\[\left(\begin{array}{ccc} 0 & 1 & 2 \\ 1 & 3 & 4 \\ 2 & 4 & 5 \end{array}\right)\]

. The second dimension is either of size 1 in the case of elements having GeomType eRegular, or of size equal to the number of quadrature points for eDeformed elements.

See also
Wikipedia "Covariance and Contravariance of Vectors"
Returns
Two-dimensional array containing the inverse metric tensor of the coordinate mapping.

Definition at line 332 of file GeomFactors.cpp.

References Adjoint(), ASSERTL1, ComputeDeriv(), Nektar::SpatialDomains::eDeformed, m_coordDim, m_expDim, m_type, Vmath::Vdiv(), and Vmath::Vvtvp().

Referenced by GetGmat().

334  {
335  ASSERTL1(keyTgt.size() == m_expDim,
336  "Dimension of target point distribution does not match "
337  "expansion dimension.");
338 
339  int i = 0, j = 0, k = 0, l = 0;
340  int ptsTgt = 1;
341 
342  if (m_type == eDeformed)
343  {
344  // Allocate storage and compute number of points
345  for (i = 0; i < m_expDim; ++i)
346  {
347  ptsTgt *= keyTgt[i].GetNumPoints();
348  }
349  }
350 
351  // Get derivative at geometry points
352  DerivStorage deriv = ComputeDeriv(keyTgt);
353 
354  Array<TwoD, NekDouble> tmp (m_expDim*m_expDim, ptsTgt, 0.0);
355  Array<TwoD, NekDouble> gmat(m_expDim*m_expDim, ptsTgt, 0.0);
356  Array<OneD, NekDouble> jac (ptsTgt, 0.0);
357 
358  // Compute g_{ij} as t_i \cdot t_j and store in tmp
359  for (i = 0, l = 0; i < m_expDim; ++i)
360  {
361  for (j = 0; j < m_expDim; ++j, ++l)
362  {
363  for (k = 0; k < m_coordDim; ++k)
364  {
365  Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1,
366  &deriv[j][k][0], 1,
367  &tmp[l][0], 1,
368  &tmp[l][0], 1);
369  }
370  }
371  }
372 
373  Adjoint(tmp, gmat);
374 
375  // Compute g = det(g_{ij}) (= Jacobian squared) and store
376  // temporarily in m_jac.
377  for (i = 0; i < m_expDim; ++i)
378  {
379  Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i*m_expDim][0], 1,
380  &jac[0], 1, &jac[0], 1);
381  }
382 
383  for (i = 0; i < m_expDim*m_expDim; ++i)
384  {
385  Vmath::Vdiv(ptsTgt, &gmat[i][0], 1, &jac[0], 1, &gmat[i][0], 1);
386  }
387 
388  return gmat;
389  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:244
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
void Adjoint(const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
Compute the transpose of the cofactors matrix.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
Geometry is curved or has non-constant factors.

◆ ComputeJac()

Array< OneD, NekDouble > Nektar::SpatialDomains::GeomFactors::ComputeJac ( const LibUtilities::PointsKeyVector keyTgt) const
private

Return the Jacobian of the mapping and cache the result.

This routine returns an array of values specifying the Jacobian of the mapping at quadrature points in the element. The array is either of size 1 in the case of elements having GeomType eRegular, or of size equal to the number of quadrature points for eDeformed elements.

Returns
Array containing the Jacobian of the coordinate mapping at the quadrature points of the element.
See also
GeomType

Definition at line 252 of file GeomFactors.cpp.

References Adjoint(), ASSERTL1, ComputeDeriv(), Nektar::SpatialDomains::eDeformed, m_coordDim, m_expDim, m_type, Vmath::Vsqrt(), and Vmath::Vvtvp().

Referenced by GetJac(), and Nektar::SpatialDomains::operator==().

254  {
255  ASSERTL1(keyTgt.size() == m_expDim,
256  "Dimension of target point distribution does not match "
257  "expansion dimension.");
258 
259  int i = 0, j = 0, k = 0, l = 0;
260  int ptsTgt = 1;
261 
262  if (m_type == eDeformed)
263  {
264  // Allocate storage and compute number of points
265  for (i = 0; i < m_expDim; ++i)
266  {
267  ptsTgt *= keyTgt[i].GetNumPoints();
268  }
269  }
270 
271  // Get derivative at geometry points
272  DerivStorage deriv = ComputeDeriv(keyTgt);
273 
274  Array<TwoD, NekDouble> tmp (m_expDim*m_expDim, ptsTgt, 0.0);
275  Array<TwoD, NekDouble> gmat(m_expDim*m_expDim, ptsTgt, 0.0);
276  Array<OneD, NekDouble> jac (ptsTgt, 0.0);
277 
278  // Compute g_{ij} as t_i \cdot t_j and store in tmp
279  for (i = 0, l = 0; i < m_expDim; ++i)
280  {
281  for (j = 0; j < m_expDim; ++j, ++l)
282  {
283  for (k = 0; k < m_coordDim; ++k)
284  {
285  Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1,
286  &deriv[j][k][0], 1,
287  &tmp[l][0], 1,
288  &tmp[l][0], 1);
289  }
290  }
291  }
292 
293  Adjoint(tmp, gmat);
294 
295  // Compute g = det(g_{ij}) (= Jacobian squared) and store
296  // temporarily in m_jac.
297  for (i = 0; i < m_expDim; ++i)
298  {
299  Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i*m_expDim][0], 1,
300  &jac[0], 1, &jac[0], 1);
301  }
302 
303  // Compute the Jacobian = sqrt(g)
304  Vmath::Vsqrt(ptsTgt, &jac[0], 1, &jac[0], 1);
305 
306  return jac;
307  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
void Adjoint(const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
Compute the transpose of the cofactors matrix.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
Geometry is curved or has non-constant factors.

◆ ComputeMovingFrames()

void Nektar::SpatialDomains::GeomFactors::ComputeMovingFrames ( const LibUtilities::PointsKeyVector keyTgt,
const SpatialDomains::GeomMMF  MMFdir,
const Array< OneD, const NekDouble > &  CircCentre,
Array< OneD, Array< OneD, NekDouble > > &  movingframes 
)
private

Definition at line 475 of file GeomFactors.cpp.

References ASSERTL1, ComputeDeriv(), ComputePrincipleDirection(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eLOCAL, Vmath::Fill(), m_coordDim, m_expDim, m_type, Vmath::Neg(), Vmath::Vcopy(), VectorCrossProd(), VectorNormalise(), and Vmath::Vvtvp().

Referenced by GetMovingFrames().

480  {
481  ASSERTL1(keyTgt.size() == m_expDim,
482  "Dimension of target point distribution does not match "
483  "expansion dimension.");
484 
485  int i = 0, k = 0;
486  int ptsTgt = 1;
487  int nq = 1;
488 
489  for (i = 0; i < m_expDim; ++i)
490  {
491  nq *= keyTgt[i].GetNumPoints();
492  }
493 
494  if (m_type == eDeformed)
495  {
496  // Allocate storage and compute number of points
497  for (i = 0; i < m_expDim; ++i)
498  {
499  ptsTgt *= keyTgt[i].GetNumPoints();
500  }
501  }
502 
503  // Get derivative at geometry points
504  DerivStorage deriv = ComputeDeriv(keyTgt);
505 
506  // number of moving frames is requited to be 3, even for surfaces
507  int MFdim = 3;
508 
509  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > MFtmp(MFdim);
510 
511  // Compute g_{ij} as t_i \cdot t_j and store in tmp
512  for (i = 0; i < MFdim; ++i)
513  {
514  MFtmp[i] = Array<OneD, Array<OneD, NekDouble> >(m_coordDim);
515  for (k = 0; k < m_coordDim; ++k)
516  {
517  MFtmp[i][k] = Array<OneD, NekDouble>(nq);
518  }
519  }
520 
521  // Compute g_{ij} as t_i \cdot t_j and store in tmp
522  for (i = 0; i < MFdim-1; ++i)
523  {
524  for (k = 0; k < m_coordDim; ++k)
525  {
526  if (m_type == eDeformed)
527  {
528  Vmath::Vcopy(ptsTgt, &deriv[i][k][0], 1,
529  &MFtmp[i][k][0], 1);
530  }
531  else
532  {
533  Vmath::Fill(nq, deriv[i][k][0], MFtmp[i][k], 1);
534  }
535  }
536  }
537 
538  // Direction of MF1 is preserved: MF2 is considered in the same
539  // tangent plane as MF1. MF3 is computed by cross product of MF1
540  // and MF2. MF2 is consequently computed as the cross product of
541  // MF3 and MF1.
542  Array<OneD, Array<OneD,NekDouble> > PrincipleDir(m_coordDim);
543  for (int k=0; k<m_coordDim; k++)
544  {
545  PrincipleDir[k] = Array<OneD, NekDouble>(nq);
546  }
547 
548  if( !(MMFdir == eLOCAL) )
549  {
550  ComputePrincipleDirection(keyTgt, MMFdir,
551  factors, PrincipleDir);
552  }
553 
554  // MF3 = MF1 \times MF2
555  VectorCrossProd(MFtmp[0], MFtmp[1], MFtmp[2]);
556 
557  // Normalizing MF3
558  VectorNormalise(MFtmp[2]);
559 
560  if ( !(MMFdir == eLOCAL) )
561  {
562  Array<OneD, NekDouble> temp(nq, 0.0);
563 
564  // Reorient MF1 along the PrincipleDir
565  for (i = 0; i < m_coordDim; ++i)
566  {
567  Vmath::Vvtvp(nq, MFtmp[2][i], 1,
568  PrincipleDir[i], 1,
569  temp, 1,
570  temp, 1);
571  }
572  Vmath::Neg(nq, temp, 1);
573 
574  // u2 = v2 - < u1 , v2 > ( u1 / < u1, u1 > )
575  for (i = 0; i < m_coordDim; ++i)
576  {
577  Vmath::Vvtvp(nq, temp, 1,
578  MFtmp[2][i], 1,
579  PrincipleDir[i], 1,
580  MFtmp[0][i], 1);
581  }
582  }
583 
584  // Normalizing MF1
585  VectorNormalise(MFtmp[0]);
586 
587  // MF2 = MF3 \times MF1
588  VectorCrossProd(MFtmp[2], MFtmp[0], MFtmp[1]);
589 
590  // Normalizing MF2
591  VectorNormalise(MFtmp[1]);
592 
593  for (i = 0; i < MFdim; ++i)
594  {
595  for (k = 0; k < m_coordDim; ++k)
596  {
597  Vmath::Vcopy(nq, &MFtmp[i][k][0], 1,
598  &movingframes[i*m_coordDim+k][0], 1);
599  }
600  }
601  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void ComputePrincipleDirection(const LibUtilities::PointsKeyVector &keyTgt, const SpatialDomains::GeomMMF MMFdir, const Array< OneD, const NekDouble > &CircCentre, Array< OneD, Array< OneD, NekDouble > > &output)
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void VectorCrossProd(const Array< OneD, const Array< OneD, NekDouble > > &v1, const Array< OneD, const Array< OneD, NekDouble > > &v2, Array< OneD, Array< OneD, NekDouble > > &v3)
Computes the vector cross-product in 3D of v1 and v2, storing the result in v3.
void VectorNormalise(Array< OneD, Array< OneD, NekDouble > > &array)
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
No Principal direction.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition: GeomFactors.h:70
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
Geometry is curved or has non-constant factors.

◆ ComputePrincipleDirection()

void Nektar::SpatialDomains::GeomFactors::ComputePrincipleDirection ( const LibUtilities::PointsKeyVector keyTgt,
const SpatialDomains::GeomMMF  MMFdir,
const Array< OneD, const NekDouble > &  CircCentre,
Array< OneD, Array< OneD, NekDouble > > &  output 
)
private

Definition at line 764 of file GeomFactors.cpp.

References ASSERTL1, Nektar::SpatialDomains::eTangentCircular, Nektar::SpatialDomains::eTangentIrregular, Nektar::SpatialDomains::eTangentNonconvex, Nektar::SpatialDomains::eTangentX, Nektar::SpatialDomains::eTangentXY, Nektar::SpatialDomains::eTangentY, Nektar::SpatialDomains::eTangentZ, Vmath::Fill(), Interp(), m_coordDim, m_coords, m_expDim, and m_xmap.

Referenced by ComputeMovingFrames().

769  {
770  int nq = output[0].num_elements();
771 
772  output = Array<OneD,Array<OneD,NekDouble> >(m_coordDim);
773  for (int i = 0; i < m_coordDim; ++i)
774  {
775  output[i] = Array<OneD, NekDouble> (nq, 0.0);
776  }
777 
778  // Construction of Connection
779  switch(MMFdir)
780  {
781  // projection to x-axis
782  case eTangentX:
783  {
784  Vmath::Fill(nq, 1.0, output[0], 1);
785  break;
786  }
787  case eTangentY:
788  {
789  Vmath::Fill(nq, 1.0, output[1], 1);
790  break;
791  }
792  case eTangentXY:
793  {
794  Vmath::Fill(nq, sqrt(2.0), output[0], 1);
795  Vmath::Fill(nq, sqrt(2.0), output[1], 1);
796  break;
797  }
798  case eTangentZ:
799  {
800  Vmath::Fill(nq, 1.0, output[2], 1);
801  break;
802  }
803  case eTangentCircular:
804  {
805  // Tangent direction depends on spatial location.
806  Array<OneD, Array<OneD, NekDouble> > x(m_coordDim);
807  for (int k = 0; k < m_coordDim; k++)
808  {
809  x[k] = Array<OneD, NekDouble>(nq);
810  }
811 
812  // m_coords are StdExpansions which store the mapping
813  // between the std element and the local element. Bwd
814  // transforming the std element minimum basis gives a
815  // minimum physical basis for geometry. Need to then
816  // interpolate this up to the quadrature basis.
817  int nqtot_map = 1;
819  for (int i = 0; i < m_expDim; ++i)
820  {
821  map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
822  nqtot_map *= map_points[i].GetNumPoints();
823  }
824  Array<OneD, NekDouble> tmp(nqtot_map);
825  for (int k = 0; k < m_coordDim; k++)
826  {
827  m_xmap->BwdTrans(m_coords[k], tmp);
828  Interp(map_points, tmp, keyTgt, x[k]);
829  }
830 
831  // circular around the center of the domain
832  NekDouble radius, xc=0.0, yc=0.0, xdis, ydis;
833  NekDouble la, lb;
834 
835  ASSERTL1(factors.num_elements() >= 4,
836  "factors is too short.");
837 
838  la = factors[0];
839  lb = factors[1];
840  xc = factors[2];
841  yc = factors[3];
842 
843  for (int i = 0; i < nq; i++)
844  {
845  xdis = x[0][i]-xc;
846  ydis = x[1][i]-yc;
847  radius = sqrt(xdis*xdis/la/la+ydis*ydis/lb/lb);
848  output[0][i] = ydis/radius;
849  output[1][i] = -1.0*xdis/radius;
850  }
851  break;
852  }
853  case eTangentIrregular:
854  {
855  // Tangent direction depends on spatial location.
856  Array<OneD, Array<OneD, NekDouble> > x(m_coordDim);
857  for (int k = 0; k < m_coordDim; k++)
858  {
859  x[k] = Array<OneD, NekDouble>(nq);
860  }
861 
862  int nqtot_map = 1;
863  LibUtilities::PointsKeyVector map_points(m_expDim);
864  for (int i = 0; i < m_expDim; ++i)
865  {
866  map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
867  nqtot_map *= map_points[i].GetNumPoints();
868  }
869  Array<OneD, NekDouble> tmp(nqtot_map);
870  for (int k = 0; k < m_coordDim; k++)
871  {
872  m_xmap->BwdTrans(m_coords[k], tmp);
873  Interp(map_points, tmp, keyTgt, x[k]);
874  }
875 
876  // circular around the center of the domain
877  NekDouble xtan, ytan, mag;
878  for (int i = 0; i < nq; i++)
879  {
880  xtan = -1.0*(x[1][i]*x[1][i]*x[1][i] + x[1][i]);
881  ytan = 2.0*x[0][i];
882  mag = sqrt(xtan*xtan + ytan*ytan);
883  output[0][i] = xtan/mag;
884  output[1][i] = ytan/mag;
885  }
886  break;
887  }
888  case eTangentNonconvex:
889  {
890  // Tangent direction depends on spatial location.
891  Array<OneD, Array<OneD, NekDouble> > x(m_coordDim);
892  for (int k = 0; k < m_coordDim; k++)
893  {
894  x[k] = Array<OneD, NekDouble>(nq);
895  }
896 
897  int nqtot_map = 1;
898  LibUtilities::PointsKeyVector map_points(m_expDim);
899  for (int i = 0; i < m_expDim; ++i)
900  {
901  map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
902  nqtot_map *= map_points[i].GetNumPoints();
903  }
904  Array<OneD, NekDouble> tmp(nqtot_map);
905  for (int k = 0; k < m_coordDim; k++)
906  {
907  m_xmap->BwdTrans(m_coords[k], tmp);
908  Interp(map_points, tmp, keyTgt, x[k]);
909  }
910 
911  // circular around the center of the domain
912  NekDouble xtan, ytan, mag;
913  for (int i = 0; i < nq; i++)
914  {
915  xtan = -2.0*x[1][i]*x[1][i]*x[1][i] + x[1][i];
916  ytan = sqrt(3.0)*x[0][i];
917  mag = sqrt(xtan*xtan + ytan*ytan);
918  output[0][i] = xtan/mag;
919  output[1][i] = ytan/mag;
920  }
921  break;
922  }
923  default:
924  {
925  break;
926  }
927  }
928  }
Y coordinate direction.
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
Circular around the centre of domain.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
Circular around the centre of domain.
X coordinate direction.
Z coordinate direction.
void Interp(const LibUtilities::PointsKeyVector &src_points, const Array< OneD, const NekDouble > &src, const LibUtilities::PointsKeyVector &tgt_points, Array< OneD, NekDouble > &tgt) const
Perform interpolation of data between two point distributions.
double NekDouble
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
Array< OneD, Array< OneD, NekDouble > > m_coords
Stores coordinates of the geometry.
Definition: GeomFactors.h:149
Circular around the centre of domain.
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ GetCoordim()

int Nektar::SpatialDomains::GeomFactors::GetCoordim ( ) const
inline

Return the number of dimensions of the coordinate system.

This is greater than or equal to the expansion dimension.

Returns
The dimension of the coordinate system.

Definition at line 328 of file GeomFactors.h.

References m_coordDim.

329  {
330  return m_coordDim;
331  }
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139

◆ GetDeriv()

DerivStorage Nektar::SpatialDomains::GeomFactors::GetDeriv ( const LibUtilities::PointsKeyVector tpoints)
inline

Return the derivative of the mapping with respect to the reference coordinates, \(\frac{\partial \chi_i}{\partial \xi_j}\).

Parameters
tpointsTarget point distributions.
Returns
Derivative evaluated at target point distributions.
See also
GeomFactors::ComputeDeriv

Definition at line 232 of file GeomFactors.h.

References ComputeDeriv().

Referenced by CheckIfValid().

234  {
235  return ComputeDeriv(tpoints);
236  }
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const

◆ GetDerivFactors()

const Array< TwoD, const NekDouble > Nektar::SpatialDomains::GeomFactors::GetDerivFactors ( const LibUtilities::PointsKeyVector keyTgt)
inline

Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\).

Returns cached value if available, otherwise computes derivative factors and stores result in cache.

Parameters
keyTgtTarget point distributions.
Returns
Derivative factors evaluated at target point distributions.
See also
GeomFactors::ComputeDerivFactors

Definition at line 286 of file GeomFactors.h.

References ComputeDerivFactors(), and m_derivFactorCache.

288  {
289  auto x = m_derivFactorCache.find(keyTgt);
290 
291  if (x != m_derivFactorCache.end())
292  {
293  return x->second;
294  }
295 
296  m_derivFactorCache[keyTgt] = ComputeDerivFactors(keyTgt);
297 
298  return m_derivFactorCache[keyTgt];
299 
300  }
Array< TwoD, NekDouble > ComputeDerivFactors(const LibUtilities::PointsKeyVector &keyTgt) const
Return the derivative of the reference coordinates with respect to the mapping, . ...
std::map< LibUtilities::PointsKeyVector, Array< TwoD, NekDouble > > m_derivFactorCache
DerivFactors vector cache.
Definition: GeomFactors.h:155

◆ GetGmat()

const Array< TwoD, const NekDouble > Nektar::SpatialDomains::GeomFactors::GetGmat ( const LibUtilities::PointsKeyVector keyTgt)
inline

Return the Laplacian coefficients \(g_{ij}\).

Parameters
keyTgtTarget point distributions.
Returns
Inverse metric tensor evaluated at target point distributions.
See also
GeomFactors::ComputeGmat

Definition at line 270 of file GeomFactors.h.

References ComputeGmat().

272  {
273  return ComputeGmat(keyTgt);
274  }
Array< TwoD, NekDouble > ComputeGmat(const LibUtilities::PointsKeyVector &keyTgt) const
Computes the Laplacian coefficients .

◆ GetGtype()

GeomType Nektar::SpatialDomains::GeomFactors::GetGtype ( )
inline

Returns whether the geometry is regular or deformed.

A geometric shape is considered regular if it has constant geometric information, and deformed if this information changes throughout the shape.

Returns
The type of geometry.
See also
GeomType

Definition at line 318 of file GeomFactors.h.

References m_type.

319  {
320  return m_type;
321  }
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135

◆ GetHash()

size_t Nektar::SpatialDomains::GeomFactors::GetHash ( )
inline

Computes a hash of this GeomFactors element.

The hash is computed from the geometry type, expansion dimension, coordinate dimension and Jacobian.

Returns
Hash of this GeomFactors object.

Definition at line 348 of file GeomFactors.h.

References Nektar::SpatialDomains::eDeformed, GetJac(), Nektar::hash_combine(), Nektar::hash_range(), m_coordDim, m_expDim, m_type, and m_xmap.

349  {
350  LibUtilities::PointsKeyVector ptsKeys = m_xmap->GetPointsKeys();
351  const Array<OneD, const NekDouble> jac = GetJac(ptsKeys);
352 
353  size_t hash = 0;
354  hash_combine(hash, (int)m_type, m_expDim, m_coordDim);
355  if (m_type == eDeformed)
356  {
357  hash_range(hash, jac.begin(), jac.end());
358  }
359  else
360  {
361  hash_combine(hash, jac[0]);
362  }
363  return hash;
364  }
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:69
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition: GeomFactors.h:135
void hash_combine(std::size_t &seed)
Definition: HashUtils.hpp:46
int m_coordDim
Dimension of coordinate system.
Definition: GeomFactors.h:139
const Array< OneD, const NekDouble > GetJac(const LibUtilities::PointsKeyVector &keyTgt)
Return the Jacobian of the mapping and cache the result.
Definition: GeomFactors.h:248
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147
Geometry is curved or has non-constant factors.

◆ GetJac()

const Array< OneD, const NekDouble > Nektar::SpatialDomains::GeomFactors::GetJac ( const LibUtilities::PointsKeyVector keyTgt)
inline

Return the Jacobian of the mapping and cache the result.

Returns cached value if available, otherwise computes Jacobian and stores result in cache.

Parameters
keyTgtTarget point distributions.
Returns
Jacobian evaluated at target point distributions.
See also
GeomFactors::ComputeJac

Definition at line 248 of file GeomFactors.h.

References ComputeJac(), and m_jacCache.

Referenced by GetHash().

250  {
251  auto x = m_jacCache.find(keyTgt);
252 
253  if (x != m_jacCache.end())
254  {
255  return x->second;
256  }
257 
258  m_jacCache[keyTgt] = ComputeJac(keyTgt);
259 
260  return m_jacCache[keyTgt];
261 
262  }
std::map< LibUtilities::PointsKeyVector, Array< OneD, NekDouble > > m_jacCache
Jacobian vector cache.
Definition: GeomFactors.h:152
Array< OneD, NekDouble > ComputeJac(const LibUtilities::PointsKeyVector &keyTgt) const
Return the Jacobian of the mapping and cache the result.

◆ GetMovingFrames()

void Nektar::SpatialDomains::GeomFactors::GetMovingFrames ( const LibUtilities::PointsKeyVector keyTgt,
const SpatialDomains::GeomMMF  MMFdir,
const Array< OneD, const NekDouble > &  CircCentre,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
inline

Returns moving frames.

Definition at line 302 of file GeomFactors.h.

References ComputeMovingFrames().

306  {
307  ComputeMovingFrames(keyTgt,MMFdir,CircCentre,outarray);
308  }
void ComputeMovingFrames(const LibUtilities::PointsKeyVector &keyTgt, const SpatialDomains::GeomMMF MMFdir, const Array< OneD, const NekDouble > &CircCentre, Array< OneD, Array< OneD, NekDouble > > &movingframes)

◆ GetXmap()

StdRegions::StdExpansionSharedPtr & Nektar::SpatialDomains::GeomFactors::GetXmap ( void  )
inlineprotected

Return the Xmap;.

Definition at line 366 of file GeomFactors.h.

References m_xmap.

367  {
368  return m_xmap;
369  }
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
Definition: GeomFactors.h:147

◆ Interp()

void Nektar::SpatialDomains::GeomFactors::Interp ( const LibUtilities::PointsKeyVector src_points,
const Array< OneD, const NekDouble > &  src,
const LibUtilities::PointsKeyVector tgt_points,
Array< OneD, NekDouble > &  tgt 
) const
private

Perform interpolation of data between two point distributions.

Parameters
map_pointsSource data point distribution.
srcSource data to be interpolated.
tpointsTarget data point distribution.
tgtTarget data storage.

Definition at line 679 of file GeomFactors.cpp.

References ASSERTL1, Nektar::LibUtilities::Interp1D(), Nektar::LibUtilities::Interp2D(), Nektar::LibUtilities::Interp3D(), and m_expDim.

Referenced by ComputeDeriv(), and ComputePrincipleDirection().

684  {
685  ASSERTL1(src_points.size() == tgt_points.size(),
686  "Dimension of target point distribution does not match "
687  "expansion dimension.");
688 
689  switch (m_expDim)
690  {
691  case 1:
692  LibUtilities::Interp1D(src_points[0], src,
693  tgt_points[0], tgt);
694  break;
695  case 2:
696  LibUtilities::Interp2D(src_points[0], src_points[1], src,
697  tgt_points[0], tgt_points[1], tgt);
698  break;
699  case 3:
700  LibUtilities::Interp3D(src_points[0], src_points[1],
701  src_points[2], src,
702  tgt_points[0], tgt_points[1],
703  tgt_points[2], tgt);
704  break;
705  }
706  }
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis...
Definition: Interp.cpp:115
int m_expDim
Dimension of expansion.
Definition: GeomFactors.h:137
void Interp3D(const BasisKey &fbasis0, const BasisKey &fbasis1, const BasisKey &fbasis2, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, const BasisKey &tbasis2, Array< OneD, NekDouble > &to)
this function interpolates a 3D function evaluated at the quadrature points of the 3D basis...
Definition: Interp.cpp:185
void Interp1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
this function interpolates a 1D function evaluated at the quadrature points of the basis fbasis0 to ...
Definition: Interp.cpp:53
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ IsValid()

bool Nektar::SpatialDomains::GeomFactors::IsValid ( ) const
inline

Determine if element is valid and not self-intersecting.

The validity test is performed by testing if the Jacobian is negative at any point in the shape.

Returns
True if the element is not self-intersecting.

Definition at line 338 of file GeomFactors.h.

References m_valid.

339  {
340  return m_valid;
341  }
bool m_valid
Validity of element (Jacobian positive)
Definition: GeomFactors.h:141

◆ VectorCrossProd()

void Nektar::SpatialDomains::GeomFactors::VectorCrossProd ( const Array< OneD, const Array< OneD, NekDouble > > &  v1,
const Array< OneD, const Array< OneD, NekDouble > > &  v2,
Array< OneD, Array< OneD, NekDouble > > &  v3 
)
private

Computes the vector cross-product in 3D of v1 and v2, storing the result in v3.

Parameters
v1First input vector.
v2Second input vector.
v3Output vector computed to be orthogonal to both v1 and v2.

Definition at line 976 of file GeomFactors.cpp.

References ASSERTL0, Vmath::Vmul(), and Vmath::Vvtvm().

Referenced by ComputeMovingFrames().

980  {
981  ASSERTL0(v1.num_elements() == 3,
982  "Input 1 has dimension not equal to 3.");
983  ASSERTL0(v2.num_elements() == 3,
984  "Input 2 has dimension not equal to 3.");
985  ASSERTL0(v3.num_elements() == 3,
986  "Output vector has dimension not equal to 3.");
987 
988  int nq = v1[0].num_elements();
989  Array<OneD, NekDouble> temp(nq);
990 
991  Vmath::Vmul (nq, v1[2], 1, v2[1], 1, temp, 1);
992  Vmath::Vvtvm(nq, v1[1], 1, v2[2], 1, temp, 1, v3[0], 1);
993 
994  Vmath::Vmul (nq, v1[0], 1, v2[2], 1, temp, 1);
995  Vmath::Vvtvm(nq, v1[2], 1, v2[0], 1, temp, 1, v3[1], 1);
996 
997  Vmath::Vmul (nq, v1[1], 1, v2[0], 1, temp, 1);
998  Vmath::Vvtvm(nq, v1[0], 1, v2[1], 1, temp, 1, v3[2], 1);
999  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector plus vector): z = w*x - y
Definition: Vmath.cpp:468
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:186

◆ VectorNormalise()

void Nektar::SpatialDomains::GeomFactors::VectorNormalise ( Array< OneD, Array< OneD, NekDouble > > &  array)
private

Definition at line 934 of file GeomFactors.cpp.

References ASSERTL0, Vmath::Vdiv(), Vmath::Vsqrt(), and Vmath::Vvtvp().

Referenced by ComputeMovingFrames().

936  {
937  int ndim = array.num_elements();
938  ASSERTL0(ndim > 0, "Number of components must be > 0.");
939  for (int i = 1; i < ndim; ++i)
940  {
941  ASSERTL0(array[i].num_elements() == array[0].num_elements(),
942  "Array size mismatch in coordinates.");
943  }
944 
945  int nq = array[0].num_elements();
946  Array<OneD, NekDouble> norm (nq, 0.0);
947 
948  // Compute the norm of each vector.
949  for (int i = 0; i < ndim; ++i)
950  {
951  Vmath::Vvtvp(nq, array[i], 1,
952  array[i], 1,
953  norm, 1,
954  norm, 1);
955  }
956 
957  Vmath::Vsqrt(nq, norm, 1, norm, 1);
958 
959  // Normalise the vectors by the norm
960  for (int i = 0; i < ndim; ++i)
961  {
962  Vmath::Vdiv(nq, array[i], 1, norm, 1, array[i], 1);
963  }
964  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:244

Friends And Related Function Documentation

◆ operator==

bool operator== ( const GeomFactors lhs,
const GeomFactors rhs 
)
friend

Tests if two GeomFactors classes are equal.

Member data equivalence is tested in the following order: shape type, expansion dimension, coordinate dimension and coordinates.

Definition at line 131 of file GeomFactors.cpp.

132  {
133  if(!(lhs.m_type == rhs.m_type))
134  {
135  return false;
136  }
137 
138  if(!(lhs.m_expDim == rhs.m_expDim))
139  {
140  return false;
141  }
142 
143  if(!(lhs.m_coordDim == rhs.m_coordDim))
144  {
145  return false;
146  }
147 
148  const Array<OneD, const NekDouble> jac_lhs =
149  lhs.ComputeJac(lhs.m_xmap->GetPointsKeys());
150  const Array<OneD, const NekDouble> jac_rhs =
151  rhs.ComputeJac(rhs.m_xmap->GetPointsKeys());
152  if(!(jac_lhs == jac_rhs))
153  {
154  return false;
155  }
156 
157  return true;
158  }
StandardMatrixTag & lhs
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs

Member Data Documentation

◆ m_coordDim

int Nektar::SpatialDomains::GeomFactors::m_coordDim
protected

◆ m_coords

Array<OneD, Array<OneD, NekDouble> > Nektar::SpatialDomains::GeomFactors::m_coords
protected

Stores coordinates of the geometry.

Definition at line 149 of file GeomFactors.h.

Referenced by ComputeDeriv(), and ComputePrincipleDirection().

◆ m_derivFactorCache

std::map<LibUtilities::PointsKeyVector, Array<TwoD, NekDouble> > Nektar::SpatialDomains::GeomFactors::m_derivFactorCache
protected

DerivFactors vector cache.

Definition at line 155 of file GeomFactors.h.

Referenced by GetDerivFactors().

◆ m_expDim

int Nektar::SpatialDomains::GeomFactors::m_expDim
protected

◆ m_jacCache

std::map<LibUtilities::PointsKeyVector, Array<OneD, NekDouble> > Nektar::SpatialDomains::GeomFactors::m_jacCache
protected

Jacobian vector cache.

Definition at line 152 of file GeomFactors.h.

Referenced by GetJac().

◆ m_MMFDir

enum GeomMMF Nektar::SpatialDomains::GeomFactors::m_MMFDir
protected

Principle tangent direction for MMF.

Definition at line 144 of file GeomFactors.h.

◆ m_type

GeomType Nektar::SpatialDomains::GeomFactors::m_type
protected

Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).

Definition at line 135 of file GeomFactors.h.

Referenced by CheckIfValid(), ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), GetGtype(), GetHash(), and Nektar::SpatialDomains::operator==().

◆ m_valid

bool Nektar::SpatialDomains::GeomFactors::m_valid
protected

Validity of element (Jacobian positive)

Definition at line 141 of file GeomFactors.h.

Referenced by CheckIfValid(), and IsValid().

◆ m_xmap

StdRegions::StdExpansionSharedPtr Nektar::SpatialDomains::GeomFactors::m_xmap
protected

Stores information about the expansion.

Definition at line 147 of file GeomFactors.h.

Referenced by CheckIfValid(), ComputeDeriv(), ComputePrincipleDirection(), GetHash(), GetXmap(), and Nektar::SpatialDomains::operator==().