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, const CurveSharedPtr curve=CurveSharedPtr())
 
 ~QuadGeom () override=default
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry2D
 Geometry2D ()
 
 Geometry2D (const int coordim, CurveSharedPtr curve)
 
 ~Geometry2D () override=default
 
CurveSharedPtr GetCurve ()
 
- 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).
 
GeomFactorsSharedPtr GetGeomFactors ()
 Get the geometric factors for this object, generating them if required.
 
GeomFactorsSharedPtr GetRefGeomFactors (const Array< OneD, const LibUtilities::BasisSharedPtr > &tbasis)
 
GeomFactorsSharedPtr GetMetricInfo ()
 Get the geometric factors for this object.
 
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.
 
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 ()
 
void GenGeomFactors ()
 Handles generation of geometry factors.
 

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.
 
void v_GenGeomFactors () override
 
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 (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
CurveSharedPtr m_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.
 
GeomFactorsSharedPtr m_geomFactors
 Geometric factors.
 
GeomState m_geomFactorsState
 State of the geometric factors.
 
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.
 
GeomType m_geomType
 Type of geometry.
 
LibUtilities::ShapeType m_shapeType
 Type of shape.
 
int m_globalID
 Global ID.
 
Array< OneD, 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 ()
 

Additional Inherited Members

- Static Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsSharedPtr ValidateRegGeomFactor (GeomFactorsSharedPtr geomFactor)
 Check to see if a geometric factor has already been created that contains the same regular information.
 
- Static Protected Attributes inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsVector m_regGeomFactorsManager
 

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 90 of file QuadGeom.cpp.

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

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,
const CurveSharedPtr  curve = CurveSharedPtr() 
)

◆ ~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 222 of file QuadGeom.cpp.

227{
228 return GetFaceOrientation(face1.m_verts, face2.m_verts, doRot, dir, angle,
229 tol);
230}
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:222

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 236 of file QuadGeom.cpp.

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

References ASSERTL0, 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::SpatialDomains::PointGeom::Rotate(), and tinysimd::sqrt().

◆ PreSolveStraightEdge()

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

Definition at line 551 of file QuadGeom.cpp.

552{
553 int i0, i1, j1, j2;
554 if (fabs(m_isoParameter[0][3]) >= fabs(m_isoParameter[1][3]))
555 {
556 i0 = 0;
557 i1 = 1;
558 }
559 else
560 {
561 i1 = 0;
562 i0 = 1;
563 m_straightEdge |= 2;
564 }
565 NekDouble gamma = m_isoParameter[i1][3] / m_isoParameter[i0][3];
566 std::vector<NekDouble> c(3);
567 for (int i = 0; i < 3; ++i)
568 {
569 c[i] = m_isoParameter[i1][i] - gamma * m_isoParameter[i0][i];
570 }
571 if (fabs(c[1]) >= fabs(c[2]))
572 {
573 j1 = 1;
574 j2 = 2;
575 }
576 else
577 {
578 j1 = 2;
579 j2 = 1;
580 m_straightEdge |= 4;
581 }
582 NekDouble beta = c[j2] / c[j1];
583 if (i0 == 1)
584 {
586 }
587 if (j1 == 2)
588 {
589 NekDouble temp = m_isoParameter[0][j1];
590 m_isoParameter[0][j1] = m_isoParameter[0][j2];
591 m_isoParameter[0][j2] = temp;
592 }
593 m_isoParameter[0][2] -= m_isoParameter[0][1] * beta;
594 m_isoParameter[1][0] = c[0];
595 m_isoParameter[1][1] = 1. / c[j1];
596 m_isoParameter[1][2] = beta;
597 m_isoParameter[1][3] = gamma;
598}
Array< OneD, Array< OneD, NekDouble > > m_isoParameter
Definition Geometry.h:204
@ 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_GenGeomFactors().

◆ SetUpXmap()

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

Definition at line 191 of file QuadGeom.cpp.

192{
193 int order0 = std::max(m_edges[0]->GetXmap()->GetBasis(0)->GetNumModes(),
194 m_edges[2]->GetXmap()->GetBasis(0)->GetNumModes());
195 int order1 = std::max(m_edges[1]->GetXmap()->GetBasis(0)->GetNumModes(),
196 m_edges[3]->GetXmap()->GetBasis(0)->GetNumModes());
197
198 std::array<LibUtilities::BasisKey, 2> basis = {
199 LibUtilities::BasisKey(
201 LibUtilities::PointsKey(order0 + 1,
203 LibUtilities::BasisKey(
205 LibUtilities::PointsKey(order1 + 1,
207
208 m_xmap = GetStdQuadFactory().CreateInstance(basis);
209}
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition Geometry.h:189
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
Definition Geometry.h:439
@ 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 105 of file QuadGeom.cpp.

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

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_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 476 of file QuadGeom.cpp.

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

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::Geometry::m_state, Nektar::SpatialDomains::Geometry::m_xmap, and tinysimd::sqrt().

Referenced by v_GenGeomFactors().

◆ v_GenGeomFactors()

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

Set up GeoFac for this geometry using Coord quadrature distribution

Implements Nektar::SpatialDomains::Geometry.

Definition at line 347 of file QuadGeom.cpp.

348{
349 if (!m_setupState)
350 {
352 }
353
355 {
356 GeomType Gtype = eRegular;
357
359
360 // We will first check whether we have a regular or deformed
361 // geometry. We will define regular as those cases where the
362 // Jacobian and the metric terms of the derivative are constants
363 // (i.e. not coordinate dependent)
364
365 // Check to see if expansions are linear
366 // If not linear => deformed geometry
367 m_straightEdge = 1;
368 if ((m_xmap->GetBasisNumModes(0) != 2) ||
369 (m_xmap->GetBasisNumModes(1) != 2))
370 {
371 Gtype = eDeformed;
372 m_straightEdge = 0;
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]) >
450 {
451 Gtype = eDeformed;
452 }
453 }
454 }
455
456 if (Gtype == eRegular)
457 {
459 }
460 else if (m_straightEdge)
461 {
463 }
464
466 Gtype, m_coordim, m_xmap, m_coeffs);
468 }
469}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
bool m_setupState
Wether or not the setup routines have been run.
Definition Geometry.h:193
GeomState m_geomFactorsState
State of the geometric factors.
Definition Geometry.h:187
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
Definition Geometry.h:185
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::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::ePtsFilled, Nektar::SpatialDomains::eRegular, Nektar::NekConstants::kNekZeroTol, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry::m_geomFactors, Nektar::SpatialDomains::Geometry::m_geomFactorsState, 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_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 211 of file QuadGeom.cpp.

213{
214 ASSERTL1(m_state == ePtsFilled, "Geometry is not in physical space");
215
216 Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
217 m_xmap->BwdTrans(m_coeffs[i], tmp);
218
219 return m_xmap->PhysEvaluate(Lcoord, tmp);
220}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....

References ASSERTL1, Nektar::SpatialDomains::ePtsFilled, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_state, and Nektar::SpatialDomains::Geometry::m_xmap.

◆ 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 600 of file QuadGeom.cpp.

601{
602 return i % 2;
603}

◆ 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 107 of file QuadGeom.h.

108 {
109 return static_cast<Geometry1D *>(m_edges[i]);
110 }

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 112 of file QuadGeom.h.

113 {
114 return m_eorient[i];
115 }

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 97 of file QuadGeom.h.

98 {
99 return kNedges;
100 }

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 92 of file QuadGeom.h.

93 {
94 return kNverts;
95 }

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 102 of file QuadGeom.h.

103 {
104 return m_verts[i];
105 }

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 605 of file QuadGeom.cpp.

606{
607 Geometry::v_Reset(curvedEdges, curvedFaces);
608 CurveMap::iterator it = curvedFaces.find(m_globalID);
609
610 if (it != curvedFaces.end())
611 {
612 m_curve = it->second;
613 }
614
615 for (int i = 0; i < 4; ++i)
616 {
617 m_edges[i]->Reset(curvedEdges, curvedFaces);
618 }
619
620 SetUpXmap();
621 SetUpCoeffs(m_xmap->GetNcoeffs());
622}
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition Geometry.h:704
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:372

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 624 of file QuadGeom.cpp.

625{
626 if (!m_setupState)
627 {
628 for (int i = 0; i < 4; ++i)
629 {
630 m_edges[i]->Setup();
631 }
632 SetUpXmap();
633 SetUpCoeffs(m_xmap->GetNcoeffs());
634 m_setupState = true;
635 }
636}

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

Referenced by v_GenGeomFactors().

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 118 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 119 of file QuadGeom.h.

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

◆ m_verts

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

◆ XMLElementType

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

Definition at line 76 of file QuadGeom.h.