Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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, const SegGeomSharedPtr edges[], const CurveSharedPtr curve=CurveSharedPtr())
 
 ~QuadGeom ()
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry2D
 Geometry2D ()
 
 Geometry2D (const int coordim, CurveSharedPtr curve)
 
virtual ~Geometry2D ()
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry
 Geometry ()
 Default constructor. More...
 
 Geometry (int coordim)
 Constructor when supplied a coordinate dimension. More...
 
virtual ~Geometry ()
 Default destructor. More...
 
int GetCoordim () const
 Return the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded). More...
 
void SetCoordim (int coordim)
 Sets the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded). More...
 
GeomFactorsSharedPtr GetGeomFactors ()
 Get the geometric factors for this object, generating them if required. More...
 
GeomFactorsSharedPtr GetRefGeomFactors (const Array< OneD, const LibUtilities::BasisSharedPtr > &tbasis)
 
GeomFactorsSharedPtr GetMetricInfo ()
 Get the geometric factors for this object. More...
 
LibUtilities::ShapeType GetShapeType (void)
 Get the geometric shape type of this object. More...
 
int GetGlobalID (void) const
 Get the ID of this object. More...
 
void SetGlobalID (int globalid)
 Set the ID of this object. More...
 
int GetVid (int i) const
 Get the ID of vertex i of this object. More...
 
int GetEid (int i) const
 Get the ID of edge i of this object. More...
 
int GetFid (int i) const
 Get the ID of face i of this object. More...
 
int GetTid (int i) const
 Get the ID of trace i of this object. More...
 
PointGeomSharedPtr GetVertex (int i) const
 Returns vertex i of this object. More...
 
Geometry1DSharedPtr GetEdge (int i) const
 Returns edge i of this object. More...
 
Geometry2DSharedPtr GetFace (int i) const
 Returns face i of this object. More...
 
StdRegions::Orientation GetEorient (const int i) const
 Returns the orientation of edge i with respect to the ordering of edges in the standard element. More...
 
StdRegions::Orientation GetForient (const int i) const
 Returns the orientation of face i with respect to the ordering of faces in the standard element. More...
 
int GetNumVerts () const
 Get the number of vertices of this object. More...
 
int GetNumEdges () const
 Get the number of edges of this object. More...
 
int GetNumFaces () const
 Get the number of faces of this object. More...
 
int GetShapeDim () const
 Get the object's shape dimension. More...
 
StdRegions::StdExpansionSharedPtr GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element. More...
 
const Array< OneD, const NekDouble > & GetCoeffs (const int i) const
 Return the coefficients of the transformation Geometry::m_xmap in coordinate direction i. More...
 
void FillGeom ()
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements. More...
 
std::array< NekDouble, 6 > GetBoundingBox ()
 Generates the bounding box for the element. More...
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\). More...
 
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)\). More...
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &resid)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\). More...
 
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. More...
 
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. More...
 
bool MinMaxCheck (const Array< OneD, const NekDouble > &gloCoord)
 Check if given global coord is within twice the min/max distance of the element. More...
 
void ClampLocCoords (Array< OneD, NekDouble > &locCoord, NekDouble tol)
 Clamp local coords to be within standard regions [-1, 1]^dim. More...
 
int GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex. More...
 
int GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex. More...
 
int GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face. More...
 
void Reset (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors. More...
 
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. More...
 
static StdRegions::Orientation GetFaceOrientation (const PointGeomVector &face1, const PointGeomVector &face2, bool doRot=false, int dir=0, NekDouble angle=0.0, NekDouble tol=1e-8)
 

Static Public Attributes

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

Protected Member Functions

virtual NekDouble v_GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord)
 Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i. More...
 
void v_GenGeomFactors ()
 
virtual void v_FillGeom ()
 
virtual NekDouble v_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. More...
 
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &resid)
 
virtual void v_Reset (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors. More...
 
virtual void v_Setup ()
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry2D
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 &resid)
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
void GenGeomFactors ()
 Handles generation of geometry factors. More...
 
virtual Geometry2DSharedPtr v_GetFace (int i) const
 Returns face i of this object. More...
 
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. More...
 
virtual int v_GetNumFaces () const
 Get the number of faces of this object. More...
 
virtual StdRegions::StdExpansionSharedPtr v_GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element. More...
 
virtual int v_GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex. More...
 
virtual int v_GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex. More...
 
virtual int v_GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face. More...
 
void SetUpCoeffs (const int nCoeffs)
 Initialise the Geometry::m_coeffs array. More...
 

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. More...
 
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry2D
PointGeomVector m_verts
 
SegGeomVector m_edges
 
std::vector< StdRegions::Orientationm_eorient
 
CurveSharedPtr m_curve
 
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry
int m_coordim
 Coordinate dimension of this geometry object. More...
 
GeomFactorsSharedPtr m_geomFactors
 Geometric factors. More...
 
GeomState m_geomFactorsState
 State of the geometric factors. More...
 
StdRegions::StdExpansionSharedPtr m_xmap
 \(\chi\) mapping containing isoparametric transformation. More...
 
GeomState m_state
 Enumeration to dictate whether coefficients are filled. More...
 
bool m_setupState
 Wether or not the setup routines have been run. More...
 
GeomType m_geomType
 Type of geometry. More...
 
LibUtilities::ShapeType m_shapeType
 Type of shape. More...
 
int m_globalID
 Global ID. More...
 
Array< OneD, Array< OneD, NekDouble > > m_coeffs
 Array containing expansion coefficients of m_xmap. More...
 
- Static Protected Attributes inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsVector m_regGeomFactorsManager
 

Detailed Description

Definition at line 56 of file QuadGeom.h.

Constructor & Destructor Documentation

◆ QuadGeom() [1/3]

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

Definition at line 51 of file QuadGeom.cpp.

References Nektar::LibUtilities::eQuadrilateral.

◆ QuadGeom() [2/3]

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

Definition at line 88 of file QuadGeom.cpp.

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

89  : Geometry2D(in)
90 {
91  // From Geometry
92  m_shapeType = in.m_shapeType;
93  m_globalID = in.m_globalID;
94 
95  // From QuadGeom
96  m_verts = in.m_verts;
97  m_edges = in.m_edges;
98  for (int i = 0; i < kNedges; i++)
99  {
100  m_eorient[i] = in.m_eorient[i];
101  }
102 }
static const int kNedges
Definition: QuadGeom.h:78
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry2D.h:80
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition: Geometry.h:197

◆ QuadGeom() [3/3]

Nektar::SpatialDomains::QuadGeom::QuadGeom ( const int  id,
const SegGeomSharedPtr  edges[],
const CurveSharedPtr  curve = CurveSharedPtr() 
)

Copy the edge shared pointers.

Definition at line 56 of file QuadGeom.cpp.

References ASSERTL0, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::LibUtilities::eQuadrilateral, Nektar::SpatialDomains::SegGeom::GetEdgeOrientation(), Nektar::SpatialDomains::Geometry::GetVertex(), kNedges, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry2D::m_edges, Nektar::SpatialDomains::Geometry2D::m_eorient, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_shapeType, and Nektar::SpatialDomains::Geometry2D::m_verts.

59  : Geometry2D(edges[0]->GetVertex(0)->GetCoordim(), curve)
60 {
61  int j;
62 
64  m_globalID = id;
65 
66  /// Copy the edge shared pointers.
67  m_edges.insert(m_edges.begin(), edges, edges + QuadGeom::kNedges);
68  m_eorient.resize(kNedges);
69 
70  for (j = 0; j < kNedges; ++j)
71  {
72  m_eorient[j] =
73  SegGeom::GetEdgeOrientation(*edges[j], *edges[(j + 1) % kNedges]);
74  m_verts.push_back(
75  edges[j]->GetVertex(m_eorient[j] == StdRegions::eForwards ? 0 : 1));
76  }
77 
78  for (j = 2; j < kNedges; ++j)
79  {
82  }
83 
84  m_coordim = edges[0]->GetVertex(0)->GetCoordim();
85  ASSERTL0(m_coordim > 1, "Cannot call function with dim == 1");
86 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
static const int kNedges
Definition: QuadGeom.h:78
static StdRegions::Orientation GetEdgeOrientation(const SegGeom &edge1, const SegGeom &edge2)
Get the orientation of edge1.
Definition: SegGeom.cpp:200
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry2D.h:80
int GetCoordim() const
Return the coordinate dimension of this object (i.e. the dimension of the space in which this object ...
Definition: Geometry.h:271
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition: Geometry.h:197
PointGeomSharedPtr GetVertex(int i) const
Returns vertex i of this object.
Definition: Geometry.h:343
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:183

◆ ~QuadGeom()

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

Definition at line 104 of file QuadGeom.cpp.

105 {
106 }

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

References Nektar::SpatialDomains::Geometry2D::m_verts.

Referenced by Nektar::MultiRegions::DisContField3D::FindPeriodicFaces().

141 {
142  return GetFaceOrientation(face1.m_verts, face2.m_verts,
143  doRot, dir, angle, tol);
144 }
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:138

◆ GetFaceOrientation() [2/2]

StdRegions::Orientation Nektar::SpatialDomains::QuadGeom::GetFaceOrientation ( const PointGeomVector face1,
const PointGeomVector 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 150 of file QuadGeom.cpp.

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, and Nektar::SpatialDomains::PointGeom::Rotate().

153 {
154  int i, j, vmap[4] = {-1, -1, -1, -1};
155 
156  if(doRot)
157  {
158  PointGeom rotPt;
159 
160  for (i = 0; i < 4; ++i)
161  {
162  rotPt.Rotate((*face1[i]), dir, angle);
163  for (j = 0; j < 4; ++j)
164  {
165  if (rotPt.dist(*face2[j]) < tol)
166  {
167  vmap[j] = i;
168  break;
169  }
170  }
171  }
172  }
173  else
174  {
175 
176  NekDouble x, y, z, x1, y1, z1, cx = 0.0, cy = 0.0, cz = 0.0;
177 
178  // For periodic faces, we calculate the vector between the centre
179  // points of the two faces. (For connected faces this will be
180  // zero). We can then use this to determine alignment later in the
181  // algorithm.
182  for (i = 0; i < 4; ++i)
183  {
184  cx += (*face2[i])(0) - (*face1[i])(0);
185  cy += (*face2[i])(1) - (*face1[i])(1);
186  cz += (*face2[i])(2) - (*face1[i])(2);
187  }
188  cx /= 4;
189  cy /= 4;
190  cz /= 4;
191 
192  // Now construct a mapping which takes us from the vertices of one
193  // face to the other. That is, vertex j of face2 corresponds to
194  // vertex vmap[j] of face1.
195  for (i = 0; i < 4; ++i)
196  {
197  x = (*face1[i])(0);
198  y = (*face1[i])(1);
199  z = (*face1[i])(2);
200  for (j = 0; j < 4; ++j)
201  {
202  x1 = (*face2[j])(0) - cx;
203  y1 = (*face2[j])(1) - cy;
204  z1 = (*face2[j])(2) - cz;
205  if (sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) +
206  (z1 - z) * (z1 - z)) < 1e-8)
207  {
208  vmap[j] = i;
209  break;
210  }
211  }
212  }
213  }
214 
215  // Use the mapping to determine the eight alignment options between
216  // faces.
217  if (vmap[1] == (vmap[0] + 1) % 4)
218  {
219  switch (vmap[0])
220  {
221  case 0:
223  break;
224  case 1:
226  break;
227  case 2:
229  break;
230  case 3:
232  break;
233  }
234  }
235  else
236  {
237  switch (vmap[0])
238  {
239  case 0:
241  break;
242  case 1:
244  break;
245  case 2:
247  break;
248  case 3:
250  break;
251  }
252  }
253 
254  ASSERTL0(false, "unable to determine face orientation");
256 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
double NekDouble

◆ SetUpXmap()

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

Definition at line 108 of file QuadGeom.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eModified_A, Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::SpatialDomains::Geometry2D::m_edges, and Nektar::SpatialDomains::Geometry::m_xmap.

Referenced by v_Reset(), and v_Setup().

109 {
110  int order0 = max(m_edges[0]->GetXmap()->GetBasis(0)->GetNumModes(),
111  m_edges[2]->GetXmap()->GetBasis(0)->GetNumModes());
112  int order1 = max(m_edges[1]->GetXmap()->GetBasis(0)->GetNumModes(),
113  m_edges[3]->GetXmap()->GetBasis(0)->GetNumModes());
114 
115  const LibUtilities::BasisKey B0(
117  order0,
118  LibUtilities::PointsKey(order0+1, LibUtilities::eGaussLobattoLegendre));
119  const LibUtilities::BasisKey B1(
121  order1,
122  LibUtilities::PointsKey(order1+1, LibUtilities::eGaussLobattoLegendre));
123 
125 }
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:421
Principle Modified Functions .
Definition: BasisType.h:48
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51

◆ v_ContainsPoint()

bool Nektar::SpatialDomains::QuadGeom::v_ContainsPoint ( const Array< OneD, const NekDouble > &  gloCoord,
Array< OneD, NekDouble > &  locCoord,
NekDouble  tol,
NekDouble resid 
)
protectedvirtual

For curvilinear and non-affine elements (i.e. where the Jacobian varies as a function of the standard element coordinates), this is a non-linear optimisation problem that requires the use of a Newton iteration. Note therefore that this can be an expensive operation.

The parameter tol which is by default 0, can be used to expand the coordinate range of the standard element from \([-1,1]^d\) to \([-1-\epsilon,1+\epsilon\) to handle challenging edge cases. The function also returns the local coordinates corresponding to gloCoord that can be used to speed up subsequent searches.

Parameters
gloCoordThe coordinate \( (x,y,z) \).
locCoordOn exit, this is the local coordinate \(\vec{\xi}\) such that \(\chi(\vec{\xi}) = \vec{x}\).
tolThe tolerance used to dictate the bounding box of the standard coordinates \(\vec{\xi}\).
residOn exit, returns the minimum distance between gloCoord and the quadrature points inside the element.
Returns
true if the coordinate gloCoord is contained in the element; false otherwise.
See also
Geometry::GetLocCoords.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 481 of file QuadGeom.cpp.

References Nektar::SpatialDomains::Geometry::ClampLocCoords(), Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::GetLocCoords(), Nektar::SpatialDomains::Geometry::GetMetricInfo(), and Nektar::SpatialDomains::Geometry::MinMaxCheck().

485 {
486  //Rough check if within twice min/max point
487  if (GetMetricInfo()->GetGtype() != eRegular)
488  {
489  if (!MinMaxCheck(gloCoord))
490  {
491  return false;
492  }
493  }
494 
495  // Convert to the local (eta) coordinates.
496  resid = GetLocCoords(gloCoord, stdCoord);
497 
498  // Check local coordinate is within cartesian bounds.
499  if (stdCoord[0] >= -(1 + tol) && stdCoord[1] >= -(1 + tol) &&
500  stdCoord[0] <= (1 + tol) && stdCoord[1] <= (1 + tol))
501  {
502  return true;
503  }
504 
505  //Clamp local coords
506  ClampLocCoords(stdCoord, tol);
507 
508  return false;
509 }
bool MinMaxCheck(const Array< OneD, const NekDouble > &gloCoord)
Check if given global coord is within twice the min/max distance of the element.
Definition: Geometry.cpp:435
void ClampLocCoords(Array< OneD, NekDouble > &locCoord, NekDouble tol)
Clamp local coords to be within standard regions [-1, 1]^dim.
Definition: Geometry.cpp:478
Geometry is straight-sided with constant geometric factors.
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 ge...
Definition: Geometry.h:534
GeomFactorsSharedPtr GetMetricInfo()
Get the geometric factors for this object.
Definition: Geometry.h:298

◆ v_FillGeom()

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

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

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, Nektar::SpatialDomains::Geometry2D::m_edges, Nektar::SpatialDomains::Geometry2D::m_eorient, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_state, and Nektar::SpatialDomains::Geometry::m_xmap.

Referenced by v_GenGeomFactors(), and v_GetLocCoords().

339 {
340  // check to see if geometry structure is already filled
341  if (m_state != ePtsFilled)
342  {
343  int i, j, k;
344  int nEdgeCoeffs;
345 
346  if (m_curve)
347  {
348  int npts = m_curve->m_points.size();
349  int nEdgePts = (int)sqrt(static_cast<NekDouble>(npts));
350  Array<OneD, NekDouble> tmp(npts);
351  Array<OneD, NekDouble> tmp2(m_xmap->GetTotPoints());
352  LibUtilities::PointsKey curveKey(nEdgePts, m_curve->m_ptype);
353 
354  // Sanity checks:
355  // - Curved faces should have square number of points;
356  // - Each edge should have sqrt(npts) points.
357  ASSERTL0(nEdgePts * nEdgePts == npts,
358  "NUMPOINTS should be a square number in"
359  " quadrilteral " +
360  boost::lexical_cast<string>(m_globalID));
361 
362  for (i = 0; i < kNedges; ++i)
363  {
364  ASSERTL0(m_edges[i]->GetXmap()->GetNcoeffs() == nEdgePts,
365  "Number of edge points does not correspond to "
366  "number of face points in quadrilateral " +
367  boost::lexical_cast<string>(m_globalID));
368  }
369 
370  for (i = 0; i < m_coordim; ++i)
371  {
372  for (j = 0; j < npts; ++j)
373  {
374  tmp[j] = (m_curve->m_points[j]->GetPtr())[i];
375  }
376 
377  // Interpolate m_curve points to GLL points
378  LibUtilities::Interp2D(curveKey,
379  curveKey,
380  tmp,
381  m_xmap->GetBasis(0)->GetPointsKey(),
382  m_xmap->GetBasis(1)->GetPointsKey(),
383  tmp2);
384 
385  // Forwards transform to get coefficient space.
386  m_xmap->FwdTrans(tmp2, m_coeffs[i]);
387  }
388  }
389 
390  // Now fill in edges.
391  Array<OneD, unsigned int> mapArray;
392  Array<OneD, int> signArray;
393 
394  for (i = 0; i < kNedges; i++)
395  {
396  m_edges[i]->FillGeom();
397  m_xmap->GetEdgeToElementMap(i, m_eorient[i], mapArray, signArray);
398 
399  nEdgeCoeffs = m_edges[i]->GetXmap()->GetNcoeffs();
400 
401  for (j = 0; j < m_coordim; j++)
402  {
403  for (k = 0; k < nEdgeCoeffs; k++)
404  {
405  m_coeffs[j][mapArray[k]] =
406  signArray[k] * (m_edges[i]->GetCoeffs(j))[k];
407  }
408  }
409  }
410 
412  }
413 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
static const int kNedges
Definition: QuadGeom.h:78
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
Definition: Geometry.h:421
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry2D.h:80
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis...
Definition: Interp.cpp:115
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
Geometric information has been generated.
GeomState m_state
Enumeration to dictate whether coefficients are filled.
Definition: Geometry.h:191
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:183

◆ v_GenGeomFactors()

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

Set up GeoFac for this geometry using Coord quadrature distribution

Implements Nektar::SpatialDomains::Geometry.

Definition at line 261 of file QuadGeom.cpp.

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_setupState, Nektar::SpatialDomains::Geometry2D::m_verts, Nektar::SpatialDomains::Geometry::m_xmap, v_FillGeom(), and v_Setup().

262 {
263  if(!m_setupState)
264  {
266  }
267 
269  {
270  int i;
271  GeomType Gtype = eRegular;
272 
274 
275  // We will first check whether we have a regular or deformed
276  // geometry. We will define regular as those cases where the
277  // Jacobian and the metric terms of the derivative are constants
278  // (i.e. not coordinate dependent)
279 
280  // Check to see if expansions are linear
281  // If not linear => deformed geometry
282  for (i = 0; i < m_coordim; ++i)
283  {
284  if ((m_xmap->GetBasisNumModes(0) != 2) ||
285  (m_xmap->GetBasisNumModes(1) != 2))
286  {
287  Gtype = eDeformed;
288  }
289  }
290 
291  // For linear expansions, the mapping from standard to local
292  // element is given by the relation:
293  // x_i = 0.25 * [ ( x_i^A + x_i^B + x_i^C + x_i^D) +
294  // (-x_i^A + x_i^B + x_i^C - x_i^D)*xi_1 +
295  // (-x_i^A - x_i^B + x_i^C + x_i^D)*xi_2 +
296  // ( x_i^A - x_i^B + x_i^C - x_i^D)*xi_1*xi_2 ]
297  //
298  // The jacobian of the transformation and the metric terms
299  // dxi_i/dx_j, involve only terms of the form dx_i/dxi_j (both
300  // for coordim == 2 or 3). Inspecting the formula above, it can
301  // be appreciated that the derivatives dx_i/dxi_j will be
302  // constant, if the coefficient of the non-linear term is zero.
303  //
304  // That is why for regular geometry, we require
305  //
306  // x_i^A - x_i^B + x_i^C - x_i^D = 0
307  //
308  // or equivalently
309  //
310  // x_i^A - x_i^B = x_i^D - x_i^C
311  //
312  // This corresponds to quadrilaterals which are paralellograms.
313  if (Gtype == eRegular)
314  {
315  for (i = 0; i < m_coordim; i++)
316  {
317  if (fabs((*m_verts[0])(i) - (*m_verts[1])(i) +
318  (*m_verts[2])(i) - (*m_verts[3])(i)) >
320  {
321  Gtype = eDeformed;
322  break;
323  }
324  }
325  }
326 
328  Gtype, m_coordim, m_xmap, m_coeffs);
330  }
331 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
Definition: Geometry.h:185
GeomState m_geomFactorsState
State of the geometric factors.
Definition: Geometry.h:187
static const NekDouble kNekZeroTol
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
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
Geometry is straight-sided with constant geometric factors.
Geometric information has been generated.
GeomType
Indicates the type of element geometry.
Geometry is curved or has non-constant factors.
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:183

◆ v_GetCoord()

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

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 127 of file QuadGeom.cpp.

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

129 {
130  ASSERTL1(m_state == ePtsFilled, "Geometry is not in physical space");
131 
132  Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
133  m_xmap->BwdTrans(m_coeffs[i], tmp);
134 
135  return m_xmap->PhysEvaluate(Lcoord, tmp);
136 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
Geometric information has been generated.
GeomState m_state
Enumeration to dictate whether coefficients are filled.
Definition: Geometry.h:191
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ v_GetLocCoords()

NekDouble Nektar::SpatialDomains::QuadGeom::v_GetLocCoords ( const Array< OneD, const NekDouble > &  coords,
Array< OneD, NekDouble > &  Lcoords 
)
protectedvirtual

Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this geometry object.

For curvilinear and non-affine elements (i.e. where the Jacobian varies as a function of the standard element coordinates), this is a non-linear optimisation problem that requires the use of a Newton iteration. Note therefore that this can be an expensive operation.

Note that, clearly, the provided Cartesian coordinate lie outside the element. The function therefore returns the minimum distance from some position in the element to . Lcoords will also be constrained to fit within the range \([-1,1]^d\) where \( d \) is the dimension of the element.

Parameters
coordsInput Cartesian global coordinates
LcoordsCorresponding local coordinates
Returns
Distance between obtained coordinates and provided ones.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 418 of file QuadGeom.cpp.

References Nektar::SpatialDomains::PointGeom::dot(), Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::GetMetricInfo(), Vmath::Imin(), Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry2D::m_verts, Nektar::SpatialDomains::Geometry::m_xmap, Nektar::SpatialDomains::PointGeom::Mult(), Nektar::SpatialDomains::Geometry2D::NewtonIterationForLocCoord(), Vmath::Sadd(), Nektar::SpatialDomains::PointGeom::Sub(), v_FillGeom(), Vmath::Vmul(), and Vmath::Vvtvp().

420 {
421  NekDouble resid = 0.0;
422  if (GetMetricInfo()->GetGtype() == eRegular)
423  {
424  NekDouble coords2 = (m_coordim == 3) ? coords[2] : 0.0;
425  PointGeom dv1, dv2, norm, orth1, orth2;
426  PointGeom xin(m_coordim, 0, coords[0], coords[1], coords2);
427 
428  // Calculate edge vectors from 0-1 and 0-3 edges.
429  dv1.Sub(*m_verts[1], *m_verts[0]);
430  dv2.Sub(*m_verts[3], *m_verts[0]);
431 
432  // Obtain normal to plane in which dv1 and dv2 lie
433  norm.Mult(dv1, dv2);
434 
435  // Obtain vector which are normal to dv1 and dv2.
436  orth1.Mult(norm, dv1);
437  orth2.Mult(norm, dv2);
438 
439  // Start with vector of desired points minus vertex_0
440  xin -= *m_verts[0];
441 
442  // Calculate length using L/|dv1| = (x-v0).n1/(dv1.n1) for coordiante 1
443  // Then rescale to [-1,1].
444  Lcoords[0] = xin.dot(orth2) / dv1.dot(orth2);
445  Lcoords[0] = 2 * Lcoords[0] - 1;
446  Lcoords[1] = xin.dot(orth1) / dv2.dot(orth1);
447  Lcoords[1] = 2 * Lcoords[1] - 1;
448  }
449  else
450  {
452 
453  // Determine nearest point of coords to values in m_xmap
454  int npts = m_xmap->GetTotPoints();
455  Array<OneD, NekDouble> ptsx(npts), ptsy(npts);
456  Array<OneD, NekDouble> tmpx(npts), tmpy(npts);
457 
458  m_xmap->BwdTrans(m_coeffs[0], ptsx);
459  m_xmap->BwdTrans(m_coeffs[1], ptsy);
460 
461  const Array<OneD, const NekDouble> za = m_xmap->GetPoints(0);
462  const Array<OneD, const NekDouble> zb = m_xmap->GetPoints(1);
463 
464  // guess the first local coords based on nearest point
465  Vmath::Sadd(npts, -coords[0], ptsx, 1, tmpx, 1);
466  Vmath::Sadd(npts, -coords[1], ptsy, 1, tmpy, 1);
467  Vmath::Vmul(npts, tmpx, 1, tmpx, 1, tmpx, 1);
468  Vmath::Vvtvp(npts, tmpy, 1, tmpy, 1, tmpx, 1, tmpx, 1);
469 
470  int min_i = Vmath::Imin(npts, tmpx, 1);
471 
472  Lcoords[0] = za[min_i % za.num_elements()];
473  Lcoords[1] = zb[min_i / za.num_elements()];
474 
475  // Perform newton iteration to find local coordinates
476  NewtonIterationForLocCoord(coords, ptsx, ptsy, Lcoords, resid);
477  }
478  return resid;
479 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
Definition: Vmath.cpp:850
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
Definition: Geometry2D.cpp:65
double NekDouble
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.cpp:318
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
Geometry is straight-sided with constant geometric factors.
GeomFactorsSharedPtr GetMetricInfo()
Get the geometric factors for this object.
Definition: Geometry.h:298
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:183
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:186

◆ v_Reset()

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

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 511 of file QuadGeom.cpp.

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

512 {
513  Geometry::v_Reset(curvedEdges, curvedFaces);
514  CurveMap::iterator it = curvedFaces.find(m_globalID);
515 
516  if (it != curvedFaces.end())
517  {
518  m_curve = it->second;
519  }
520 
521  for (int i = 0; i < 4; ++i)
522  {
523  m_edges[i]->Reset(curvedEdges, curvedFaces);
524  }
525 
526  SetUpXmap();
527  SetUpCoeffs(m_xmap->GetNcoeffs());
528 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
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:335
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition: Geometry.h:643

◆ v_Setup()

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 530 of file QuadGeom.cpp.

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

Referenced by v_GenGeomFactors().

531 {
532  if(!m_setupState)
533  {
534  for (int i = 0; i < 4; ++i)
535  {
536  m_edges[i]->Setup();
537  }
538  SetUpXmap();
539  SetUpCoeffs(m_xmap->GetNcoeffs());
540  m_setupState = true;
541  }
542 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
bool m_setupState
Wether or not the setup routines have been run.
Definition: Geometry.h:193
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition: Geometry.h:643

Member Data Documentation

◆ kNedges

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

Definition at line 78 of file QuadGeom.h.

Referenced by QuadGeom(), and v_FillGeom().

◆ kNverts

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

◆ XMLElementType

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

Definition at line 79 of file QuadGeom.h.