Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::SpatialDomains::QuadGeom Class Reference

#include <QuadGeom.h>

Inheritance diagram for Nektar::SpatialDomains::QuadGeom:
[legend]

Public Member Functions

 QuadGeom ()
 
 QuadGeom (const QuadGeom &in)
 
 QuadGeom (const int id, std::array< SegGeom *, kNverts > edges, Curve *curve=nullptr)
 
 ~QuadGeom () override=default
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry2D
 Geometry2D ()
 
 Geometry2D (const int coordim, Curve *curve)
 
 ~Geometry2D () override=default
 
CurveGetCurve ()
 
void SetCurve (Curve *curvePtr)
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry
 Geometry ()
 Default constructor.
 
 Geometry (int coordim)
 Constructor when supplied a coordinate dimension.
 
virtual ~Geometry ()=default
 
int GetCoordim () const
 Return the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded).
 
void SetCoordim (int coordim)
 Sets the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded).
 
GeomFactorsUniquePtr GenGeomFactors (LibUtilities::PointsKeyVector &keyTgt)
 Used by Expansion to generate associated GeomFactors.
 
LibUtilities::ShapeType GetShapeType (void)
 Get the geometric shape type of this object.
 
int GetGlobalID (void) const
 Get the ID of this object.
 
void SetGlobalID (int globalid)
 Set the ID of this object.
 
int GetVid (int i) const
 Returns global id of vertex i of this object.
 
int GetEid (int i) const
 Get the ID of edge i of this object.
 
int GetFid (int i) const
 Get the ID of face i of this object.
 
int GetTid (int i) const
 Get the ID of trace i of this object.
 
PointGeomGetVertex (int i) const
 Returns vertex i of this object.
 
Geometry1DGetEdge (int i) const
 Returns edge i of this object.
 
Geometry2DGetFace (int i) const
 Returns face i of this object.
 
StdRegions::Orientation GetEorient (const int i) const
 Returns the orientation of edge i with respect to the ordering of edges in the standard element.
 
StdRegions::Orientation GetForient (const int i) const
 Returns the orientation of face i with respect to the ordering of faces in the standard element.
 
int GetNumVerts () const
 Get the number of vertices of this object.
 
int GetNumEdges () const
 Get the number of edges of this object.
 
int GetNumFaces () const
 Get the number of faces of this object.
 
int GetShapeDim () const
 Get the object's shape dimension.
 
StdRegions::StdExpansionSharedPtr GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element.
 
const Array< OneD, const NekDouble > & GetCoeffs (const int i) const
 Return the coefficients of the transformation Geometry::m_xmap in coordinate direction i.
 
void FillGeom ()
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
 
std::array< NekDouble, 6 > GetBoundingBox ()
 Generates the bounding box for the element.
 
void ClearBoundingBox ()
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\).
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\).
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\).
 
NekDouble GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
 Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this geometry object.
 
NekDouble GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord)
 Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i.
 
int PreliminaryCheck (const Array< OneD, const NekDouble > &gloCoord)
 A fast and robust check if a given global coord is outside of a deformed element. For regular elements, this check is unnecessary.
 
bool MinMaxCheck (const Array< OneD, const NekDouble > &gloCoord)
 Check if given global coord is within the BoundingBox of the element.
 
bool ClampLocCoords (Array< OneD, NekDouble > &locCoord, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
 Clamp local coords to be within standard regions [-1, 1]^dim.
 
NekDouble FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
 
int GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex.
 
int GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex.
 
int GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face.
 
int GetEdgeNormalToFaceVert (int i, int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex.
 
int GetDir (const int i, const int j=0) const
 Returns the element coordinate direction corresponding to a given face coordinate direction.
 
GeomType CalcGeomType ()
 
void Reset (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void ResetNonRecursive (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object non-recursively: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void Setup ()
 

Static Public Member Functions

static StdRegions::Orientation GetFaceOrientation (const QuadGeom &face1, const QuadGeom &face2, bool doRot=false, int dir=0, NekDouble angle=0.0, NekDouble tol=1e-8)
 Get the orientation of face1.
 
static StdRegions::Orientation GetFaceOrientation (std::array< PointGeom *, 4 > face1, std::array< PointGeom *, 4 > face2, bool doRot=false, int dir=0, NekDouble angle=0.0, NekDouble tol=1e-8)
 

Static Public Attributes

static const int kNedges = 4
 
static const int kNverts = 4
 
static const int kNfacets = kNedges
 
static const std::string XMLElementType
 
- Static Public Attributes inherited from Nektar::SpatialDomains::Geometry2D
static const int kDim = 2
 

Protected Member Functions

NekDouble v_GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord) override
 Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i.
 
GeomType v_CalcGeomType () override
 
GeomFactorsUniquePtr v_GenGeomFactors (LibUtilities::PointsKeyVector &keyTgt) override
 Used by Expansion to generate associated GeomFactors.
 
void v_FillGeom () override
 
int v_GetDir (const int faceidx, const int facedir) const override
 Returns the element coordinate direction corresponding to a given face coordinate direction.
 
void v_Reset (CurveMap &curvedEdges, CurveMap &curvedFaces) override
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void v_Setup () override
 
void PreSolveStraightEdge ()
 
int v_AllLeftCheck (const Array< OneD, const NekDouble > &gloCoord) override
 
int v_GetNumVerts () const final
 Get the number of vertices of this object.
 
int v_GetNumEdges () const final
 Get the number of edges of this object.
 
PointGeomv_GetVertex (const int i) const final
 Returns vertex i of this object.
 
Geometry1Dv_GetEdge (const int i) const final
 Returns edge i of this object.
 
StdRegions::Orientation v_GetEorient (const int i) const final
 Returns the orientation of edge i with respect to the ordering of edges in the standard element.
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry2D
NekDouble v_GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
 Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this geometry object.
 
void NewtonIterationForLocCoord (const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &dist)
 
void SolveStraightEdgeQuad (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
 
void v_CalculateInverseIsoParam () override
 
int v_GetShapeDim () const override
 Get the object's shape dimension.
 
NekDouble v_FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) override
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
virtual int v_GetVid (int i) const
 Get the ID of vertex i of this object.
 
virtual Geometry2Dv_GetFace (const int i) const
 Returns face i of this object.
 
virtual StdRegions::Orientation v_GetForient (const int i) const
 Returns the orientation of face i with respect to the ordering of faces in the standard element.
 
virtual int v_GetNumFaces () const
 Get the number of faces of this object.
 
virtual StdRegions::StdExpansionSharedPtr v_GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element.
 
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\).
 
virtual int v_GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex.
 
virtual int v_GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex.
 
virtual int v_GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face.
 
virtual int v_GetEdgeNormalToFaceVert (const int i, const int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex.
 
void SetUpCoeffs (const int nCoeffs)
 Initialise the Geometry::m_coeffs array.
 

Protected Attributes

std::array< PointGeom *, kNvertsm_verts
 
std::array< SegGeom *, kNedgesm_edges
 
std::array< StdRegions::Orientation, kNedgesm_eorient
 
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry2D
Curvem_curve
 
Array< OneD, int > m_manifold
 
Array< OneD, Array< OneD, NekDouble > > m_edgeNormal
 
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry
int m_coordim
 Coordinate dimension of this geometry object.
 
StdRegions::StdExpansionSharedPtr m_xmap
 \(\chi\) mapping containing isoparametric transformation.
 
GeomState m_state
 Enumeration to dictate whether coefficients are filled.
 
bool m_setupState
 Wether or not the setup routines have been run.
 
LibUtilities::ShapeType m_shapeType
 Type of shape.
 
int m_globalID
 Global ID.
 
std::vector< Array< OneD, NekDouble > > m_coeffs
 Array containing expansion coefficients of m_xmap.
 
Array< OneD, NekDoublem_boundingBox
 Array containing bounding box.
 
Array< OneD, Array< OneD, NekDouble > > m_isoParameter
 
Array< OneD, Array< OneD, NekDouble > > m_invIsoParam
 
int m_straightEdge
 

Private Member Functions

void SetUpXmap ()
 

Detailed Description

Definition at line 52 of file QuadGeom.h.

Constructor & Destructor Documentation

◆ QuadGeom() [1/3]

Nektar::SpatialDomains::QuadGeom::QuadGeom ( )

◆ QuadGeom() [2/3]

Nektar::SpatialDomains::QuadGeom::QuadGeom ( const QuadGeom in)

Definition at line 93 of file QuadGeom.cpp.

93 : Geometry2D(in)
94{
95 // From Geometry
96 m_shapeType = in.m_shapeType;
97 m_globalID = in.m_globalID;
98
99 // From QuadGeom
100 m_verts = in.m_verts;
101 m_edges = in.m_edges;
102 for (int i = 0; i < kNedges; i++)
103 {
104 m_eorient[i] = in.m_eorient[i];
105 }
106}
std::array< PointGeom *, kNverts > m_verts
Definition QuadGeom.h:120
std::array< StdRegions::Orientation, kNedges > m_eorient
Definition QuadGeom.h:122
std::array< SegGeom *, kNedges > m_edges
Definition QuadGeom.h:121

References kNedges, m_edges, m_eorient, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_shapeType, and m_verts.

◆ QuadGeom() [3/3]

Nektar::SpatialDomains::QuadGeom::QuadGeom ( const int  id,
std::array< SegGeom *, kNverts edges,
Curve curve = nullptr 
)

◆ ~QuadGeom()

Nektar::SpatialDomains::QuadGeom::~QuadGeom ( )
overridedefault

Member Function Documentation

◆ GetFaceOrientation() [1/2]

StdRegions::Orientation Nektar::SpatialDomains::QuadGeom::GetFaceOrientation ( const QuadGeom face1,
const QuadGeom face2,
bool  doRot = false,
int  dir = 0,
NekDouble  angle = 0.0,
NekDouble  tol = 1e-8 
)
static

Get the orientation of face1.

Definition at line 228 of file QuadGeom.cpp.

233{
234 return GetFaceOrientation(face1.m_verts, face2.m_verts, doRot, dir, angle,
235 tol);
236}
static StdRegions::Orientation GetFaceOrientation(const QuadGeom &face1, const QuadGeom &face2, bool doRot=false, int dir=0, NekDouble angle=0.0, NekDouble tol=1e-8)
Get the orientation of face1.
Definition QuadGeom.cpp:228

References GetFaceOrientation(), and m_verts.

Referenced by Nektar::MultiRegions::DisContField::FindPeriodicTraces(), and GetFaceOrientation().

◆ GetFaceOrientation() [2/2]

StdRegions::Orientation Nektar::SpatialDomains::QuadGeom::GetFaceOrientation ( std::array< PointGeom *, 4 >  face1,
std::array< PointGeom *, 4 >  face2,
bool  doRot = false,
int  dir = 0,
NekDouble  angle = 0.0,
NekDouble  tol = 1e-8 
)
static

Calculate the orientation of face2 to face1 (note this is not face1 to face2!).

Definition at line 242 of file QuadGeom.cpp.

245{
246 int i, j, vmap[4] = {-1, -1, -1, -1};
247
248 if (doRot)
249 {
250 PointGeom rotPt;
251
252 for (i = 0; i < 4; ++i)
253 {
254 rotPt.Rotate((*face1[i]), dir, angle);
255 for (j = 0; j < 4; ++j)
256 {
257 if (rotPt.dist(*face2[j]) < tol)
258 {
259 vmap[j] = i;
260 break;
261 }
262 }
263 }
264 }
265 else
266 {
267
268 NekDouble x, y, z, x1, y1, z1, cx = 0.0, cy = 0.0, cz = 0.0;
269
270 // For periodic faces, we calculate the vector between the centre
271 // points of the two faces. (For connected faces this will be
272 // zero). We can then use this to determine alignment later in the
273 // algorithm.
274 for (i = 0; i < 4; ++i)
275 {
276 cx += (*face2[i])(0) - (*face1[i])(0);
277 cy += (*face2[i])(1) - (*face1[i])(1);
278 cz += (*face2[i])(2) - (*face1[i])(2);
279 }
280 cx /= 4;
281 cy /= 4;
282 cz /= 4;
283
284 // Now construct a mapping which takes us from the vertices of one
285 // face to the other. That is, vertex j of face2 corresponds to
286 // vertex vmap[j] of face1.
287 for (i = 0; i < 4; ++i)
288 {
289 x = (*face1[i])(0);
290 y = (*face1[i])(1);
291 z = (*face1[i])(2);
292 for (j = 0; j < 4; ++j)
293 {
294 x1 = (*face2[j])(0) - cx;
295 y1 = (*face2[j])(1) - cy;
296 z1 = (*face2[j])(2) - cz;
297 if (sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) +
298 (z1 - z) * (z1 - z)) < 1e-8)
299 {
300 vmap[j] = i;
301 break;
302 }
303 }
304 }
305 }
306
307 // Use the mapping to determine the eight alignment options between
308 // faces.
309 if (vmap[1] == (vmap[0] + 1) % 4)
310 {
311 switch (vmap[0])
312 {
313 case 0:
315 break;
316 case 1:
318 break;
319 case 2:
321 break;
322 case 3:
324 break;
325 }
326 }
327 else
328 {
329 switch (vmap[0])
330 {
331 case 0:
333 break;
334 case 1:
336 break;
337 case 2:
339 break;
340 case 3:
342 break;
343 }
344 }
345 NEKERROR(ErrorUtil::efatal, "unable to determine face orientation");
347}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
std::vector< double > z(NPUPPER)
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290

References Nektar::SpatialDomains::PointGeom::dist(), Nektar::StdRegions::eDir1BwdDir1_Dir2BwdDir2, Nektar::StdRegions::eDir1BwdDir1_Dir2FwdDir2, Nektar::StdRegions::eDir1BwdDir2_Dir2BwdDir1, Nektar::StdRegions::eDir1BwdDir2_Dir2FwdDir1, Nektar::StdRegions::eDir1FwdDir1_Dir2BwdDir2, Nektar::StdRegions::eDir1FwdDir1_Dir2FwdDir2, Nektar::StdRegions::eDir1FwdDir2_Dir2BwdDir1, Nektar::StdRegions::eDir1FwdDir2_Dir2FwdDir1, Nektar::ErrorUtil::efatal, NEKERROR, Nektar::SpatialDomains::PointGeom::Rotate(), and tinysimd::sqrt().

◆ PreSolveStraightEdge()

void Nektar::SpatialDomains::QuadGeom::PreSolveStraightEdge ( )
protected

Definition at line 556 of file QuadGeom.cpp.

557{
558 int i0, i1, j1, j2;
559 if (fabs(m_isoParameter[0][3]) >= fabs(m_isoParameter[1][3]))
560 {
561 i0 = 0;
562 i1 = 1;
563 }
564 else
565 {
566 i1 = 0;
567 i0 = 1;
568 m_straightEdge |= 2;
569 }
570 NekDouble gamma = m_isoParameter[i1][3] / m_isoParameter[i0][3];
571 std::vector<NekDouble> c(3);
572 for (int i = 0; i < 3; ++i)
573 {
574 c[i] = m_isoParameter[i1][i] - gamma * m_isoParameter[i0][i];
575 }
576 if (fabs(c[1]) >= fabs(c[2]))
577 {
578 j1 = 1;
579 j2 = 2;
580 }
581 else
582 {
583 j1 = 2;
584 j2 = 1;
585 m_straightEdge |= 4;
586 }
587 NekDouble beta = c[j2] / c[j1];
588 if (i0 == 1)
589 {
591 }
592 if (j1 == 2)
593 {
594 NekDouble temp = m_isoParameter[0][j1];
595 m_isoParameter[0][j1] = m_isoParameter[0][j2];
596 m_isoParameter[0][j2] = temp;
597 }
598 m_isoParameter[0][2] -= m_isoParameter[0][1] * beta;
599 m_isoParameter[1][0] = c[0];
600 m_isoParameter[1][1] = 1. / c[j1];
601 m_isoParameter[1][2] = beta;
602 m_isoParameter[1][3] = gamma;
603}
Array< OneD, Array< OneD, NekDouble > > m_isoParameter
Definition Geometry.h:199
@ beta
Gauss Radau pinned at x=-1,.
Definition PointsType.h:59
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References Nektar::LibUtilities::beta, Nektar::SpatialDomains::Geometry::m_isoParameter, Nektar::SpatialDomains::Geometry::m_straightEdge, and Vmath::Vcopy().

Referenced by v_CalcGeomType().

◆ SetUpXmap()

void Nektar::SpatialDomains::QuadGeom::SetUpXmap ( )
private

Definition at line 194 of file QuadGeom.cpp.

195{
196 int order0 = std::max(m_edges[0]->GetXmap()->GetBasis(0)->GetNumModes(),
197 m_edges[2]->GetXmap()->GetBasis(0)->GetNumModes());
198 int order1 = std::max(m_edges[1]->GetXmap()->GetBasis(0)->GetNumModes(),
199 m_edges[3]->GetXmap()->GetBasis(0)->GetNumModes());
200
201 std::array<LibUtilities::BasisKey, 2> basis = {
202 LibUtilities::BasisKey(
204 LibUtilities::PointsKey(order0 + 1,
206 LibUtilities::BasisKey(
208 LibUtilities::PointsKey(order1 + 1,
210
211 m_xmap = GetStdQuadFactory().CreateInstance(basis);
212}
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition Geometry.h:186
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
Definition Geometry.h:440
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
XmapFactory< StdRegions::StdQuadExp, 2 > & GetStdQuadFactory()
Definition QuadGeom.cpp:48

References Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::SpatialDomains::GetStdQuadFactory(), Nektar::SpatialDomains::Geometry::GetXmap(), m_edges, and Nektar::SpatialDomains::Geometry::m_xmap.

Referenced by v_Reset(), and v_Setup().

◆ v_AllLeftCheck()

int Nektar::SpatialDomains::QuadGeom::v_AllLeftCheck ( const Array< OneD, const NekDouble > &  gloCoord)
overrideprotectedvirtual

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 108 of file QuadGeom.cpp.

109{
110 int nc = 1, d0 = m_manifold[0], d1 = m_manifold[1];
111 if (0 == m_edgeNormal.size())
112 {
113 m_edgeNormal = Array<OneD, Array<OneD, NekDouble>>(m_verts.size());
114 Array<OneD, Array<OneD, NekDouble>> x(2);
115 x[0] = Array<OneD, NekDouble>(3);
116 x[1] = Array<OneD, NekDouble>(3);
117 m_verts[0]->GetCoords(x[0]);
118 int i0 = 1, i1 = 0, direction = 1;
119 for (size_t i = 0; i < m_verts.size(); ++i)
120 {
121 i0 ^= 1;
122 i1 ^= 1;
123 m_verts[(i + 1) % m_verts.size()]->GetCoords(x[i1]);
124 if (m_edges[i]->GetXmap()->GetBasis(0)->GetNumModes() > 2)
125 {
126 continue;
127 }
128 m_edgeNormal[i] = Array<OneD, NekDouble>(2);
129 m_edgeNormal[i][0] = x[i0][d1] - x[i1][d1];
130 m_edgeNormal[i][1] = x[i1][d0] - x[i0][d0];
131 }
132 if (m_coordim == 3)
133 {
134 for (size_t i = 0; i < m_verts.size(); ++i)
135 {
136 if (m_edgeNormal[i].size() == 2)
137 {
138 m_verts[i]->GetCoords(x[0]);
139 m_verts[(i + 2) % m_verts.size()]->GetCoords(x[1]);
140 if (m_edgeNormal[i][0] * (x[1][d0] - x[0][d0]) <
141 m_edgeNormal[i][1] * (x[0][d1] - x[1][d1]))
142 {
143 direction = -1;
144 }
145 break;
146 }
147 }
148 }
149 if (direction == -1)
150 {
151 for (size_t i = 0; i < m_verts.size(); ++i)
152 {
153 if (m_edgeNormal[i].size() == 2)
154 {
155 m_edgeNormal[i][0] = -m_edgeNormal[i][0];
156 m_edgeNormal[i][1] = -m_edgeNormal[i][1];
157 }
158 }
159 }
160 }
161
162 Array<OneD, NekDouble> vertex(3);
163 for (size_t i = 0; i < m_verts.size(); ++i)
164 {
165 int i1 = (i + 1) % m_verts.size();
166 if (m_verts[i]->GetGlobalID() < m_verts[i1]->GetGlobalID())
167 {
168 m_verts[i]->GetCoords(vertex);
169 }
170 else
171 {
172 m_verts[i1]->GetCoords(vertex);
173 }
174 if (m_edgeNormal[i].size() == 0)
175 {
176 nc = 0; // not sure
177 continue;
178 }
179 if (m_edgeNormal[i][0] * (gloCoord[d0] - vertex[d0]) <
180 m_edgeNormal[i][1] * (vertex[d1] - gloCoord[d1]))
181 {
182 return -1; // outside
183 }
184 }
185 // 3D manifold needs to check the distance
186 if (m_coordim == 3)
187 {
188 nc = 0;
189 }
190 // nc: 1 (side element), 0 (maybe inside), -1 (outside)
191 return nc;
192}
Array< OneD, Array< OneD, NekDouble > > m_edgeNormal
Definition Geometry2D.h:69
int GetGlobalID(void) const
Get the ID of this object.
Definition Geometry.h:314
int m_coordim
Coordinate dimension of this geometry object.
Definition Geometry.h:184

References Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry2D::m_edgeNormal, m_edges, Nektar::SpatialDomains::Geometry2D::m_manifold, and m_verts.

◆ v_CalcGeomType()

GeomType Nektar::SpatialDomains::QuadGeom::v_CalcGeomType ( )
overrideprotectedvirtual

Set up GeoFac for this geometry using Coord quadrature distribution

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 352 of file QuadGeom.cpp.

353{
354 if (!m_setupState)
355 {
357 }
359
360 GeomType Gtype = eRegular;
361
362 // We will first check whether we have a regular or deformed
363 // geometry. We will define regular as those cases where the
364 // Jacobian and the metric terms of the derivative are constants
365 // (i.e. not coordinate dependent)
366
367 // Check to see if expansions are linear
368 // If not linear => deformed geometry
369 if ((m_xmap->GetBasisNumModes(0) != 2) ||
370 (m_xmap->GetBasisNumModes(1) != 2))
371 {
372 Gtype = eDeformed;
373 }
374
375 // For linear expansions, the mapping from standard to local
376 // element is given by the relation:
377 // x_i = 0.25 * [ ( x_i^A + x_i^B + x_i^C + x_i^D) +
378 // (-x_i^A + x_i^B + x_i^C - x_i^D)*xi_1 +
379 // (-x_i^A - x_i^B + x_i^C + x_i^D)*xi_2 +
380 // ( x_i^A - x_i^B + x_i^C - x_i^D)*xi_1*xi_2 ]
381 //
382 // The jacobian of the transformation and the metric terms
383 // dxi_i/dx_j, involve only terms of the form dx_i/dxi_j (both
384 // for coordim == 2 or 3). Inspecting the formula above, it can
385 // be appreciated that the derivatives dx_i/dxi_j will be
386 // constant, if the coefficient of the non-linear term is zero.
387 //
388 // That is why for regular geometry, we require
389 //
390 // x_i^A - x_i^B + x_i^C - x_i^D = 0
391 //
392 // or equivalently
393 //
394 // x_i^A - x_i^B = x_i^D - x_i^C
395 //
396 // This corresponds to quadrilaterals which are paralellograms.
397 m_manifold = Array<OneD, int>(m_coordim);
398 m_manifold[0] = 0;
399 m_manifold[1] = 1;
400 if (m_coordim == 3)
401 {
402 PointGeom e01, e21, norm;
403 e01.Sub(*m_verts[0], *m_verts[1]);
404 e21.Sub(*m_verts[3], *m_verts[1]);
405 norm.Mult(e01, e21);
406 int tmpi = 0;
407 double tmp = std::fabs(norm[0]);
408 if (tmp < fabs(norm[1]))
409 {
410 tmp = fabs(norm[1]);
411 tmpi = 1;
412 }
413 if (tmp < fabs(norm[2]))
414 {
415 tmpi = 2;
416 }
417 m_manifold[0] = (tmpi + 1) % 3;
418 m_manifold[1] = (tmpi + 2) % 3;
419 m_manifold[2] = (tmpi + 3) % 3;
420 }
421
422 if (Gtype == eRegular)
423 {
424 Array<OneD, Array<OneD, NekDouble>> verts(m_verts.size());
425 for (int i = 0; i < m_verts.size(); ++i)
426 {
427 verts[i] = Array<OneD, NekDouble>(3);
428 m_verts[i]->GetCoords(verts[i]);
429 }
430 // a00 + a01 xi1 + a02 xi2 + a03 xi1 xi2
431 // a10 + a11 xi1 + a12 xi2 + a03 xi1 xi2
432 m_isoParameter = Array<OneD, Array<OneD, NekDouble>>(2);
433 for (int i = 0; i < 2; i++)
434 {
435 unsigned int d = m_manifold[i];
436 m_isoParameter[i] = Array<OneD, NekDouble>(4, 0.);
437 // Karniadakis, Sherwin 2005, Appendix D
438 NekDouble A = verts[0][d];
439 NekDouble B = verts[1][d];
440 NekDouble D = verts[2][d];
441 NekDouble C = verts[3][d];
442 m_isoParameter[i][0] = 0.25 * (A + B + C + D); // 1
443 m_isoParameter[i][1] = 0.25 * (-A + B - C + D); // xi1
444 m_isoParameter[i][2] = 0.25 * (-A - B + C + D); // xi2
445 m_isoParameter[i][3] = 0.25 * (A - B - C + D); // xi1*xi2
446 NekDouble tmp =
447 fabs(m_isoParameter[i][1]) + fabs(m_isoParameter[i][2]);
448 if (fabs(m_isoParameter[i][3]) > tmp * NekConstants::kNekZeroTol)
449 {
450 Gtype = eDeformed;
451 }
452 }
453 }
454
455 if (Gtype == eRegular)
456 {
458 }
459 else if (m_straightEdge)
460 {
462 }
463
464 return Gtype;
465}
bool m_setupState
Wether or not the setup routines have been run.
Definition Geometry.h:190
static const NekDouble kNekZeroTol
GeomType
Indicates the type of element geometry.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eDeformed
Geometry is curved or has non-constant factors.
std::vector< double > d(NPUPPER *NPUPPER)

References Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eRegular, Nektar::NekConstants::kNekZeroTol, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry::m_isoParameter, Nektar::SpatialDomains::Geometry2D::m_manifold, Nektar::SpatialDomains::Geometry::m_setupState, Nektar::SpatialDomains::Geometry::m_straightEdge, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, Nektar::SpatialDomains::PointGeom::Mult(), PreSolveStraightEdge(), Nektar::SpatialDomains::PointGeom::Sub(), Nektar::SpatialDomains::Geometry2D::v_CalculateInverseIsoParam(), v_FillGeom(), and v_Setup().

◆ v_FillGeom()

void Nektar::SpatialDomains::QuadGeom::v_FillGeom ( )
overrideprotectedvirtual

Note verts and edges are listed according to anticlockwise convention but points in _coeffs have to be in array format from left to right.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 481 of file QuadGeom.cpp.

482{
483 // check to see if geometry structure is already filled
484 if (m_state != ePtsFilled)
485 {
486 int i, j, k;
487 int nEdgeCoeffs;
488
489 if (m_curve)
490 {
491 int npts = m_curve->m_points.size();
492 int nEdgePts = (int)sqrt(static_cast<NekDouble>(npts));
493 Array<OneD, NekDouble> tmp(npts);
494 Array<OneD, NekDouble> tmp2(m_xmap->GetTotPoints());
495 LibUtilities::PointsKey curveKey(nEdgePts, m_curve->m_ptype);
496
497 // Sanity checks:
498 // - Curved faces should have square number of points;
499 // - Each edge should have sqrt(npts) points.
500 ASSERTL0(nEdgePts * nEdgePts == npts,
501 "NUMPOINTS should be a square number in"
502 " quadrilteral " +
503 std::to_string(m_globalID));
504
505 for (i = 0; i < kNedges; ++i)
506 {
507 ASSERTL0(m_edges[i]->GetXmap()->GetNcoeffs() == nEdgePts,
508 "Number of edge points does not correspond to "
509 "number of face points in quadrilateral " +
510 std::to_string(m_globalID));
511 }
512
513 for (i = 0; i < m_coordim; ++i)
514 {
515 for (j = 0; j < npts; ++j)
516 {
517 tmp[j] = (m_curve->m_points[j]->GetPtr())[i];
518 }
519
520 // Interpolate m_curve points to GLL points
521 LibUtilities::Interp2D(curveKey, curveKey, tmp,
522 m_xmap->GetBasis(0)->GetPointsKey(),
523 m_xmap->GetBasis(1)->GetPointsKey(),
524 tmp2);
525
526 // Forwards transform to get coefficient space.
527 m_xmap->FwdTrans(tmp2, m_coeffs[i]);
528 }
529 }
530
531 // Now fill in edges.
532 Array<OneD, unsigned int> mapArray;
533 Array<OneD, int> signArray;
534
535 for (i = 0; i < kNedges; i++)
536 {
537 m_edges[i]->FillGeom();
538 m_xmap->GetTraceToElementMap(i, mapArray, signArray, m_eorient[i]);
539
540 nEdgeCoeffs = m_edges[i]->GetXmap()->GetNcoeffs();
541
542 for (j = 0; j < m_coordim; j++)
543 {
544 for (k = 0; k < nEdgeCoeffs; k++)
545 {
546 m_coeffs[j][mapArray[k]] =
547 signArray[k] * (m_edges[i]->GetCoeffs(j))[k];
548 }
549 }
550 }
551
553 }
554}
#define ASSERTL0(condition, msg)
GeomState m_state
Enumeration to dictate whether coefficients are filled.
Definition Geometry.h:188
std::vector< Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition Geometry.h:196
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
@ ePtsFilled
Geometric information has been generated.
LibUtilities::PointsType m_ptype
Points distribution of this curve.
Definition Curve.hpp:57
std::vector< PointGeom * > m_points
Points along the curve.
Definition Curve.hpp:53

References ASSERTL0, Nektar::SpatialDomains::ePtsFilled, Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::LibUtilities::Interp2D(), kNedges, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry2D::m_curve, m_edges, m_eorient, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Curve::m_points, Nektar::SpatialDomains::Curve::m_ptype, Nektar::SpatialDomains::Geometry::m_state, Nektar::SpatialDomains::Geometry::m_xmap, and tinysimd::sqrt().

Referenced by v_CalcGeomType().

◆ v_GenGeomFactors()

GeomFactorsUniquePtr Nektar::SpatialDomains::QuadGeom::v_GenGeomFactors ( LibUtilities::PointsKeyVector keyTgt)
overrideprotectedvirtual

◆ v_GetCoord()

NekDouble Nektar::SpatialDomains::QuadGeom::v_GetCoord ( const int  i,
const Array< OneD, const NekDouble > &  Lcoord 
)
overrideprotectedvirtual

Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 214 of file QuadGeom.cpp.

216{
217 if (m_state != ePtsFilled)
218 {
219 NEKERROR(ErrorUtil::efatal, "Geometry is not in physical space");
220 }
221
222 Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
223 m_xmap->BwdTrans(m_coeffs[i], tmp);
224
225 return m_xmap->PhysEvaluate(Lcoord, tmp);
226}

References Nektar::ErrorUtil::efatal, Nektar::SpatialDomains::ePtsFilled, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_state, Nektar::SpatialDomains::Geometry::m_xmap, and NEKERROR.

◆ v_GetDir()

int Nektar::SpatialDomains::QuadGeom::v_GetDir ( const int  i,
const int  j 
) const
overrideprotectedvirtual

Returns the element coordinate direction corresponding to a given face coordinate direction.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 605 of file QuadGeom.cpp.

606{
607 return i % 2;
608}

◆ v_GetEdge()

Geometry1D * Nektar::SpatialDomains::QuadGeom::v_GetEdge ( const int  i) const
inlinefinalprotectedvirtual

Returns edge i of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 110 of file QuadGeom.h.

111 {
112 return static_cast<Geometry1D *>(m_edges[i]);
113 }

References m_edges.

◆ v_GetEorient()

StdRegions::Orientation Nektar::SpatialDomains::QuadGeom::v_GetEorient ( const int  i) const
inlinefinalprotectedvirtual

Returns the orientation of edge i with respect to the ordering of edges in the standard element.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 115 of file QuadGeom.h.

116 {
117 return m_eorient[i];
118 }

References m_eorient.

◆ v_GetNumEdges()

int Nektar::SpatialDomains::QuadGeom::v_GetNumEdges ( ) const
inlinefinalprotectedvirtual

Get the number of edges of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 100 of file QuadGeom.h.

101 {
102 return kNedges;
103 }

References kNedges.

◆ v_GetNumVerts()

int Nektar::SpatialDomains::QuadGeom::v_GetNumVerts ( ) const
inlinefinalprotectedvirtual

Get the number of vertices of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 95 of file QuadGeom.h.

96 {
97 return kNverts;
98 }

References kNverts.

◆ v_GetVertex()

PointGeom * Nektar::SpatialDomains::QuadGeom::v_GetVertex ( const int  i) const
inlinefinalprotectedvirtual

Returns vertex i of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 105 of file QuadGeom.h.

106 {
107 return m_verts[i];
108 }

References m_verts.

◆ v_Reset()

void Nektar::SpatialDomains::QuadGeom::v_Reset ( CurveMap curvedEdges,
CurveMap curvedFaces 
)
overrideprotectedvirtual

Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 610 of file QuadGeom.cpp.

611{
612 Geometry::v_Reset(curvedEdges, curvedFaces);
613 CurveMap::iterator it = curvedFaces.find(m_globalID);
614
615 if (it != curvedFaces.end())
616 {
617 m_curve = it->second.get();
618 }
619
620 for (int i = 0; i < 4; ++i)
621 {
622 m_edges[i]->Reset(curvedEdges, curvedFaces);
623 }
624
625 SetUpXmap();
626 SetUpCoeffs(m_xmap->GetNcoeffs());
627}
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition Geometry.h:694
virtual void v_Reset(CurveMap &curvedEdges, CurveMap &curvedFaces)
Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated Geo...
Definition Geometry.cpp:366

References Nektar::SpatialDomains::Geometry2D::m_curve, m_edges, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_xmap, Nektar::SpatialDomains::Geometry::SetUpCoeffs(), SetUpXmap(), and Nektar::SpatialDomains::Geometry::v_Reset().

◆ v_Setup()

void Nektar::SpatialDomains::QuadGeom::v_Setup ( )
overrideprotectedvirtual

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 629 of file QuadGeom.cpp.

630{
631 if (!m_setupState)
632 {
633 for (int i = 0; i < 4; ++i)
634 {
635 m_edges[i]->Setup();
636 }
637 SetUpXmap();
638 SetUpCoeffs(m_xmap->GetNcoeffs());
639
640 // Check to see if expansions are linear
641 m_straightEdge = 1;
642 if ((m_xmap->GetBasisNumModes(0) != 2) ||
643 (m_xmap->GetBasisNumModes(1) != 2))
644 {
645 m_straightEdge = 0;
646 }
647
648 m_setupState = true;
649 }
650}

References m_edges, Nektar::SpatialDomains::Geometry::m_setupState, Nektar::SpatialDomains::Geometry::m_straightEdge, Nektar::SpatialDomains::Geometry::m_xmap, Nektar::SpatialDomains::Geometry::SetUpCoeffs(), and SetUpXmap().

Referenced by v_CalcGeomType().

Member Data Documentation

◆ kNedges

const int Nektar::SpatialDomains::QuadGeom::kNedges = 4
static

Definition at line 55 of file QuadGeom.h.

Referenced by QuadGeom(), v_FillGeom(), and v_GetNumEdges().

◆ kNfacets

const int Nektar::SpatialDomains::QuadGeom::kNfacets = kNedges
static

Definition at line 57 of file QuadGeom.h.

◆ kNverts

const int Nektar::SpatialDomains::QuadGeom::kNverts = 4
static

◆ m_edges

std::array<SegGeom *, kNedges> Nektar::SpatialDomains::QuadGeom::m_edges
protected

Definition at line 121 of file QuadGeom.h.

Referenced by QuadGeom(), SetUpXmap(), v_AllLeftCheck(), v_FillGeom(), v_GetEdge(), v_Reset(), and v_Setup().

◆ m_eorient

std::array<StdRegions::Orientation, kNedges> Nektar::SpatialDomains::QuadGeom::m_eorient
protected

Definition at line 122 of file QuadGeom.h.

Referenced by QuadGeom(), v_FillGeom(), and v_GetEorient().

◆ m_verts

std::array<PointGeom *, kNverts> Nektar::SpatialDomains::QuadGeom::m_verts
protected

Definition at line 120 of file QuadGeom.h.

Referenced by GetFaceOrientation(), QuadGeom(), v_AllLeftCheck(), v_CalcGeomType(), and v_GetVertex().

◆ XMLElementType

const std::string Nektar::SpatialDomains::QuadGeom::XMLElementType
static

Definition at line 76 of file QuadGeom.h.