Nektar++
|
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 NekDouble > | GetJac (const LibUtilities::PointsKeyVector &keyTgt) |
Return the Jacobian of the mapping and cache the result. More... | |
const Array< TwoD, const NekDouble > | GetGmat (const LibUtilities::PointsKeyVector &keyTgt) |
Return the Laplacian coefficients \(g_{ij}\). More... | |
const Array< TwoD, const NekDouble > | GetDerivFactors (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::StdExpansionSharedPtr & | GetXmap () |
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, NekDouble > | ComputeJac (const LibUtilities::PointsKeyVector &keyTgt) const |
Return the Jacobian of the mapping and cache the result. More... | |
Array< TwoD, NekDouble > | ComputeGmat (const LibUtilities::PointsKeyVector &keyTgt) const |
Computes the Laplacian coefficients \(g_{ij}\). More... | |
Array< TwoD, NekDouble > | ComputeDerivFactors (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... | |
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
Definition at line 71 of file GeomFactors.h.
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.
gtype | Specified whether the geometry is regular or deformed. |
coordim | Specifies the dimension of the coordinate system. |
Coords | Coordinate maps of the element. |
Definition at line 86 of file GeomFactors.cpp.
References CheckIfValid().
Nektar::SpatialDomains::GeomFactors::GeomFactors | ( | const GeomFactors & | S | ) |
Copy constructor.
S | An instance of a GeomFactors class from which to construct a new instance. |
Definition at line 99 of file GeomFactors.cpp.
Nektar::SpatialDomains::GeomFactors::~GeomFactors | ( | ) |
|
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.
src | Input data array. |
tgt | Storage for adjoint matrix data. |
Definition at line 675 of file GeomFactors.cpp.
References ASSERTL1, Nektar::UnitTests::d(), Vmath::Fill(), m_expDim, Vmath::Smul(), Vmath::Vcopy(), and Vmath::Vvtvvtm().
Referenced by ComputeDerivFactors(), ComputeGmat(), and ComputeJac().
|
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 577 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().
|
private |
Derivatives are computed at the geometry point distributions and interpolated to the target point distributions.
tpoints | Target point distributions. |
Definition at line 153 of file GeomFactors.cpp.
References ASSERTL1, Interp(), m_coordDim, m_coords, m_expDim, and m_xmap.
Referenced by ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), and GetDeriv().
|
private |
Return the derivative of the reference coordinates with respect to the mapping, \(\frac{\partial \xi_i}{\partial \chi_j}\).
keyTgt | Target point distributions. |
Definition at line 376 of file GeomFactors.cpp.
References Adjoint(), ASSERTL1, ComputeDeriv(), Nektar::SpatialDomains::eDeformed, Nektar::VarcoeffHashingTest::factors, m_coordDim, m_expDim, m_type, Vmath::Vdiv(), Vmath::Vsqrt(), and Vmath::Vvtvp().
Referenced by GetDerivFactors().
|
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.
Definition at line 312 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().
|
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.
Definition at line 235 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().
|
private |
Definition at line 451 of file GeomFactors.cpp.
References ASSERTL1, ComputeDeriv(), ComputePrincipleDirection(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eLOCAL, Nektar::VarcoeffHashingTest::factors, Vmath::Fill(), m_coordDim, m_expDim, m_type, Vmath::Neg(), Vmath::Vcopy(), VectorCrossProd(), VectorNormalise(), and Vmath::Vvtvp().
Referenced by GetMovingFrames().
|
private |
Definition at line 720 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, Nektar::VarcoeffHashingTest::factors, Vmath::Fill(), Interp(), m_coordDim, m_coords, m_expDim, m_xmap, and tinysimd::sqrt().
Referenced by ComputeMovingFrames().
|
inline |
Return the number of dimensions of the coordinate system.
This is greater than or equal to the expansion dimension.
Definition at line 307 of file GeomFactors.h.
References m_coordDim.
|
inline |
Return the derivative of the mapping with respect to the reference coordinates, \(\frac{\partial \chi_i}{\partial \xi_j}\).
tpoints | Target point distributions. |
Definition at line 216 of file GeomFactors.h.
References ComputeDeriv().
Referenced by CheckIfValid().
|
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.
keyTgt | Target point distributions. |
Definition at line 267 of file GeomFactors.h.
References ComputeDerivFactors(), and m_derivFactorCache.
|
inline |
Return the Laplacian coefficients \(g_{ij}\).
keyTgt | Target point distributions. |
Definition at line 252 of file GeomFactors.h.
References ComputeGmat().
|
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.
Definition at line 298 of file GeomFactors.h.
References m_type.
|
inline |
Computes a hash of this GeomFactors element.
The hash is computed from the geometry type, expansion dimension, coordinate dimension and Jacobian.
Definition at line 327 of file GeomFactors.h.
References Nektar::SpatialDomains::eDeformed, GetJac(), Nektar::hash_combine(), Nektar::hash_range(), m_coordDim, m_expDim, m_type, and m_xmap.
|
inline |
Return the Jacobian of the mapping and cache the result.
Returns cached value if available, otherwise computes Jacobian and stores result in cache.
keyTgt | Target point distributions. |
Definition at line 231 of file GeomFactors.h.
References ComputeJac(), and m_jacCache.
Referenced by GetHash().
|
inline |
Returns moving frames.
Definition at line 282 of file GeomFactors.h.
References ComputeMovingFrames().
|
inlineprotected |
|
private |
Perform interpolation of data between two point distributions.
map_points | Source data point distribution. |
src | Source data to be interpolated. |
tpoints | Target data point distribution. |
tgt | Target data storage. |
Definition at line 642 of file GeomFactors.cpp.
References ASSERTL1, Nektar::LibUtilities::Interp1D(), Nektar::LibUtilities::Interp2D(), Nektar::LibUtilities::Interp3D(), and m_expDim.
Referenced by ComputeDeriv(), and ComputePrincipleDirection().
|
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.
Definition at line 317 of file GeomFactors.h.
References m_valid.
|
private |
Computes the vector cross-product in 3D of v1 and v2, storing the result in v3.
v1 | First input vector. |
v2 | Second input vector. |
v3 | Output vector computed to be orthogonal to both v1 and v2. |
Definition at line 925 of file GeomFactors.cpp.
References ASSERTL0, Vmath::Vmul(), and Vmath::Vvtvm().
Referenced by ComputeMovingFrames().
|
private |
Definition at line 888 of file GeomFactors.cpp.
References ASSERTL0, Vmath::Vdiv(), Vmath::Vsqrt(), and Vmath::Vvtvp().
Referenced by ComputeMovingFrames().
|
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 116 of file GeomFactors.cpp.
|
protected |
Dimension of coordinate system.
Definition at line 131 of file GeomFactors.h.
Referenced by CheckIfValid(), ComputeDeriv(), ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), ComputePrincipleDirection(), GetCoordim(), and GetHash().
Stores coordinates of the geometry.
Definition at line 141 of file GeomFactors.h.
Referenced by ComputeDeriv(), and ComputePrincipleDirection().
|
protected |
DerivFactors vector cache.
Definition at line 146 of file GeomFactors.h.
Referenced by GetDerivFactors().
|
protected |
Dimension of expansion.
Definition at line 129 of file GeomFactors.h.
Referenced by Adjoint(), CheckIfValid(), ComputeDeriv(), ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), ComputePrincipleDirection(), GetHash(), and Interp().
|
protected |
|
protected |
Principle tangent direction for MMF.
Definition at line 136 of file GeomFactors.h.
|
protected |
Type of geometry (e.g. eRegular, eDeformed, eMovingRegular).
Definition at line 127 of file GeomFactors.h.
Referenced by CheckIfValid(), ComputeDerivFactors(), ComputeGmat(), ComputeJac(), ComputeMovingFrames(), GetGtype(), and GetHash().
|
protected |
Validity of element (Jacobian positive)
Definition at line 133 of file GeomFactors.h.
Referenced by CheckIfValid(), and IsValid().
|
protected |
Stores information about the expansion.
Definition at line 139 of file GeomFactors.h.
Referenced by CheckIfValid(), ComputeDeriv(), ComputePrincipleDirection(), GetHash(), and GetXmap().