Nektar++
Loading...
Searching...
No Matches
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 std::vector< Array< OneD, NekDouble > > &coords, const LibUtilities::PointsKeyVector &keyTgt)
 Constructor for GeomFactors class.
 
 GeomFactors (const GeomFactors &S)
 Copy constructor.
 
 ~GeomFactors ()=default
 Destructor.
 
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}\).
 
const Array< OneD, const NekDoubleGetJac ()
 Return the Jacobian of the mapping.
 
Array< OneD, NekDoubleComputeJac (const LibUtilities::PointsKeyVector &keyTgt) const
 Compute the Jacobian of the mapping.
 
const Array< TwoD, const NekDoubleGetGmat (const LibUtilities::PointsKeyVector &keyTgt)
 Return the Laplacian coefficients \(g_{ij}\).
 
const Array< TwoD, const NekDoubleGetDerivFactors ()
 Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\).
 
Array< TwoD, NekDoubleComputeDerivFactors (const LibUtilities::PointsKeyVector &keyTgt) const
 Compute the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\).
 
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.
 
GeomType GetGtype ()
 Returns whether the geometry is regular or deformed.
 
bool IsValid () const
 Determine if element is valid and not self-intersecting.
 
int GetCoordim () const
 Return the number of dimensions of the coordinate system.
 
size_t GetHash ()
 Computes a hash of this GeomFactors element.
 

Protected Member Functions

StdRegions::StdExpansionSharedPtrGetXmap ()
 Return the Xmap;.
 

Protected Attributes

GeomType m_type
 Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
 
int m_expDim
 Dimension of expansion.
 
int m_coordDim
 Dimension of coordinate system.
 
bool m_valid
 Validity of element (Jacobian positive)
 
LibUtilities::PointsKeyVector m_keyTgt
 Default points at which to compute jacobian and derivative factors.
 
enum GeomMMF m_MMFDir
 Principle tangent direction for MMF.
 
StdRegions::StdExpansionSharedPtr m_xmap
 Stores information about the expansion.
 
std::vector< Array< OneD, NekDouble > > m_coords
 Stores coordinates of the geometry.
 
Array< OneD, NekDoublem_jac
 Jacobian vector.
 
Array< TwoD, NekDoublem_derivFactor
 DerivFactors vector.
 
bool m_jacComputed = false
 Indicates whether stored jacobian has been populated.
 
bool m_derivFacComputed = false
 Indicates whether stored derivative factors have been populated.
 

Private Member Functions

void CheckIfValid ()
 Tests if the element is valid and not self-intersecting.
 
DerivStorage ComputeDeriv (const LibUtilities::PointsKeyVector &keyTgt) const
 
Array< TwoD, NekDoubleComputeGmat (const LibUtilities::PointsKeyVector &keyTgt) const
 Computes the Laplacian coefficients \(g_{ij}\).
 
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.
 
void Adjoint (const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
 Compute the transpose of the cofactors matrix.
 
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.
 

Friends

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

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 67 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 std::vector< Array< OneD, NekDouble > > &  coords,
const LibUtilities::PointsKeyVector keyTgt 
)

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.
keyTgtPoints at which to compute stored Jacobian and derivative factors

Definition at line 88 of file GeomFactors.cpp.

92 : m_type(gtype), m_expDim(xmap->GetShapeDimension()), m_coordDim(coordim),
93 m_valid(true), m_keyTgt(keyTgt), m_xmap(xmap), m_coords(coords)
94{
96}
int m_coordDim
Dimension of coordinate system.
LibUtilities::PointsKeyVector m_keyTgt
Default points at which to compute jacobian and derivative factors.
void CheckIfValid()
Tests if the element is valid and not self-intersecting.
int m_expDim
Dimension of expansion.
bool m_valid
Validity of element (Jacobian positive)
StdRegions::StdExpansionSharedPtr m_xmap
Stores information about the expansion.
GeomType m_type
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
std::vector< Array< OneD, NekDouble > > m_coords
Stores coordinates of the geometry.

References CheckIfValid().

◆ 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 102 of file GeomFactors.cpp.

103 : m_type(S.m_type), m_expDim(S.m_expDim), m_coordDim(S.m_coordDim),
104 m_valid(S.m_valid), m_xmap(S.m_xmap), m_coords(S.m_coords),
105 m_jac(S.m_jac), m_derivFactor(S.m_derivFactor)
106{
107}
Array< OneD, NekDouble > m_jac
Jacobian vector.
Array< TwoD, NekDouble > m_derivFactor
DerivFactors vector.

◆ ~GeomFactors()

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

Destructor.

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 709 of file GeomFactors.cpp.

711{
712 if (src.size() != tgt.size())
713 {
715 "Source matrix is of different size to destination"
716 "matrix for computing adjoint.");
717 }
718
719 int n = src[0].size();
720 switch (m_expDim)
721 {
722 case 1:
723 Vmath::Fill(n, 1.0, &tgt[0][0], 1);
724 break;
725 case 2:
726 Vmath::Vcopy(n, &src[3][0], 1, &tgt[0][0], 1);
727 Vmath::Smul(n, -1.0, &src[1][0], 1, &tgt[1][0], 1);
728 Vmath::Smul(n, -1.0, &src[2][0], 1, &tgt[2][0], 1);
729 Vmath::Vcopy(n, &src[0][0], 1, &tgt[3][0], 1);
730 break;
731 case 3:
732 {
733 int a, b, c, d, e, i, j;
734
735 // Compute g^{ij} by computing Cofactors(g_ij)^T
736 for (i = 0; i < m_expDim; ++i)
737 {
738 for (j = 0; j < m_expDim; ++j)
739 {
740 a = ((i + 1) % m_expDim) * m_expDim + ((j + 1) % m_expDim);
741 b = ((i + 1) % m_expDim) * m_expDim + ((j + 2) % m_expDim);
742 c = ((i + 2) % m_expDim) * m_expDim + ((j + 1) % m_expDim);
743 d = ((i + 2) % m_expDim) * m_expDim + ((j + 2) % m_expDim);
744 e = j * m_expDim + i;
745 Vmath::Vvtvvtm(n, &src[a][0], 1, &src[d][0], 1, &src[b][0],
746 1, &src[c][0], 1, &tgt[e][0], 1);
747 }
748 }
749 break;
750 }
751 }
752}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
std::vector< double > d(NPUPPER *NPUPPER)
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.hpp:456
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition Vmath.hpp:100
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:54
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References Nektar::ErrorUtil::ewarning, Vmath::Fill(), m_expDim, NEKERROR, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Vvtvvtm().

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

◆ 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.

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) ? 1 : nqtot;
626 Array<OneD, NekDouble> jac(pts, 0.0);
627
628 DerivStorage deriv = GetDeriv(p);
629
630 switch (m_expDim)
631 {
632 case 2:
633 {
634 Vmath::Vvtvvtm(pts, &deriv[0][0][0], 1, &deriv[1][1][0], 1,
635 &deriv[1][0][0], 1, &deriv[0][1][0], 1, &jac[0], 1);
636 break;
637 }
638 case 3:
639 {
640 Array<OneD, NekDouble> tmp(pts, 0.0);
641
642 Vmath::Vvtvvtm(pts, &deriv[1][1][0], 1, &deriv[2][2][0], 1,
643 &deriv[2][1][0], 1, &deriv[1][2][0], 1, &tmp[0], 1);
644 Vmath::Vvtvp(pts, &deriv[0][0][0], 1, &tmp[0], 1, &jac[0], 1,
645 &jac[0], 1);
646
647 Vmath::Vvtvvtm(pts, &deriv[2][1][0], 1, &deriv[0][2][0], 1,
648 &deriv[0][1][0], 1, &deriv[2][2][0], 1, &tmp[0], 1);
649 Vmath::Vvtvp(pts, &deriv[1][0][0], 1, &tmp[0], 1, &jac[0], 1,
650 &jac[0], 1);
651
652 Vmath::Vvtvvtm(pts, &deriv[0][1][0], 1, &deriv[1][2][0], 1,
653 &deriv[1][1][0], 1, &deriv[0][2][0], 1, &tmp[0], 1);
654 Vmath::Vvtvp(pts, &deriv[2][0][0], 1, &tmp[0], 1, &jac[0], 1,
655 &jac[0], 1);
656
657 break;
658 }
659 }
660
661 if (Vmath::Vmin(pts, &jac[0], 1) < 0)
662 {
663 m_valid = false;
664 }
665}
DerivStorage GetDeriv(const LibUtilities::PointsKeyVector &keyTgt)
Return the derivative of the mapping with respect to the reference coordinates, .
std::vector< PointsKey > PointsKeyVector
Definition Points.h:313
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eMovingRegular
Currently unused.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > DerivStorage
Storage type for derivative of mapping.
Definition GeomFactors.h:62
std::vector< double > p(NPUPPER)
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.hpp:725
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.hpp:366

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

Referenced by GeomFactors().

◆ 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 150 of file GeomFactors.cpp.

152{
153 if (keyTgt.size() != m_expDim)
154 {
156 "Dimension of target point distribution does not match "
157 "expansion dimension.");
158 }
159
160 int i = 0, j = 0;
161 int nqtot_map = 1;
162 int nqtot_tbasis = 1;
166
167 // Allocate storage and compute number of points
168 for (i = 0; i < m_expDim; ++i)
169 {
170 map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
171 nqtot_map *= map_points[i].GetNumPoints();
172 nqtot_tbasis *= keyTgt[i].GetNumPoints();
173 deriv[i] = Array<OneD, Array<OneD, NekDouble>>(m_coordDim);
174 d_map[i] = Array<OneD, Array<OneD, NekDouble>>(m_coordDim);
175 }
176
177 // Calculate local derivatives
178 for (i = 0; i < m_coordDim; ++i)
179 {
180 Array<OneD, NekDouble> tmp(nqtot_map);
181 // Transform from coefficient space to physical space
182 m_xmap->BwdTrans(m_coords[i], tmp);
183
184 // Allocate storage and take the derivative (calculated at the
185 // points as specified in 'Coords')
186 for (j = 0; j < m_expDim; ++j)
187 {
188 d_map[j][i] = Array<OneD, NekDouble>(nqtot_map);
189 deriv[j][i] = Array<OneD, NekDouble>(nqtot_tbasis);
190 }
191
192 switch (m_expDim)
193 {
194 case 1:
195 m_xmap->StdPhysDeriv(tmp, d_map[0][i]);
196 break;
197 case 2:
198 m_xmap->StdPhysDeriv(tmp, d_map[0][i], d_map[1][i]);
199 break;
200 case 3:
201 m_xmap->StdPhysDeriv(tmp, d_map[0][i], d_map[1][i],
202 d_map[2][i]);
203 break;
204 }
205 }
206
207 for (i = 0; i < m_coordDim; ++i)
208 {
209 // Interpolate the derivatives:
210 // - from the points as defined in the mapping ('Coords')
211 // - to the points at which we want to know the metrics
212 // ('tbasis')
213 bool same = true;
214 for (j = 0; j < m_expDim; ++j)
215 {
216 same = same && (map_points[j] == keyTgt[j]);
217 }
218 if (same)
219 {
220 for (j = 0; j < m_expDim; ++j)
221 {
222 deriv[j][i] = d_map[j][i];
223 }
224 }
225 else
226 {
227 for (j = 0; j < m_expDim; ++j)
228 {
229 Interp(map_points, d_map[j][i], keyTgt, deriv[j][i]);
230 }
231 }
232 }
233
234 return deriv;
235}
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.

References Nektar::ErrorUtil::ewarning, Interp(), m_coordDim, m_coords, m_expDim, m_xmap, and NEKERROR.

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

◆ ComputeDerivFactors()

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

Compute 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. A 1D example: /f$ Jac =(\partial x/ \partial \xi) /f$ ; /f$ factor = 1/Jac = (\partial \xi/ \partial x) /f$

Definition at line 401 of file GeomFactors.cpp.

403{
404 if (keyTgt.size() != m_expDim)
405 {
407 "Dimension of target point distribution does not match "
408 "expansion dimension.");
409 }
410
411 int i = 0, j = 0, k = 0, l = 0;
412 int ptsTgt = 1;
413
414 if (m_type == eDeformed)
415 {
416 // Allocate storage and compute number of points
417 for (i = 0; i < m_expDim; ++i)
418 {
419 ptsTgt *= keyTgt[i].GetNumPoints();
420 }
421 }
422
423 // Get derivative at geometry points
424 DerivStorage deriv = ComputeDeriv(keyTgt);
425
426 Array<TwoD, NekDouble> tmp(m_expDim * m_expDim, ptsTgt, 0.0);
427 Array<TwoD, NekDouble> gmat(m_expDim * m_expDim, ptsTgt, 0.0);
428 Array<OneD, NekDouble> jac(ptsTgt, 0.0);
429 Array<TwoD, NekDouble> factors(m_expDim * m_coordDim, ptsTgt, 0.0);
430
431 // Compute g_{ij} as t_i \cdot t_j and store in tmp
432 for (i = 0, l = 0; i < m_expDim; ++i)
433 {
434 for (j = 0; j < m_expDim; ++j, ++l)
435 {
436 for (k = 0; k < m_coordDim; ++k)
437 {
438 Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1, &deriv[j][k][0], 1,
439 &tmp[l][0], 1, &tmp[l][0], 1);
440 }
441 }
442 }
443
444 Adjoint(tmp, gmat);
445
446 // Compute g = det(g_{ij}) (= Jacobian squared) and store
447 // temporarily in m_jac.
448 for (i = 0; i < m_expDim; ++i)
449 {
450 Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i * m_expDim][0], 1, &jac[0],
451 1, &jac[0], 1);
452 }
453
454 for (i = 0; i < m_expDim * m_expDim; ++i)
455 {
456 Vmath::Vdiv(ptsTgt, &gmat[i][0], 1, &jac[0], 1, &gmat[i][0], 1);
457 }
458
459 // Compute the Jacobian = sqrt(g)
460 Vmath::Vsqrt(ptsTgt, &jac[0], 1, &jac[0], 1);
461
462 // Compute the derivative factors
463 for (k = 0, l = 0; k < m_coordDim; ++k)
464 {
465 for (j = 0; j < m_expDim; ++j, ++l)
466 {
467 for (i = 0; i < m_expDim; ++i)
468 {
469 Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1,
470 &gmat[m_expDim * i + j][0], 1, &factors[l][0], 1,
471 &factors[l][0], 1);
472 }
473 }
474 }
475
476 return factors;
477}
DerivStorage ComputeDeriv(const LibUtilities::PointsKeyVector &keyTgt) const
void Adjoint(const Array< TwoD, const NekDouble > &src, Array< TwoD, NekDouble > &tgt) const
Compute the transpose of the cofactors matrix.
@ eDeformed
Geometry is curved or has non-constant factors.
StdRegions::ConstFactorMap factors
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition Vmath.hpp:340
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.hpp:126

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

Referenced by GetDerivFactors().

◆ 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"] (http://en.wikipedia.org/wiki/Covariance_and_contravariance_of_vectors)
Returns
Two-dimensional array containing the inverse metric tensor of the coordinate mapping.

Definition at line 334 of file GeomFactors.cpp.

336{
337 if (keyTgt.size() != m_expDim)
338 {
340 "Dimension of target point distribution does not match "
341 "expansion dimension.");
342 }
343
344 int i = 0, j = 0, k = 0, l = 0;
345 int ptsTgt = 1;
346
347 if (m_type == eDeformed)
348 {
349 // Allocate storage and compute number of points
350 for (i = 0; i < m_expDim; ++i)
351 {
352 ptsTgt *= keyTgt[i].GetNumPoints();
353 }
354 }
355
356 // Get derivative at geometry points
357 DerivStorage deriv = ComputeDeriv(keyTgt);
358
359 Array<TwoD, NekDouble> tmp(m_expDim * m_expDim, ptsTgt, 0.0);
360 Array<TwoD, NekDouble> gmat(m_expDim * m_expDim, ptsTgt, 0.0);
361 Array<OneD, NekDouble> jac(ptsTgt, 0.0);
362
363 // Compute g_{ij} as t_i \cdot t_j and store in tmp
364 for (i = 0, l = 0; i < m_expDim; ++i)
365 {
366 for (j = 0; j < m_expDim; ++j, ++l)
367 {
368 for (k = 0; k < m_coordDim; ++k)
369 {
370 Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1, &deriv[j][k][0], 1,
371 &tmp[l][0], 1, &tmp[l][0], 1);
372 }
373 }
374 }
375
376 Adjoint(tmp, gmat);
377
378 // Compute g = det(g_{ij}) (= Jacobian squared) and store
379 // temporarily in m_jac.
380 for (i = 0; i < m_expDim; ++i)
381 {
382 Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i * m_expDim][0], 1, &jac[0],
383 1, &jac[0], 1);
384 }
385
386 for (i = 0; i < m_expDim * m_expDim; ++i)
387 {
388 Vmath::Vdiv(ptsTgt, &gmat[i][0], 1, &jac[0], 1, &gmat[i][0], 1);
389 }
390
391 return gmat;
392}

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

Referenced by GetGmat().

◆ ComputeJac()

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

Compute the Jacobian of the mapping.

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 248 of file GeomFactors.cpp.

250{
251 if (keyTgt.size() != m_expDim)
252 {
254 "Dimension of target point distribution does not match "
255 "expansion dimension.");
256 }
257
258 // A point always has a unit jacobian
259 if (m_expDim == 0)
260 {
261 return Array<OneD, NekDouble>(1, 1.0);
262 }
263
264 int i = 0, j = 0, k = 0, l = 0;
265 int ptsTgt = 1;
266
267 if (m_type == eDeformed)
268 {
269 // Allocate storage and compute number of points
270 for (i = 0; i < m_expDim; ++i)
271 {
272 ptsTgt *= keyTgt[i].GetNumPoints();
273 }
274 }
275
276 // Get derivative at geometry points
277 DerivStorage deriv = ComputeDeriv(keyTgt);
278
279 Array<TwoD, NekDouble> tmp(m_expDim * m_expDim, ptsTgt, 0.0);
280 Array<TwoD, NekDouble> gmat(m_expDim * m_expDim, ptsTgt, 0.0);
281 Array<OneD, NekDouble> jac(ptsTgt, 0.0);
282
283 // Compute g_{ij} as t_i \cdot t_j and store in tmp
284 for (i = 0, l = 0; i < m_expDim; ++i)
285 {
286 for (j = 0; j < m_expDim; ++j, ++l)
287 {
288 for (k = 0; k < m_coordDim; ++k)
289 {
290 Vmath::Vvtvp(ptsTgt, &deriv[i][k][0], 1, &deriv[j][k][0], 1,
291 &tmp[l][0], 1, &tmp[l][0], 1);
292 }
293 }
294 }
295
296 Adjoint(tmp, gmat);
297
298 // Compute g = det(g_{ij}) (= Jacobian squared) and store
299 // temporarily in m_jac.
300 for (i = 0; i < m_expDim; ++i)
301 {
302 Vmath::Vvtvp(ptsTgt, &tmp[i][0], 1, &gmat[i * m_expDim][0], 1, &jac[0],
303 1, &jac[0], 1);
304 }
305
306 // Compute the Jacobian = sqrt(g)
307 Vmath::Vsqrt(ptsTgt, &jac[0], 1, &jac[0], 1);
308
309 return jac;
310}

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

Referenced by GetHash(), and GetJac().

◆ 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 479 of file GeomFactors.cpp.

484{
485 if (keyTgt.size() != m_expDim)
486 {
488 "Dimension of target point distribution does not match "
489 "expansion dimension.");
490 }
491
492 int i = 0, k = 0;
493 int ptsTgt = 1;
494 int nq = 1;
495
496 for (i = 0; i < m_expDim; ++i)
497 {
498 nq *= keyTgt[i].GetNumPoints();
499 }
500
501 if (m_type == eDeformed)
502 {
503 // Allocate storage and compute number of points
504 for (i = 0; i < m_expDim; ++i)
505 {
506 ptsTgt *= keyTgt[i].GetNumPoints();
507 }
508 }
509
510 // Get derivative at geometry points
511 DerivStorage deriv = ComputeDeriv(keyTgt);
512
513 // number of moving frames is requited to be 3, even for surfaces
514 int MFdim = 3;
515
516 Array<OneD, Array<OneD, Array<OneD, NekDouble>>> MFtmp(MFdim);
517
518 // Compute g_{ij} as t_i \cdot t_j and store in tmp
519 for (i = 0; i < MFdim; ++i)
520 {
521 MFtmp[i] = Array<OneD, Array<OneD, NekDouble>>(m_coordDim);
522 for (k = 0; k < m_coordDim; ++k)
523 {
524 MFtmp[i][k] = Array<OneD, NekDouble>(nq);
525 }
526 }
527
528 // Compute g_{ij} as t_i \cdot t_j and store in tmp
529 for (i = 0; i < MFdim - 1; ++i)
530 {
531 for (k = 0; k < m_coordDim; ++k)
532 {
533 if (m_type == eDeformed)
534 {
535 Vmath::Vcopy(ptsTgt, &deriv[i][k][0], 1, &MFtmp[i][k][0], 1);
536 }
537 else
538 {
539 Vmath::Fill(nq, deriv[i][k][0], MFtmp[i][k], 1);
540 }
541 }
542 }
543
544 // Direction of MF1 is preserved: MF2 is considered in the same
545 // tangent plane as MF1. MF3 is computed by cross product of MF1
546 // and MF2. MF2 is consequently computed as the cross product of
547 // MF3 and MF1.
548 Array<OneD, Array<OneD, NekDouble>> PrincipleDir(m_coordDim);
549 for (k = 0; k < m_coordDim; k++)
550 {
551 PrincipleDir[k] = Array<OneD, NekDouble>(nq);
552 }
553
554 if (!(MMFdir == eLOCAL))
555 {
556 ComputePrincipleDirection(keyTgt, MMFdir, factors, PrincipleDir);
557 }
558
559 // MF3 = MF1 \times MF2
560 VectorCrossProd(MFtmp[0], MFtmp[1], MFtmp[2]);
561
562 // Normalizing MF3
563 VectorNormalise(MFtmp[2]);
564
565 if (!(MMFdir == eLOCAL))
566 {
567 Array<OneD, NekDouble> temp(nq, 0.0);
568
569 // Reorient MF1 along the PrincipleDir
570 for (i = 0; i < m_coordDim; ++i)
571 {
572 Vmath::Vvtvp(nq, MFtmp[2][i], 1, PrincipleDir[i], 1, temp, 1, temp,
573 1);
574 }
575 Vmath::Neg(nq, temp, 1);
576
577 // u2 = v2 - < u1 , v2 > ( u1 / < u1, u1 > )
578 for (i = 0; i < m_coordDim; ++i)
579 {
580 Vmath::Vvtvp(nq, temp, 1, MFtmp[2][i], 1, PrincipleDir[i], 1,
581 MFtmp[0][i], 1);
582 }
583 }
584
585 // Normalizing MF1
586 VectorNormalise(MFtmp[0]);
587
588 // MF2 = MF3 \times MF1
589 VectorCrossProd(MFtmp[2], MFtmp[0], MFtmp[1]);
590
591 // Normalizing MF2
592 VectorNormalise(MFtmp[1]);
593
594 for (i = 0; i < MFdim; ++i)
595 {
596 for (k = 0; k < m_coordDim; ++k)
597 {
598 Vmath::Vcopy(nq, &MFtmp[i][k][0], 1,
599 &movingframes[i * m_coordDim + k][0], 1);
600 }
601 }
602}
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.
@ eLOCAL
No Principal direction.
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition Vmath.hpp:292

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

Referenced by GetMovingFrames().

◆ 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 757 of file GeomFactors.cpp.

762{
763 int nq = output[0].size();
764
765 output = Array<OneD, Array<OneD, NekDouble>>(m_coordDim);
766 for (int i = 0; i < m_coordDim; ++i)
767 {
768 output[i] = Array<OneD, NekDouble>(nq, 0.0);
769 }
770
771 // Construction of Connection
772 switch (MMFdir)
773 {
774 // projection to x-axis
775 case eTangentX:
776 {
777 Vmath::Fill(nq, 1.0, output[0], 1);
778 break;
779 }
780 case eTangentY:
781 {
782 Vmath::Fill(nq, 1.0, output[1], 1);
783 break;
784 }
785 case eTangentXY:
786 {
787 Vmath::Fill(nq, sqrt(2.0), output[0], 1);
788 Vmath::Fill(nq, sqrt(2.0), output[1], 1);
789 break;
790 }
791 case eTangentZ:
792 {
793 Vmath::Fill(nq, 1.0, output[2], 1);
794 break;
795 }
796 case eTangentCircular:
797 {
798 // Tangent direction depends on spatial location.
799 Array<OneD, Array<OneD, NekDouble>> x(m_coordDim);
800 for (int k = 0; k < m_coordDim; k++)
801 {
802 x[k] = Array<OneD, NekDouble>(nq);
803 }
804
805 // m_coords are StdExpansions which store the mapping
806 // between the std element and the local element. Bwd
807 // transforming the std element minimum basis gives a
808 // minimum physical basis for geometry. Need to then
809 // interpolate this up to the quadrature basis.
810 int nqtot_map = 1;
812 for (int i = 0; i < m_expDim; ++i)
813 {
814 map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
815 nqtot_map *= map_points[i].GetNumPoints();
816 }
817 Array<OneD, NekDouble> tmp(nqtot_map);
818 for (int k = 0; k < m_coordDim; k++)
819 {
820 m_xmap->BwdTrans(m_coords[k], tmp);
821 Interp(map_points, tmp, keyTgt, x[k]);
822 }
823
824 // circular around the center of the domain
825 NekDouble radius, xc = 0.0, yc = 0.0, xdis, ydis;
826 NekDouble la, lb;
827
828 if (factors.size() < 4)
829 {
830 NEKERROR(ErrorUtil::ewarning, "factors is too short.");
831 }
832
833 la = factors[0];
834 lb = factors[1];
835 xc = factors[2];
836 yc = factors[3];
837
838 for (int i = 0; i < nq; i++)
839 {
840 xdis = x[0][i] - xc;
841 ydis = x[1][i] - yc;
842 radius = sqrt(xdis * xdis / la / la + ydis * ydis / lb / lb);
843 output[0][i] = ydis / radius;
844 output[1][i] = -1.0 * xdis / radius;
845 }
846 break;
847 }
849 {
850 // Tangent direction depends on spatial location.
851 Array<OneD, Array<OneD, NekDouble>> x(m_coordDim);
852 for (int k = 0; k < m_coordDim; k++)
853 {
854 x[k] = Array<OneD, NekDouble>(nq);
855 }
856
857 int nqtot_map = 1;
859 for (int i = 0; i < m_expDim; ++i)
860 {
861 map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
862 nqtot_map *= map_points[i].GetNumPoints();
863 }
864 Array<OneD, NekDouble> tmp(nqtot_map);
865 for (int k = 0; k < m_coordDim; k++)
866 {
867 m_xmap->BwdTrans(m_coords[k], tmp);
868 Interp(map_points, tmp, keyTgt, x[k]);
869 }
870
871 // circular around the center of the domain
872 NekDouble xtan, ytan, mag;
873 for (int i = 0; i < nq; i++)
874 {
875 xtan = -1.0 * (x[1][i] * x[1][i] * x[1][i] + x[1][i]);
876 ytan = 2.0 * x[0][i];
877 mag = sqrt(xtan * xtan + ytan * ytan);
878 output[0][i] = xtan / mag;
879 output[1][i] = ytan / mag;
880 }
881 break;
882 }
884 {
885 // Tangent direction depends on spatial location.
886 Array<OneD, Array<OneD, NekDouble>> x(m_coordDim);
887 for (int k = 0; k < m_coordDim; k++)
888 {
889 x[k] = Array<OneD, NekDouble>(nq);
890 }
891
892 int nqtot_map = 1;
894 for (int i = 0; i < m_expDim; ++i)
895 {
896 map_points[i] = m_xmap->GetBasis(i)->GetPointsKey();
897 nqtot_map *= map_points[i].GetNumPoints();
898 }
899 Array<OneD, NekDouble> tmp(nqtot_map);
900 for (int k = 0; k < m_coordDim; k++)
901 {
902 m_xmap->BwdTrans(m_coords[k], tmp);
903 Interp(map_points, tmp, keyTgt, x[k]);
904 }
905
906 // circular around the center of the domain
907 NekDouble xtan, ytan, mag;
908 for (int i = 0; i < nq; i++)
909 {
910 xtan = -2.0 * x[1][i] * x[1][i] * x[1][i] + x[1][i];
911 ytan = sqrt(3.0) * x[0][i];
912 mag = sqrt(xtan * xtan + ytan * ytan);
913 output[0][i] = xtan / mag;
914 output[1][i] = ytan / mag;
915 }
916 break;
917 }
918 default:
919 {
920 break;
921 }
922 }
923}
@ eTangentIrregular
Circular around the centre of domain.
@ eTangentX
X coordinate direction.
@ eTangentCircular
Circular around the centre of domain.
@ eTangentNonconvex
Circular around the centre of domain.
@ eTangentZ
Z coordinate direction.
@ eTangentY
Y coordinate direction.
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290

References Nektar::SpatialDomains::eTangentCircular, Nektar::SpatialDomains::eTangentIrregular, Nektar::SpatialDomains::eTangentNonconvex, Nektar::SpatialDomains::eTangentX, Nektar::SpatialDomains::eTangentXY, Nektar::SpatialDomains::eTangentY, Nektar::SpatialDomains::eTangentZ, Nektar::ErrorUtil::ewarning, Vmath::Fill(), Interp(), m_coordDim, m_coords, m_expDim, m_xmap, NEKERROR, and tinysimd::sqrt().

Referenced by ComputeMovingFrames().

◆ 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 292 of file GeomFactors.h.

293{
294 return m_coordDim;
295}

References m_coordDim.

◆ 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 215 of file GeomFactors.h.

217{
218 return ComputeDeriv(tpoints);
219}

References ComputeDeriv().

Referenced by CheckIfValid(), and Nektar::FieldUtils::ProcessQualityMetric::GetQ().

◆ GetDerivFactors()

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

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

Returns derivative factors.

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

Definition at line 257 of file GeomFactors.h.

258{
260 {
262 m_derivFacComputed = true;
263 }
264 return m_derivFactor;
265}
Array< TwoD, NekDouble > ComputeDerivFactors(const LibUtilities::PointsKeyVector &keyTgt) const
Compute the derivative of the reference coordinates with respect to the mapping, .
bool m_derivFacComputed
Indicates whether stored derivative factors have been populated.

References ComputeDerivFactors(), m_derivFacComputed, m_derivFactor, and m_keyTgt.

Referenced by Nektar::AcousticSystem::v_GetMaxStdVelocity(), and Nektar::CompressibleFlowSystem::v_GetMaxStdVelocity().

◆ 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 244 of file GeomFactors.h.

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

References ComputeGmat().

◆ 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 283 of file GeomFactors.h.

284{
285 return m_type;
286}

References m_type.

Referenced by Nektar::AcousticSystem::v_GetMaxStdVelocity(), Nektar::CompressibleFlowSystem::v_GetMaxStdVelocity(), Nektar::FieldUtils::ProcessJacobianEnergy::v_Process(), and Nektar::FieldUtils::ProcessScalGrad::v_Process().

◆ 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 312 of file GeomFactors.h.

313{
314 LibUtilities::PointsKeyVector ptsKeys = m_xmap->GetPointsKeys();
315 const Array<OneD, const NekDouble> jac = ComputeJac(ptsKeys);
316
317 size_t hash = 0;
319 if (m_type == eDeformed)
320 {
321 hash_range(hash, jac.begin(), jac.end());
322 }
323 else
324 {
325 hash_combine(hash, jac[0]);
326 }
327 return hash;
328}
Array< OneD, NekDouble > ComputeJac(const LibUtilities::PointsKeyVector &keyTgt) const
Compute the Jacobian of the mapping.
std::size_t hash_range(Iter first, Iter last)
Definition HashUtils.hpp:64
void hash_combine(std::size_t &seed)
Definition HashUtils.hpp:44

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

◆ GetJac()

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

Return the Jacobian of the mapping.

Returns Jacobian.

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

Definition at line 228 of file GeomFactors.h.

229{
230 if (!m_jacComputed)
231 {
233 m_jacComputed = true;
234 }
235 return m_jac;
236}
bool m_jacComputed
Indicates whether stored jacobian has been populated.

References ComputeJac(), m_jac, m_jacComputed, and m_keyTgt.

Referenced by Nektar::FieldUtils::ProcessJacobianEnergy::v_Process().

◆ 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 267 of file GeomFactors.h.

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

References ComputeMovingFrames().

◆ GetXmap()

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

Return the Xmap;.

Definition at line 330 of file GeomFactors.h.

331{
332 return m_xmap;
333}

References m_xmap.

◆ 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 673 of file GeomFactors.cpp.

677{
678 if (src_points.size() != tgt_points.size())
679 {
681 "Dimension of target point distribution does not match "
682 "expansion dimension.");
683 }
684
685 switch (m_expDim)
686 {
687 case 1:
688 LibUtilities::Interp1D(src_points[0], src, tgt_points[0], tgt);
689 break;
690 case 2:
691 LibUtilities::Interp2D(src_points[0], src_points[1], src,
692 tgt_points[0], tgt_points[1], tgt);
693 break;
694 case 3:
695 LibUtilities::Interp3D(src_points[0], src_points[1], src_points[2],
696 src, tgt_points[0], tgt_points[1],
697 tgt_points[2], tgt);
698 break;
699 }
700}
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:47
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:162
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:101

References Nektar::ErrorUtil::ewarning, Nektar::LibUtilities::Interp1D(), Nektar::LibUtilities::Interp2D(), Nektar::LibUtilities::Interp3D(), m_expDim, and NEKERROR.

Referenced by ComputeDeriv(), and ComputePrincipleDirection().

◆ 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 302 of file GeomFactors.h.

303{
304 return m_valid;
305}

References m_valid.

Referenced by Nektar::IterativeElasticSystem::v_DoSolve().

◆ 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 970 of file GeomFactors.cpp.

974{
975 if (v1.size() != 3)
976 {
977 NEKERROR(ErrorUtil::efatal, "Input 1 has dimension not equal to 3.");
978 }
979
980 if (v2.size() != 3)
981 {
982 NEKERROR(ErrorUtil::efatal, "Input 2 has dimension not equal to 3.");
983 }
984
985 if (v3.size() != 3)
986 {
988 "Output vector has dimension not equal to 3.");
989 }
990
991 int nq = v1[0].size();
992 Array<OneD, NekDouble> temp(nq);
993
994 Vmath::Vmul(nq, v1[2], 1, v2[1], 1, temp, 1);
995 Vmath::Vvtvm(nq, v1[1], 1, v2[2], 1, temp, 1, v3[0], 1);
996
997 Vmath::Vmul(nq, v1[0], 1, v2[2], 1, temp, 1);
998 Vmath::Vvtvm(nq, v1[2], 1, v2[0], 1, temp, 1, v3[1], 1);
999
1000 Vmath::Vmul(nq, v1[1], 1, v2[0], 1, temp, 1);
1001 Vmath::Vvtvm(nq, v1[0], 1, v2[1], 1, temp, 1, v3[2], 1);
1002}
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.hpp:72
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 minus vector): z = w*x - y
Definition Vmath.hpp:381

References Nektar::ErrorUtil::efatal, NEKERROR, Vmath::Vmul(), and Vmath::Vvtvm().

Referenced by ComputeMovingFrames().

◆ VectorNormalise()

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

Definition at line 928 of file GeomFactors.cpp.

929{
930 int ndim = array.size();
931 if (ndim <= 0)
932 {
933 NEKERROR(ErrorUtil::efatal, "Number of components must be > 0.");
934 }
935 for (int i = 1; i < ndim; ++i)
936 {
937 if (array[i].size() != array[0].size())
938 {
939 NEKERROR(ErrorUtil::efatal, "Array size mismatch in coordinates.");
940 }
941 }
942
943 int nq = array[0].size();
944 Array<OneD, NekDouble> norm(nq, 0.0);
945
946 // Compute the norm of each vector.
947 for (int i = 0; i < ndim; ++i)
948 {
949 Vmath::Vvtvp(nq, array[i], 1, array[i], 1, norm, 1, norm, 1);
950 }
951
952 Vmath::Vsqrt(nq, norm, 1, norm, 1);
953
954 // Normalise the vectors by the norm
955 for (int i = 0; i < ndim; ++i)
956 {
957 Vmath::Vdiv(nq, array[i], 1, norm, 1, array[i], 1);
958 }
959}

References Nektar::ErrorUtil::efatal, NEKERROR, Vmath::Vdiv(), Vmath::Vsqrt(), and Vmath::Vvtvp().

Referenced by ComputeMovingFrames().

Friends And Related Symbol 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 113 of file GeomFactors.cpp.

114{
115 if (!(lhs.m_type == rhs.m_type))
116 {
117 return false;
118 }
119
120 if (!(lhs.m_expDim == rhs.m_expDim))
121 {
122 return false;
123 }
124
125 if (!(lhs.m_coordDim == rhs.m_coordDim))
126 {
127 return false;
128 }
129
130 const Array<OneD, const NekDouble> jac_lhs =
131 lhs.ComputeJac(lhs.m_xmap->GetPointsKeys());
132 const Array<OneD, const NekDouble> jac_rhs =
133 rhs.ComputeJac(rhs.m_xmap->GetPointsKeys());
134 if (!(jac_lhs == jac_rhs))
135 {
136 return false;
137 }
138
139 return true;
140}

Member Data Documentation

◆ m_coordDim

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

◆ m_coords

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

Stores coordinates of the geometry.

Definition at line 146 of file GeomFactors.h.

Referenced by ComputeDeriv(), and ComputePrincipleDirection().

◆ m_derivFacComputed

bool Nektar::SpatialDomains::GeomFactors::m_derivFacComputed = false
protected

Indicates whether stored derivative factors have been populated.

Definition at line 154 of file GeomFactors.h.

Referenced by GetDerivFactors().

◆ m_derivFactor

Array<TwoD, NekDouble> Nektar::SpatialDomains::GeomFactors::m_derivFactor
protected

DerivFactors vector.

Definition at line 150 of file GeomFactors.h.

Referenced by GetDerivFactors().

◆ m_expDim

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

◆ m_jac

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

Jacobian vector.

Definition at line 148 of file GeomFactors.h.

Referenced by GetJac().

◆ m_jacComputed

bool Nektar::SpatialDomains::GeomFactors::m_jacComputed = false
protected

Indicates whether stored jacobian has been populated.

Definition at line 152 of file GeomFactors.h.

Referenced by GetJac().

◆ m_keyTgt

LibUtilities::PointsKeyVector Nektar::SpatialDomains::GeomFactors::m_keyTgt
protected

Default points at which to compute jacobian and derivative factors.

Definition at line 138 of file GeomFactors.h.

Referenced by GetDerivFactors(), and GetJac().

◆ m_MMFDir

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

Principle tangent direction for MMF.

Definition at line 141 of file GeomFactors.h.

◆ m_type

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

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

Definition at line 130 of file GeomFactors.h.

Referenced by CheckIfValid(), ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), GetGtype(), and GetHash().

◆ m_valid

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

Validity of element (Jacobian positive)

Definition at line 136 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 144 of file GeomFactors.h.

Referenced by CheckIfValid(), ComputeDeriv(), ComputePrincipleDirection(), GetHash(), and GetXmap().