Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | List of all members
Nektar::SpatialDomains::TriGeom Class Reference

#include <TriGeom.h>

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

Public Member Functions

 TriGeom ()
 
 TriGeom (const TriGeom &in)
 
 TriGeom (const int id, const SegGeomSharedPtr edges[], const CurveSharedPtr curve=CurveSharedPtr())
 
 ~TriGeom ()
 
- 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 TriGeom &face1, const TriGeom &face2, bool doRot, int dir, NekDouble angle, NekDouble tol)
 
static StdRegions::Orientation GetFaceOrientation (const PointGeomVector &face1, const PointGeomVector &face2, bool doRot, int dir, NekDouble angle, NekDouble tol)
 

Static Public Attributes

static const int kNedges = 3
 Get the orientation of face1. More...
 
static const int kNverts = 3
 
- 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...
 
virtual 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 61 of file TriGeom.h.

Constructor & Destructor Documentation

◆ TriGeom() [1/3]

Nektar::SpatialDomains::TriGeom::TriGeom ( )

Definition at line 51 of file TriGeom.cpp.

References Nektar::LibUtilities::eTriangle.

52 {
54 }
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition: Geometry.h:197

◆ TriGeom() [2/3]

Nektar::SpatialDomains::TriGeom::TriGeom ( const TriGeom in)

Definition at line 85 of file TriGeom.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.

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

◆ TriGeom() [3/3]

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

Definition at line 56 of file TriGeom.cpp.

References ASSERTL0, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::LibUtilities::eTriangle, 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 + TriGeom::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 
80 
81  m_coordim = edges[0]->GetVertex(0)->GetCoordim();
82  ASSERTL0(m_coordim > 1, "Cannot call function with dim == 1");
83 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
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
static const int kNedges
Get the orientation of face1.
Definition: TriGeom.h:73
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

◆ ~TriGeom()

Nektar::SpatialDomains::TriGeom::~TriGeom ( )

Definition at line 103 of file TriGeom.cpp.

104 {
105 }

Member Function Documentation

◆ GetFaceOrientation() [1/2]

StdRegions::Orientation Nektar::SpatialDomains::TriGeom::GetFaceOrientation ( const TriGeom face1,
const TriGeom face2,
bool  doRot,
int  dir,
NekDouble  angle,
NekDouble  tol 
)
static

Definition at line 118 of file TriGeom.cpp.

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

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

121 {
122  return GetFaceOrientation(face1.m_verts, face2.m_verts,
123  doRot, dir, angle, tol);
124 }
static StdRegions::Orientation GetFaceOrientation(const TriGeom &face1, const TriGeom &face2, bool doRot, int dir, NekDouble angle, NekDouble tol)
Definition: TriGeom.cpp:118

◆ GetFaceOrientation() [2/2]

StdRegions::Orientation Nektar::SpatialDomains::TriGeom::GetFaceOrientation ( const PointGeomVector face1,
const PointGeomVector face2,
bool  doRot,
int  dir,
NekDouble  angle,
NekDouble  tol 
)
static

Definition at line 126 of file TriGeom.cpp.

References ASSERTL0, Nektar::SpatialDomains::PointGeom::dist(), Nektar::StdRegions::eDir1BwdDir1_Dir2BwdDir2, Nektar::StdRegions::eDir1BwdDir1_Dir2FwdDir2, Nektar::StdRegions::eDir1BwdDir2_Dir2BwdDir1, Nektar::StdRegions::eDir1FwdDir1_Dir2FwdDir2, Nektar::StdRegions::eDir1FwdDir2_Dir2BwdDir1, Nektar::StdRegions::eDir1FwdDir2_Dir2FwdDir1, Nektar::StdRegions::eNoOrientation, and Nektar::SpatialDomains::PointGeom::Rotate().

129 {
130  int i, j, vmap[3] = {-1, -1, -1};
131 
132  if(doRot)
133  {
134  PointGeom rotPt;
135 
136  for (i = 0; i < 3; ++i)
137  {
138  rotPt.Rotate((*face1[i]), dir, angle);
139  for (j = 0; j < 3; ++j)
140  {
141  if (rotPt.dist(*face2[j]) < tol)
142  {
143  vmap[j] = i;
144  break;
145  }
146  }
147  }
148  }
149  else
150  {
151 
152  NekDouble x, y, z, x1, y1, z1, cx = 0.0, cy = 0.0, cz = 0.0;
153 
154  // For periodic faces, we calculate the vector between the centre
155  // points of the two faces. (For connected faces this will be
156  // zero). We can then use this to determine alignment later in the
157  // algorithm.
158  for (i = 0; i < 3; ++i)
159  {
160  cx += (*face2[i])(0) - (*face1[i])(0);
161  cy += (*face2[i])(1) - (*face1[i])(1);
162  cz += (*face2[i])(2) - (*face1[i])(2);
163  }
164  cx /= 3;
165  cy /= 3;
166  cz /= 3;
167 
168  // Now construct a mapping which takes us from the vertices of one
169  // face to the other. That is, vertex j of face2 corresponds to
170  // vertex vmap[j] of face1.
171  for (i = 0; i < 3; ++i)
172  {
173  x = (*face1[i])(0);
174  y = (*face1[i])(1);
175  z = (*face1[i])(2);
176  for (j = 0; j < 3; ++j)
177  {
178  x1 = (*face2[j])(0) - cx;
179  y1 = (*face2[j])(1) - cy;
180  z1 = (*face2[j])(2) - cz;
181  if (sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) +
182  (z1 - z) * (z1 - z)) < 1e-8)
183  {
184  vmap[j] = i;
185  break;
186  }
187  }
188  }
189  }
190 
191  if (vmap[1] == (vmap[0] + 1) % 3)
192  {
193  switch (vmap[0])
194  {
195  case 0:
197  break;
198  case 1:
200  break;
201  case 2:
203  break;
204  }
205  }
206  else
207  {
208  switch (vmap[0])
209  {
210  case 0:
212  break;
213  case 1:
215  break;
216  case 2:
218  break;
219  }
220  }
221 
222  ASSERTL0(false, "Unable to determine triangle orientation");
224 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
double NekDouble

◆ SetUpXmap()

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

Definition at line 608 of file TriGeom.cpp.

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

Referenced by v_Reset(), and v_Setup().

609 {
610  int order0 = m_edges[0]->GetXmap()->GetBasis(0)->GetNumModes();
611  int order1 = max(order0,
612  max(m_edges[1]->GetXmap()->GetBasis(0)->GetNumModes(),
613  m_edges[2]->GetXmap()->GetBasis(0)->GetNumModes()));
614 
615  const LibUtilities::BasisKey B0(
617  order0,
618  LibUtilities::PointsKey(order0+1, LibUtilities::eGaussLobattoLegendre));
619  const LibUtilities::BasisKey B1(
621  order1,
622  LibUtilities::PointsKey(order1,
624 
626 }
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
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:58
Principle Modified Functions .
Definition: BasisType.h:49
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::TriGeom::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 546 of file TriGeom.cpp.

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

550 {
551  //Rough check if within twice min/max point
552  if (GetMetricInfo()->GetGtype() != eRegular)
553  {
554  if (!MinMaxCheck(gloCoord))
555  {
556  return false;
557  }
558  }
559 
560  // Convert to the local (eta) coordinates.
561  resid = GetLocCoords(gloCoord, stdCoord);
562 
563  if (stdCoord[0] >= -(1 + tol) && stdCoord[1] >= -(1 + tol) &&
564  stdCoord[0] + stdCoord[1] <= tol)
565  {
566  return true;
567  }
568 
569  //Clamp local coords
570  ClampLocCoords(stdCoord, tol);
571 
572  return false;
573 }
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::TriGeom::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 261 of file TriGeom.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eGaussRadauMAlpha1Beta0, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, Nektar::SpatialDomains::ePtsFilled, Nektar::ErrorUtil::ewarning, Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::LibUtilities::Interp2D(), kNedges, Nektar::NekConstants::kVertexTheSameDouble, 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, Nektar::SpatialDomains::Geometry2D::m_verts, Nektar::SpatialDomains::Geometry::m_xmap, NEKERROR, and Nektar::LibUtilities::PointsManager().

Referenced by v_GenGeomFactors(), and v_GetLocCoords().

262 {
263  // check to see if geometry structure is already filled
264  if (m_state == ePtsFilled)
265  {
266  return;
267  }
268 
269  int i, j, k;
270  int nEdgeCoeffs = m_xmap->GetEdgeNcoeffs(0);
271 
272  if (m_curve)
273  {
274  int pdim = LibUtilities::PointsManager()[LibUtilities::PointsKey(
275  2, m_curve->m_ptype)]
276  ->GetPointsDim();
277 
278  // Deal with 2D points type separately
279  // (e.g. electrostatic or Fekete points) to 1D tensor
280  // product.
281  if (pdim == 2)
282  {
283  int N = m_curve->m_points.size();
284  int nEdgePts =
285  (-1 + (int)sqrt(static_cast<NekDouble>(8 * N + 1))) / 2;
286 
287  ASSERTL0(nEdgePts * (nEdgePts + 1) / 2 == N,
288  "NUMPOINTS should be a triangle number for"
289  " triangle curved face " +
290  boost::lexical_cast<string>(m_globalID));
291 
292  // Sanity check 1: are curved vertices consistent with
293  // triangle vertices?
294  for (i = 0; i < 3; ++i)
295  {
296  NekDouble dist = m_verts[i]->dist(*(m_curve->m_points[i]));
298  {
299  std::stringstream ss;
300  ss << "Curved vertex " << i << " of triangle " << m_globalID
301  << " is separated from expansion vertex by"
302  << " more than " << NekConstants::kVertexTheSameDouble
303  << " (dist = " << dist << ")";
304  NEKERROR(ErrorUtil::ewarning, ss.str().c_str());
305  }
306  }
307 
308  // Sanity check 2: are curved edges from the face curvature
309  // consistent with curved edges?
310  for (i = 0; i < kNedges; ++i)
311  {
312  CurveSharedPtr edgeCurve = m_edges[i]->GetCurve();
313 
314  ASSERTL0(edgeCurve->m_points.size() == nEdgePts,
315  "Number of edge points does not correspond "
316  "to number of face points in triangle " +
317  boost::lexical_cast<string>(m_globalID));
318 
319  const int offset = 3 + i * (nEdgePts - 2);
320  NekDouble maxDist = 0.0;
321 
322  // Account for different ordering of nodal coordinates
323  // vs. Cartesian ordering of element.
325 
326  if (i == 2)
327  {
328  orient = orient == StdRegions::eForwards ?
330  }
331 
332  if (orient == StdRegions::eForwards)
333  {
334  for (j = 0; j < nEdgePts - 2; ++j)
335  {
336  NekDouble dist = m_curve->m_points[offset + j]->dist(
337  *(edgeCurve->m_points[j + 1]));
338  maxDist = dist > maxDist ? dist : maxDist;
339  }
340  }
341  else
342  {
343  for (j = 0; j < nEdgePts - 2; ++j)
344  {
345  NekDouble dist = m_curve->m_points[offset + j]->dist(
346  *(edgeCurve->m_points[nEdgePts - 2 - j]));
347  maxDist = dist > maxDist ? dist : maxDist;
348  }
349  }
350 
352  {
353  std::stringstream ss;
354  ss << "Curved edge " << i << " of triangle " << m_globalID
355  << " has a point separated from edge interior"
356  << " points by more than "
358  << " (maxdist = " << maxDist << ")";
359  NEKERROR(ErrorUtil::ewarning, ss.str().c_str());
360  }
361  }
362 
363  const LibUtilities::PointsKey P0(
365  const LibUtilities::PointsKey P1(
367  const LibUtilities::BasisKey T0(
368  LibUtilities::eOrtho_A, nEdgePts, P0);
369  const LibUtilities::BasisKey T1(
370  LibUtilities::eOrtho_B, nEdgePts, P1);
371  Array<OneD, NekDouble> phys(
372  max(nEdgePts * nEdgePts, m_xmap->GetTotPoints()));
373  Array<OneD, NekDouble> tmp(nEdgePts * nEdgePts);
374 
375  for (i = 0; i < m_coordim; ++i)
376  {
377  // Create a StdNodalTriExp.
380  AllocateSharedPtr(T0, T1, m_curve->m_ptype);
381 
382  for (j = 0; j < N; ++j)
383  {
384  phys[j] = (m_curve->m_points[j]->GetPtr())[i];
385  }
386 
387  t->BwdTrans(phys, tmp);
388 
389  // Interpolate points to standard region.
391  P1,
392  tmp,
393  m_xmap->GetBasis(0)->GetPointsKey(),
394  m_xmap->GetBasis(1)->GetPointsKey(),
395  phys);
396 
397  // Forwards transform to get coefficient space.
398  m_xmap->FwdTrans(phys, m_coeffs[i]);
399  }
400  }
401  else if (pdim == 1)
402  {
403  int npts = m_curve->m_points.size();
404  int nEdgePts = (int)sqrt(static_cast<NekDouble>(npts));
405  Array<OneD, NekDouble> tmp(npts);
406  Array<OneD, NekDouble> phys(m_xmap->GetTotPoints());
407  LibUtilities::PointsKey curveKey(nEdgePts, m_curve->m_ptype);
408 
409  // Sanity checks:
410  // - Curved faces should have square number of points;
411  // - Each edge should have sqrt(npts) points.
412  ASSERTL0(nEdgePts * nEdgePts == npts,
413  "NUMPOINTS should be a square number for"
414  " triangle " +
415  boost::lexical_cast<string>(m_globalID));
416 
417  for (i = 0; i < kNedges; ++i)
418  {
419  ASSERTL0(m_edges[i]->GetXmap()->GetNcoeffs() == nEdgePts,
420  "Number of edge points does not correspond to "
421  "number of face points in triangle " +
422  boost::lexical_cast<string>(m_globalID));
423  }
424 
425  for (i = 0; i < m_coordim; ++i)
426  {
427  for (j = 0; j < npts; ++j)
428  {
429  tmp[j] = (m_curve->m_points[j]->GetPtr())[i];
430  }
431 
432  // Interpolate curve points to standard triangle
433  // points.
434  LibUtilities::Interp2D(curveKey,
435  curveKey,
436  tmp,
437  m_xmap->GetBasis(0)->GetPointsKey(),
438  m_xmap->GetBasis(1)->GetPointsKey(),
439  phys);
440 
441  // Forwards transform to get coefficient space.
442  m_xmap->FwdTrans(phys, m_coeffs[i]);
443  }
444  }
445  else
446  {
447  ASSERTL0(false,
448  "Only 1D/2D points distributions "
449  "supported.");
450  }
451  }
452 
453  Array<OneD, unsigned int> mapArray(nEdgeCoeffs);
454  Array<OneD, int> signArray(nEdgeCoeffs);
455 
456  for (i = 0; i < kNedges; i++)
457  {
458  m_edges[i]->FillGeom();
459  m_xmap->GetEdgeToElementMap(i, m_eorient[i], mapArray, signArray);
460 
461  nEdgeCoeffs = m_edges[i]->GetXmap()->GetNcoeffs();
462 
463  for (j = 0; j < m_coordim; j++)
464  {
465  for (k = 0; k < nEdgeCoeffs; k++)
466  {
467  m_coeffs[j][mapArray[k]] =
468  signArray[k] * m_edges[i]->GetCoeffs(j)[k];
469  }
470  }
471  }
472 
474 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:209
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
Definition: Geometry.h:421
static const NekDouble kVertexTheSameDouble
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:58
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry2D.h:80
Principle Orthogonal Functions .
Definition: BasisType.h:46
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
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
PointsManagerT & PointsManager(void)
Principle Orthogonal Functions .
Definition: BasisType.h:45
double NekDouble
static const int kNedges
Get the orientation of face1.
Definition: TriGeom.h:73
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
std::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:61
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
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51

◆ v_GenGeomFactors()

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

Implements Nektar::SpatialDomains::Geometry.

Definition at line 226 of file TriGeom.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::ePtsFilled, Nektar::SpatialDomains::eRegular, 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::Geometry::m_xmap, v_FillGeom(), and v_Setup().

227 {
228  if(!m_setupState)
229  {
231  }
232 
234  {
235  GeomType Gtype = eRegular;
236 
238 
239  // check to see if expansions are linear
240  for (int i = 0; i < m_coordim; ++i)
241  {
242  if (m_xmap->GetBasisNumModes(0) != 2 ||
243  m_xmap->GetBasisNumModes(1) != 2)
244  {
245  Gtype = eDeformed;
246  }
247  }
248 
250  Gtype, m_coordim, m_xmap, m_coeffs);
251 
253  }
254 }
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 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::TriGeom::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 107 of file TriGeom.cpp.

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

109 {
110  ASSERTL1(m_state == ePtsFilled, "Geometry is not in physical space");
111 
112  Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
113  m_xmap->BwdTrans(m_coeffs[i], tmp);
114 
115  return m_xmap->PhysEvaluate(Lcoord, tmp);
116 }
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::TriGeom::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 479 of file TriGeom.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().

481 {
482  NekDouble resid = 0.0;
484 
485  // calculate local coordinate for coord
486  if (GetMetricInfo()->GetGtype() == eRegular)
487  {
488  NekDouble coords2 = (m_coordim == 3) ? coords[2] : 0.0;
489  PointGeom dv1, dv2, norm, orth1, orth2;
490  PointGeom xin(m_coordim, 0, coords[0], coords[1], coords2);
491 
492  // Calculate edge vectors from 0-1 and 0-2 edges.
493  dv1.Sub(*m_verts[1], *m_verts[0]);
494  dv2.Sub(*m_verts[2], *m_verts[0]);
495 
496  // Obtain normal to plane in which dv1 and dv2 lie
497  norm.Mult(dv1, dv2);
498 
499  // Obtain vector which are proportional to normal of dv1 and dv2.
500  orth1.Mult(norm, dv1);
501  orth2.Mult(norm, dv2);
502 
503  // Start with vector of desired points minus vertex_0
504  xin -= *m_verts[0];
505 
506  // Calculate length using L/|dv1| = (x-v0).n1/(dv1.n1) for coordiante 1
507  // Then rescale to [-1,1].
508  Lcoords[0] = xin.dot(orth2) / dv1.dot(orth2);
509  Lcoords[0] = 2 * Lcoords[0] - 1;
510  Lcoords[1] = xin.dot(orth1) / dv2.dot(orth1);
511  Lcoords[1] = 2 * Lcoords[1] - 1;
512  }
513  else
514  {
515  // Determine nearest point of coords to values in m_xmap
516  int npts = m_xmap->GetTotPoints();
517  Array<OneD, NekDouble> ptsx(npts), ptsy(npts);
518  Array<OneD, NekDouble> tmpx(npts), tmpy(npts);
519 
520  m_xmap->BwdTrans(m_coeffs[0], ptsx);
521  m_xmap->BwdTrans(m_coeffs[1], ptsy);
522 
523  const Array<OneD, const NekDouble> za = m_xmap->GetPoints(0);
524  const Array<OneD, const NekDouble> zb = m_xmap->GetPoints(1);
525 
526  // guess the first local coords based on nearest point
527  Vmath::Sadd(npts, -coords[0], ptsx, 1, tmpx, 1);
528  Vmath::Sadd(npts, -coords[1], ptsy, 1, tmpy, 1);
529  Vmath::Vmul(npts, tmpx, 1, tmpx, 1, tmpx, 1);
530  Vmath::Vvtvp(npts, tmpy, 1, tmpy, 1, tmpx, 1, tmpx, 1);
531 
532  int min_i = Vmath::Imin(npts, tmpx, 1);
533 
534  Lcoords[0] = za[min_i % za.num_elements()];
535  Lcoords[1] = zb[min_i / za.num_elements()];
536 
537  // recover cartesian coordinate from collapsed coordinate.
538  Lcoords[0] = (1.0 + Lcoords[0]) * (1.0 - Lcoords[1]) / 2 - 1.0;
539 
540  // Perform newton iteration to find local coordinates
541  NewtonIterationForLocCoord(coords, ptsx, ptsy, Lcoords, resid);
542  }
543  return resid;
544 }
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::TriGeom::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 575 of file TriGeom.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().

576 {
577  Geometry::v_Reset(curvedEdges, curvedFaces);
578  CurveMap::iterator it = curvedFaces.find(m_globalID);
579 
580  if (it != curvedFaces.end())
581  {
582  m_curve = it->second;
583  }
584 
585  for (int i = 0; i < 3; ++i)
586  {
587  m_edges[i]->Reset(curvedEdges, curvedFaces);
588  }
589 
590  SetUpXmap();
591  SetUpCoeffs(m_xmap->GetNcoeffs());
592 }
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::TriGeom::v_Setup ( )
protectedvirtual

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 594 of file TriGeom.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().

595 {
596  if(!m_setupState)
597  {
598  for (int i = 0; i < 3; ++i)
599  {
600  m_edges[i]->Setup();
601  }
602  SetUpXmap();
603  SetUpCoeffs(m_xmap->GetNcoeffs());
604  m_setupState = true;
605  }
606 }
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::TriGeom::kNedges = 3
static

Get the orientation of face1.

Definition at line 73 of file TriGeom.h.

Referenced by TriGeom(), and v_FillGeom().

◆ kNverts

const int Nektar::SpatialDomains::TriGeom::kNverts = 3
static

Definition at line 74 of file TriGeom.h.

Referenced by Nektar::SpatialDomains::TetGeom::SetUpFaceOrientation().