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

#include <TetGeom.h>

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

Public Member Functions

 TetGeom ()
 
 TetGeom (int id, const TriGeomSharedPtr faces[])
 
 ~TetGeom ()
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry3D
 Geometry3D ()
 
 Geometry3D (const int coordim)
 
virtual ~Geometry3D ()
 
int GetDir (const int faceidx, const int facedir) const
 Returns the element coordinate direction corresponding to a given face coordinate direction. More...
 
- 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 Attributes

static const int kNverts = 4
 
static const int kNedges = 6
 
static const int kNqfaces = 0
 
static const int kNtfaces = 4
 
static const int kNfaces = kNqfaces + kNtfaces
 
static const std::string XMLElementType
 
- Static Public Attributes inherited from Nektar::SpatialDomains::Geometry3D
static const int kDim = 3
 

Protected Member Functions

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)
 Determines if a point specified in global coordinates is located within this tetrahedral geometry and return local caretsian coordinates. More...
 
virtual int v_GetVertexEdgeMap (const int i, const int j) const
 Returns the standard element edge IDs that are connected to a given vertex. More...
 
virtual int v_GetVertexFaceMap (const int i, const int j) const
 Returns the standard element face IDs that are connected to a given vertex. More...
 
virtual int v_GetEdgeFaceMap (const int i, const int j) const
 Returns the standard element edge IDs that are connected to a given face. More...
 
virtual int v_GetDir (const int faceidx, const int facedir) const
 
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 ()
 
virtual void v_GenGeomFactors ()
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry3D
void NewtonIterationForLocCoord (const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, const Array< OneD, const NekDouble > &ptsz, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
 
virtual void v_FillGeom ()
 Put all quadrature information into face/edge structure and backward transform. More...
 
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 int v_GetShapeDim () const
 Get the object's shape dimension. More...
 
virtual int v_GetNumVerts () const
 Get the number of vertices of this object. More...
 
virtual int v_GetNumEdges () const
 Get the number of edges of this object. More...
 
virtual int v_GetNumFaces () const
 Get the number of faces of this object. More...
 
virtual PointGeomSharedPtr v_GetVertex (int i) const
 
virtual Geometry1DSharedPtr v_GetEdge (int i) const
 Returns edge i of this object. More...
 
virtual Geometry2DSharedPtr v_GetFace (int i) const
 Returns face i of this object. More...
 
virtual StdRegions::Orientation v_GetEorient (const int i) const
 Returns the orientation of edge i with respect to the ordering of edges in the standard element. 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...
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
void GenGeomFactors ()
 Handles generation of geometry factors. 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...
 
void SetUpCoeffs (const int nCoeffs)
 Initialise the Geometry::m_coeffs array. More...
 

Private Member Functions

void SetUpLocalEdges ()
 
void SetUpLocalVertices ()
 
void SetUpEdgeOrientation ()
 
void SetUpFaceOrientation ()
 
void SetUpXmap ()
 Set up the m_xmap object by determining the order of each direction from derived faces. More...
 

Static Private Attributes

static const unsigned int VertexEdgeConnectivity [4][3]
 
static const unsigned int VertexFaceConnectivity [4][3]
 
static const unsigned int EdgeFaceConnectivity [6][2]
 

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::Geometry3D
PointGeomVector m_verts
 
SegGeomVector m_edges
 
Geometry2DVector m_faces
 
std::vector< StdRegions::Orientationm_eorient
 
std::vector< StdRegions::Orientationm_forient
 
int m_eid
 
bool m_ownverts
 
- 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 47 of file TetGeom.h.

Constructor & Destructor Documentation

◆ TetGeom() [1/2]

Nektar::SpatialDomains::TetGeom::TetGeom ( )

Definition at line 54 of file TetGeom.cpp.

References Nektar::LibUtilities::eTetrahedron.

55 {
57 }
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition: Geometry.h:197

◆ TetGeom() [2/2]

Nektar::SpatialDomains::TetGeom::TetGeom ( int  id,
const TriGeomSharedPtr  faces[] 
)

Copy the face shared pointers

Set up orientation vectors with correct amount of elements.

Definition at line 59 of file TetGeom.cpp.

References Nektar::LibUtilities::eTetrahedron, kNedges, kNfaces, Nektar::SpatialDomains::Geometry3D::m_eorient, Nektar::SpatialDomains::Geometry3D::m_faces, Nektar::SpatialDomains::Geometry3D::m_forient, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_shapeType, SetUpEdgeOrientation(), SetUpFaceOrientation(), SetUpLocalEdges(), and SetUpLocalVertices().

60  : Geometry3D(faces[0]->GetEdge(0)->GetVertex(0)->GetCoordim())
61 {
63  m_globalID = id;
64 
65  /// Copy the face shared pointers
66  m_faces.insert(m_faces.begin(), faces, faces + TetGeom::kNfaces);
67 
68  /// Set up orientation vectors with correct amount of elements.
69  m_eorient.resize(kNedges);
70  m_forient.resize(kNfaces);
71 
76 }
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry3D.h:86
static const int kNfaces
Definition: TetGeom.h:58
std::vector< StdRegions::Orientation > m_forient
Definition: Geometry3D.h:87
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
Definition: TetGeom.h:55
Geometry1DSharedPtr GetEdge(int i) const
Returns edge i of this object.
Definition: Geometry.h:351
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

◆ ~TetGeom()

Nektar::SpatialDomains::TetGeom::~TetGeom ( )

Definition at line 78 of file TetGeom.cpp.

79 {
80 }

Member Function Documentation

◆ SetUpEdgeOrientation()

void Nektar::SpatialDomains::TetGeom::SetUpEdgeOrientation ( )
private

Definition at line 441 of file TetGeom.cpp.

References ASSERTL0, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetVid(), kNedges, Nektar::SpatialDomains::Geometry3D::m_edges, Nektar::SpatialDomains::Geometry3D::m_eorient, and Nektar::SpatialDomains::Geometry3D::m_verts.

Referenced by TetGeom().

442 {
443 
444  // This 2D array holds the local id's of all the vertices
445  // for every edge. For every edge, they are ordered to what we
446  // define as being Forwards
447  const unsigned int edgeVerts[kNedges][2] = {
448  {0, 1}, {1, 2}, {0, 2}, {0, 3}, {1, 3}, {2, 3}};
449 
450  int i;
451  for (i = 0; i < kNedges; i++)
452  {
453  if (m_edges[i]->GetVid(0) == m_verts[edgeVerts[i][0]]->GetGlobalID())
454  {
456  }
457  else if (m_edges[i]->GetVid(0) == m_verts[edgeVerts[i][1]]->GetGlobalID())
458  {
460  }
461  else
462  {
463  ASSERTL0(false, "Could not find matching vertex for the edge");
464  }
465  }
466 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::vector< StdRegions::Orientation > m_eorient
Definition: Geometry3D.h:86
int GetGlobalID(void) const
Get the ID of this object.
Definition: Geometry.h:314
static const int kNedges
Definition: TetGeom.h:55
int GetVid(int i) const
Get the ID of vertex i of this object.
Definition: Geometry.cpp:137

◆ SetUpFaceOrientation()

void Nektar::SpatialDomains::TetGeom::SetUpFaceOrientation ( )
private

Definition at line 468 of file TetGeom.cpp.

References ASSERTL0, ASSERTL1, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetVertex(), Nektar::NekConstants::kNekZeroTol, kNfaces, kNqfaces, kNtfaces, Nektar::SpatialDomains::TriGeom::kNverts, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry3D::m_faces, Nektar::SpatialDomains::Geometry3D::m_forient, and Nektar::SpatialDomains::Geometry3D::m_verts.

Referenced by TetGeom().

469 {
470 
471  int f, i;
472 
473  // These arrays represent the vector of the A and B
474  // coordinate of the local elemental coordinate system
475  // where A corresponds with the coordinate direction xi_i
476  // with the lowest index i (for that particular face)
477  // Coordinate 'B' then corresponds to the other local
478  // coordinate (i.e. with the highest index)
479  Array<OneD, NekDouble> elementAaxis(m_coordim);
480  Array<OneD, NekDouble> elementBaxis(m_coordim);
481 
482  // These arrays correspond to the local coordinate
483  // system of the face itself (i.e. the Geometry2D)
484  // faceAaxis correspond to the xi_0 axis
485  // faceBaxis correspond to the xi_1 axis
486  Array<OneD, NekDouble> faceAaxis(m_coordim);
487  Array<OneD, NekDouble> faceBaxis(m_coordim);
488 
489  // This is the base vertex of the face (i.e. the Geometry2D)
490  // This corresponds to thevertex with local ID 0 of the
491  // Geometry2D
492  unsigned int baseVertex;
493 
494  // The lenght of the vectors above
495  NekDouble elementAaxis_length;
496  NekDouble elementBaxis_length;
497  NekDouble faceAaxis_length;
498  NekDouble faceBaxis_length;
499 
500  // This 2D array holds the local id's of all the vertices
501  // for every face. For every face, they are ordered in such
502  // a way that the implementation below allows a unified approach
503  // for all faces.
504  const unsigned int faceVerts[kNfaces][TriGeom::kNverts] = {
505  {0, 1, 2}, {0, 1, 3}, {1, 2, 3}, {0, 2, 3}};
506 
507  NekDouble dotproduct1 = 0.0;
508  NekDouble dotproduct2 = 0.0;
509 
510  unsigned int orientation;
511 
512  // Loop over all the faces to set up the orientation
513  for (f = 0; f < kNqfaces + kNtfaces; f++)
514  {
515  // initialisation
516  elementAaxis_length = 0.0;
517  elementBaxis_length = 0.0;
518  faceAaxis_length = 0.0;
519  faceBaxis_length = 0.0;
520 
521  dotproduct1 = 0.0;
522  dotproduct2 = 0.0;
523 
524  baseVertex = m_faces[f]->GetVid(0);
525 
526  // We are going to construct the vectors representing the A and B axis
527  // of every face. These vectors will be constructed as a
528  // vector-representation
529  // of the edges of the face. However, for both coordinate directions, we
530  // can
531  // represent the vectors by two different edges. That's why we need to
532  // make sure that
533  // we pick the edge to which the baseVertex of the
534  // Geometry2D-representation of the face
535  // belongs...
536 
537  // Compute the length of edges on a base-face
538  if (baseVertex == m_verts[faceVerts[f][0]]->GetGlobalID())
539  {
540  for (i = 0; i < m_coordim; i++)
541  {
542  elementAaxis[i] = (*m_verts[faceVerts[f][1]])[i] -
543  (*m_verts[faceVerts[f][0]])[i];
544  elementBaxis[i] = (*m_verts[faceVerts[f][2]])[i] -
545  (*m_verts[faceVerts[f][0]])[i];
546  }
547  }
548  else if (baseVertex == m_verts[faceVerts[f][1]]->GetGlobalID())
549  {
550  for (i = 0; i < m_coordim; i++)
551  {
552  elementAaxis[i] = (*m_verts[faceVerts[f][1]])[i] -
553  (*m_verts[faceVerts[f][0]])[i];
554  elementBaxis[i] = (*m_verts[faceVerts[f][2]])[i] -
555  (*m_verts[faceVerts[f][1]])[i];
556  }
557  }
558  else if (baseVertex == m_verts[faceVerts[f][2]]->GetGlobalID())
559  {
560  for (i = 0; i < m_coordim; i++)
561  {
562  elementAaxis[i] = (*m_verts[faceVerts[f][1]])[i] -
563  (*m_verts[faceVerts[f][2]])[i];
564  elementBaxis[i] = (*m_verts[faceVerts[f][2]])[i] -
565  (*m_verts[faceVerts[f][0]])[i];
566  }
567  }
568  else
569  {
570  ASSERTL0(false, "Could not find matching vertex for the face");
571  }
572 
573  // Now, construct the edge-vectors of the local coordinates of
574  // the Geometry2D-representation of the face
575  for (i = 0; i < m_coordim; i++)
576  {
577  faceAaxis[i] =
578  (*m_faces[f]->GetVertex(1))[i] - (*m_faces[f]->GetVertex(0))[i];
579  faceBaxis[i] =
580  (*m_faces[f]->GetVertex(2))[i] - (*m_faces[f]->GetVertex(0))[i];
581 
582  elementAaxis_length += pow(elementAaxis[i], 2);
583  elementBaxis_length += pow(elementBaxis[i], 2);
584  faceAaxis_length += pow(faceAaxis[i], 2);
585  faceBaxis_length += pow(faceBaxis[i], 2);
586  }
587 
588  elementAaxis_length = sqrt(elementAaxis_length);
589  elementBaxis_length = sqrt(elementBaxis_length);
590  faceAaxis_length = sqrt(faceAaxis_length);
591  faceBaxis_length = sqrt(faceBaxis_length);
592 
593  // Calculate the inner product of both the A-axis
594  // (i.e. Elemental A axis and face A axis)
595  for (i = 0; i < m_coordim; i++)
596  {
597  dotproduct1 += elementAaxis[i] * faceAaxis[i];
598  }
599 
600  NekDouble norm = fabs(dotproduct1) / elementAaxis_length / faceAaxis_length;
601  orientation = 0;
602 
603  // if the innerproduct is equal to the (absolute value of the ) products
604  // of the lengths of both vectors, then, the coordinate systems will NOT
605  // be transposed
606  if (fabs(norm - 1.0) < NekConstants::kNekZeroTol)
607  {
608  // if the inner product is negative, both A-axis point
609  // in reverse direction
610  if (dotproduct1 < 0.0)
611  {
612  orientation += 2;
613  }
614 
615  // calculate the inner product of both B-axis
616  for (i = 0; i < m_coordim; i++)
617  {
618  dotproduct2 += elementBaxis[i] * faceBaxis[i];
619  }
620 
621  norm = fabs(dotproduct2) / elementBaxis_length / faceBaxis_length;
622 
623  // check that both these axis are indeed parallel
624  ASSERTL1(fabs(norm - 1.0) < NekConstants::kNekZeroTol,
625  "These vectors should be parallel");
626 
627  // if the inner product is negative, both B-axis point
628  // in reverse direction
629  if (dotproduct2 < 0.0)
630  {
631  orientation++;
632  }
633  }
634  // The coordinate systems are transposed
635  else
636  {
637  orientation = 4;
638 
639  // Calculate the inner product between the elemental A-axis
640  // and the B-axis of the face (which are now the corresponding axis)
641  dotproduct1 = 0.0;
642  for (i = 0; i < m_coordim; i++)
643  {
644  dotproduct1 += elementAaxis[i] * faceBaxis[i];
645  }
646 
647  norm = fabs(dotproduct1) / elementAaxis_length / faceBaxis_length;
648 
649  // check that both these axis are indeed parallel
650  ASSERTL1(fabs(norm - 1.0) < NekConstants::kNekZeroTol,
651  "These vectors should be parallel");
652 
653  // if the result is negative, both axis point in reverse
654  // directions
655  if (dotproduct1 < 0.0)
656  {
657  orientation += 2;
658  }
659 
660  // Do the same for the other two corresponding axis
661  dotproduct2 = 0.0;
662  for (i = 0; i < m_coordim; i++)
663  {
664  dotproduct2 += elementBaxis[i] * faceAaxis[i];
665  }
666 
667  norm = fabs(dotproduct2) / elementBaxis_length / faceAaxis_length;
668 
669  // check that both these axis are indeed parallel
670  ASSERTL1(fabs(norm - 1.0) < NekConstants::kNekZeroTol,
671  "These vectors should be parallel");
672 
673  if (dotproduct2 < 0.0)
674  {
675  orientation++;
676  }
677  }
678 
679  orientation = orientation + 5;
680 
681  // Fill the m_forient array
682  m_forient[f] = (StdRegions::Orientation)orientation;
683  }
684 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
static const int kNverts
Definition: TriGeom.h:74
static const int kNtfaces
Definition: TetGeom.h:57
static const int kNfaces
Definition: TetGeom.h:58
int GetGlobalID(void) const
Get the ID of this object.
Definition: Geometry.h:314
std::vector< StdRegions::Orientation > m_forient
Definition: Geometry3D.h:87
static const NekDouble kNekZeroTol
double NekDouble
static const int kNqfaces
Definition: TetGeom.h:56
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
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

◆ SetUpLocalEdges()

void Nektar::SpatialDomains::TetGeom::SetUpLocalEdges ( )
private

Definition at line 238 of file TetGeom.cpp.

References ASSERTL0, Nektar::SpatialDomains::Geometry::GetEdge(), Nektar::SpatialDomains::Geometry::GetEid(), Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry3D::m_edges, and Nektar::SpatialDomains::Geometry3D::m_faces.

Referenced by TetGeom().

239 {
240 
241  // find edge 0
242  int i, j;
243  unsigned int check;
244 
245  SegGeomSharedPtr edge;
246 
247  // First set up the 3 bottom edges
248 
249  if (m_faces[0]->GetEid(0) != m_faces[1]->GetEid(0))
250  {
251  std::ostringstream errstrm;
252  errstrm << "Local edge 0 (eid=" << m_faces[0]->GetEid(0);
253  errstrm << ") on face " << m_faces[0]->GetGlobalID();
254  errstrm << " must be the same as local edge 0 (eid="
255  << m_faces[1]->GetEid(0);
256  errstrm << ") on face " << m_faces[1]->GetGlobalID();
257  ASSERTL0(false, errstrm.str());
258  }
259 
260  int faceConnected;
261  for (faceConnected = 1; faceConnected < 4; faceConnected++)
262  {
263  check = 0;
264  for (i = 0; i < 3; i++)
265  {
266  if ((m_faces[0])->GetEid(i) == (m_faces[faceConnected])->GetEid(0))
267  {
268  edge = dynamic_pointer_cast<SegGeom>(
269  (m_faces[0])->GetEdge(i));
270  m_edges.push_back(edge);
271  check++;
272  }
273  }
274 
275  if (check < 1)
276  {
277  std::ostringstream errstrm;
278  errstrm << "Face 0 does not share an edge with first edge of "
279  "adjacent face. Faces ";
280  errstrm << (m_faces[0])->GetGlobalID() << ", "
281  << (m_faces[faceConnected])->GetGlobalID();
282  ASSERTL0(false, errstrm.str());
283  }
284  else if (check > 1)
285  {
286  std::ostringstream errstrm;
287  errstrm << "Connected faces share more than one edge. Faces ";
288  errstrm << (m_faces[0])->GetGlobalID() << ", "
289  << (m_faces[faceConnected])->GetGlobalID();
290  ASSERTL0(false, errstrm.str());
291  }
292  }
293 
294  // Then, set up the 3 vertical edges
295  check = 0;
296  for (i = 0; i < 3; i++) // Set up the vertical edge :face(1) and face(3)
297  {
298  for (j = 0; j < 3; j++)
299  {
300  if ((m_faces[1])->GetEid(i) == (m_faces[3])->GetEid(j))
301  {
302  edge = dynamic_pointer_cast<SegGeom>(
303  (m_faces[1])->GetEdge(i));
304  m_edges.push_back(edge);
305  check++;
306  }
307  }
308  }
309  if (check < 1)
310  {
311  std::ostringstream errstrm;
312  errstrm << "Connected faces do not share an edge. Faces ";
313  errstrm << (m_faces[1])->GetGlobalID() << ", "
314  << (m_faces[3])->GetGlobalID();
315  ASSERTL0(false, errstrm.str());
316  }
317  else if (check > 1)
318  {
319  std::ostringstream errstrm;
320  errstrm << "Connected faces share more than one edge. Faces ";
321  errstrm << (m_faces[1])->GetGlobalID() << ", "
322  << (m_faces[3])->GetGlobalID();
323  ASSERTL0(false, errstrm.str());
324  }
325  // Set up vertical edges: face(1) through face(3)
326  for (faceConnected = 1; faceConnected < 3; faceConnected++)
327  {
328  check = 0;
329  for (i = 0; i < 3; i++)
330  {
331  for (j = 0; j < 3; j++)
332  {
333  if ((m_faces[faceConnected])->GetEid(i) ==
334  (m_faces[faceConnected + 1])->GetEid(j))
335  {
336  edge = dynamic_pointer_cast<SegGeom>(
337  (m_faces[faceConnected])->GetEdge(i));
338  m_edges.push_back(edge);
339  check++;
340  }
341  }
342  }
343 
344  if (check < 1)
345  {
346  std::ostringstream errstrm;
347  errstrm << "Connected faces do not share an edge. Faces ";
348  errstrm << (m_faces[faceConnected])->GetGlobalID() << ", "
349  << (m_faces[faceConnected + 1])->GetGlobalID();
350  ASSERTL0(false, errstrm.str());
351  }
352  else if (check > 1)
353  {
354  std::ostringstream errstrm;
355  errstrm << "Connected faces share more than one edge. Faces ";
356  errstrm << (m_faces[faceConnected])->GetGlobalID() << ", "
357  << (m_faces[faceConnected + 1])->GetGlobalID();
358  ASSERTL0(false, errstrm.str());
359  }
360  }
361 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
int GetEid(int i) const
Get the ID of edge i of this object.
Definition: Geometry.cpp:145
int GetGlobalID(void) const
Get the ID of this object.
Definition: Geometry.h:314
Geometry1DSharedPtr GetEdge(int i) const
Returns edge i of this object.
Definition: Geometry.h:351
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62

◆ SetUpLocalVertices()

void Nektar::SpatialDomains::TetGeom::SetUpLocalVertices ( )
private

Definition at line 363 of file TetGeom.cpp.

References ASSERTL0, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetVertex(), Nektar::SpatialDomains::Geometry::GetVid(), Nektar::SpatialDomains::Geometry3D::m_edges, and Nektar::SpatialDomains::Geometry3D::m_verts.

Referenced by TetGeom().

364 {
365 
366  // Set up the first 2 vertices (i.e. vertex 0,1)
367  if ((m_edges[0]->GetVid(0) == m_edges[1]->GetVid(0)) ||
368  (m_edges[0]->GetVid(0) == m_edges[1]->GetVid(1)))
369  {
370  m_verts.push_back(m_edges[0]->GetVertex(1));
371  m_verts.push_back(m_edges[0]->GetVertex(0));
372  }
373  else if ((m_edges[0]->GetVid(1) == m_edges[1]->GetVid(0)) ||
374  (m_edges[0]->GetVid(1) == m_edges[1]->GetVid(1)))
375  {
376  m_verts.push_back(m_edges[0]->GetVertex(0));
377  m_verts.push_back(m_edges[0]->GetVertex(1));
378  }
379  else
380  {
381  std::ostringstream errstrm;
382  errstrm << "Connected edges do not share a vertex. Edges ";
383  errstrm << m_edges[0]->GetGlobalID() << ", "
384  << m_edges[1]->GetGlobalID();
385  ASSERTL0(false, errstrm.str());
386  }
387 
388  // set up the other bottom vertices (i.e. vertex 2)
389  for (int i = 1; i < 2; i++)
390  {
391  if (m_edges[i]->GetVid(0) == m_verts[i]->GetGlobalID())
392  {
393  m_verts.push_back(m_edges[i]->GetVertex(1));
394  }
395  else if (m_edges[i]->GetVid(1) == m_verts[i]->GetGlobalID())
396  {
397  m_verts.push_back(m_edges[i]->GetVertex(0));
398  }
399  else
400  {
401  std::ostringstream errstrm;
402  errstrm << "Connected edges do not share a vertex. Edges ";
403  errstrm << m_edges[i]->GetGlobalID() << ", "
404  << m_edges[i - 1]->GetGlobalID();
405  ASSERTL0(false, errstrm.str());
406  }
407  }
408 
409  // set up top vertex
410  if (m_edges[3]->GetVid(0) == m_verts[0]->GetGlobalID())
411  {
412  m_verts.push_back(m_edges[3]->GetVertex(1));
413  }
414  else
415  {
416  m_verts.push_back(m_edges[3]->GetVertex(0));
417  }
418 
419  // Check the other edges match up.
420  int check = 0;
421  for (int i = 4; i < 6; ++i)
422  {
423  if ((m_edges[i]->GetVid(0) == m_verts[i - 3]->GetGlobalID() &&
424  m_edges[i]->GetVid(1) == m_verts[3]->GetGlobalID()) ||
425  (m_edges[i]->GetVid(1) == m_verts[i - 3]->GetGlobalID() &&
426  m_edges[i]->GetVid(0) == m_verts[3]->GetGlobalID()))
427  {
428  check++;
429  }
430  }
431  if (check != 2)
432  {
433  std::ostringstream errstrm;
434  errstrm << "Connected edges do not share a vertex. Edges ";
435  errstrm << m_edges[3]->GetGlobalID() << ", "
436  << m_edges[2]->GetGlobalID();
437  ASSERTL0(false, errstrm.str());
438  }
439 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
int GetGlobalID(void) const
Get the ID of this object.
Definition: Geometry.h:314
int GetVid(int i) const
Get the ID of vertex i of this object.
Definition: Geometry.cpp:137
PointGeomSharedPtr GetVertex(int i) const
Returns vertex i of this object.
Definition: Geometry.h:343

◆ SetUpXmap()

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

Set up the m_xmap object by determining the order of each direction from derived faces.

Definition at line 747 of file TetGeom.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eGaussRadauMAlpha1Beta0, Nektar::LibUtilities::eGaussRadauMAlpha2Beta0, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eModified_C, Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::SpatialDomains::Geometry3D::m_faces, and Nektar::SpatialDomains::Geometry::m_xmap.

Referenced by v_Setup().

748 {
749  vector<int> tmp;
750  tmp.push_back(m_faces[0]->GetXmap()->GetEdgeNcoeffs(0));
751  int order0 = *max_element(tmp.begin(), tmp.end());
752 
753  tmp.clear();
754  tmp.push_back(order0);
755  tmp.push_back(m_faces[0]->GetXmap()->GetEdgeNcoeffs(1));
756  tmp.push_back(m_faces[0]->GetXmap()->GetEdgeNcoeffs(2));
757  int order1 = *max_element(tmp.begin(), tmp.end());
758 
759  tmp.clear();
760  tmp.push_back(order0);
761  tmp.push_back(order1);
762  tmp.push_back(m_faces[1]->GetXmap()->GetEdgeNcoeffs(1));
763  tmp.push_back(m_faces[1]->GetXmap()->GetEdgeNcoeffs(2));
764  tmp.push_back(m_faces[3]->GetXmap()->GetEdgeNcoeffs(1));
765  int order2 = *max_element(tmp.begin(), tmp.end());
766 
767  const LibUtilities::BasisKey A(
769  order0,
770  LibUtilities::PointsKey(order0+1, LibUtilities::eGaussLobattoLegendre));
771  const LibUtilities::BasisKey B(
773  order1,
774  LibUtilities::PointsKey(order1,
776  const LibUtilities::BasisKey C(
778  order2,
779  LibUtilities::PointsKey(order2,
781 
783 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
Principle Modified Functions .
Definition: BasisType.h:50
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.
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:59
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51

◆ v_ContainsPoint()

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

Determines if a point specified in global coordinates is located within this tetrahedral geometry and return local caretsian coordinates.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 87 of file TetGeom.cpp.

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

91 {
92  //Rough check if within twice min/max point
93  if (GetMetricInfo()->GetGtype() != eRegular)
94  {
95  if (!MinMaxCheck(gloCoord))
96  {
97  return false;
98  }
99  }
100 
101  // Convert to the local (eta) coordinates.
102  resid = GetLocCoords(gloCoord, locCoord);
103 
104  // Check local coordinate is within cartesian bounds.
105  if (locCoord[0] >= -(1 + tol) && locCoord[1] >= -(1 + tol) &&
106  locCoord[2] >= -(1 + tol) &&
107  locCoord[0] + locCoord[1] + locCoord[2] <= -1 + tol)
108  {
109  return true;
110  }
111 
112  //Clamp local coords
113  ClampLocCoords(locCoord, tol);
114 
115  return false;
116 }
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_GenGeomFactors()

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

Generate the geometry factors for this element.

Implements Nektar::SpatialDomains::Geometry.

Definition at line 713 of file TetGeom.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, Nektar::SpatialDomains::Geometry3D::v_FillGeom(), and v_Setup().

714 {
715  if(!m_setupState)
716  {
718  }
719 
721  {
722  GeomType Gtype = eRegular;
723 
724  v_FillGeom();
725 
726  // check to see if expansions are linear
727  for (int i = 0; i < m_coordim; ++i)
728  {
729  if (m_xmap->GetBasisNumModes(0) != 2 ||
730  m_xmap->GetBasisNumModes(1) != 2 ||
731  m_xmap->GetBasisNumModes(2) != 2)
732  {
733  Gtype = eDeformed;
734  }
735  }
736 
738  Gtype, m_coordim, m_xmap, m_coeffs);
740  }
741 }
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
virtual void v_FillGeom()
Put all quadrature information into face/edge structure and backward transform.
Definition: Geometry3D.cpp:235
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_GetDir()

int Nektar::SpatialDomains::TetGeom::v_GetDir ( const int  faceidx,
const int  facedir 
) const
protectedvirtual

Implements Nektar::SpatialDomains::Geometry3D.

Definition at line 207 of file TetGeom.cpp.

208 {
209  if (faceidx == 0)
210  {
211  return facedir;
212  }
213  else if (faceidx == 1)
214  {
215  return 2 * facedir;
216  }
217  else
218  {
219  return 1 + facedir;
220  }
221 }

◆ v_GetEdgeFaceMap()

int Nektar::SpatialDomains::TetGeom::v_GetEdgeFaceMap ( const int  i,
const int  j 
) const
protectedvirtual

Returns the standard element edge IDs that are connected to a given face.

For example, on a prism, edge 0 is connnected to faces 0 and 1; GetEdgeFaceMap(0,j) would therefore return the values 0 and 1 respectively. We assume that j runs between 0 and 1 inclusive, since every face is connected to precisely two faces for all 3D elements.

This function is used in the construction of the low-energy preconditioner.

Parameters
iThe edge to query connectivity for.
jThe local face index between 0 and 1 connected to this element.
See also
MultiRegions::PreconditionerLowEnergy

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 233 of file TetGeom.cpp.

References EdgeFaceConnectivity.

234 {
235  return EdgeFaceConnectivity[i][j];
236 }
static const unsigned int EdgeFaceConnectivity[6][2]
Definition: TetGeom.h:85

◆ v_GetLocCoords()

NekDouble Nektar::SpatialDomains::TetGeom::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 118 of file TetGeom.cpp.

References Nektar::SpatialDomains::PointGeom::dist(), 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::Geometry3D::m_verts, Nektar::SpatialDomains::Geometry::m_xmap, Nektar::SpatialDomains::PointGeom::Mult(), Nektar::SpatialDomains::Geometry3D::NewtonIterationForLocCoord(), Vmath::Sadd(), Nektar::SpatialDomains::PointGeom::Sub(), Nektar::SpatialDomains::Geometry3D::v_FillGeom(), Vmath::Vmul(), and Vmath::Vvtvp().

120 {
121  NekDouble ptdist = 1e6;
122 
123  // calculate local coordinates (eta) for coord
124  if (GetMetricInfo()->GetGtype() == eRegular)
125  {
126  // Point inside tetrahedron
127  PointGeom r(m_coordim, 0, coords[0], coords[1], coords[2]);
128 
129  // Edges
130  PointGeom er0, e10, e20, e30;
131  er0.Sub(r, *m_verts[0]);
132  e10.Sub(*m_verts[1], *m_verts[0]);
133  e20.Sub(*m_verts[2], *m_verts[0]);
134  e30.Sub(*m_verts[3], *m_verts[0]);
135 
136  // Cross products (Normal times area)
137  PointGeom cp1020, cp2030, cp3010;
138  cp1020.Mult(e10, e20);
139  cp2030.Mult(e20, e30);
140  cp3010.Mult(e30, e10);
141 
142  // Barycentric coordinates (relative volume)
143  NekDouble V = e30.dot(cp1020); // Tet Volume={(e30)dot(e10)x(e20)}/6
144  NekDouble beta = er0.dot(cp2030) / V; // volume1={(er0)dot(e20)x(e30)}/6
145  NekDouble gamma = er0.dot(cp3010) / V; // volume1={(er0)dot(e30)x(e10)}/6
146  NekDouble delta = er0.dot(cp1020) / V; // volume1={(er0)dot(e10)x(e20)}/6
147 
148  // Make tet bigger
149  Lcoords[0] = 2.0 * beta - 1.0;
150  Lcoords[1] = 2.0 * gamma - 1.0;
151  Lcoords[2] = 2.0 * delta - 1.0;
152 
153  // Set ptdist to distance to nearest vertex
154  for (int i = 0; i < 4; ++i)
155  {
156  ptdist = min(ptdist, r.dist(*m_verts[i]));
157  }
158  }
159  else
160  {
161  v_FillGeom();
162 
163  // Determine nearest point of coords to values in m_xmap
164  int npts = m_xmap->GetTotPoints();
165  Array<OneD, NekDouble> ptsx(npts), ptsy(npts), ptsz(npts);
166  Array<OneD, NekDouble> tmp1(npts), tmp2(npts);
167 
168  m_xmap->BwdTrans(m_coeffs[0], ptsx);
169  m_xmap->BwdTrans(m_coeffs[1], ptsy);
170  m_xmap->BwdTrans(m_coeffs[2], ptsz);
171 
172  const Array<OneD, const NekDouble> za = m_xmap->GetPoints(0);
173  const Array<OneD, const NekDouble> zb = m_xmap->GetPoints(1);
174  const Array<OneD, const NekDouble> zc = m_xmap->GetPoints(2);
175 
176  // guess the first local coords based on nearest point
177  Vmath::Sadd(npts, -coords[0], ptsx, 1, tmp1, 1);
178  Vmath::Vmul(npts, tmp1, 1, tmp1, 1, tmp1, 1);
179  Vmath::Sadd(npts, -coords[1], ptsy, 1, tmp2, 1);
180  Vmath::Vvtvp(npts, tmp2, 1, tmp2, 1, tmp1, 1, tmp1, 1);
181  Vmath::Sadd(npts, -coords[2], ptsz, 1, tmp2, 1);
182  Vmath::Vvtvp(npts, tmp2, 1, tmp2, 1, tmp1, 1, tmp1, 1);
183 
184  int min_i = Vmath::Imin(npts, tmp1, 1);
185 
186  // distance from coordinate to nearest point for return value.
187  ptdist = sqrt(tmp1[min_i]);
188 
189  // Get collapsed coordinate
190  int qa = za.num_elements(), qb = zb.num_elements();
191  Lcoords[2] = zc[min_i / (qa * qb)];
192  min_i = min_i % (qa * qb);
193  Lcoords[1] = zb[min_i / qa];
194  Lcoords[0] = za[min_i % qa];
195 
196  // recover cartesian coordinate from collapsed coordinate.
197  Lcoords[1] = (1.0 + Lcoords[0]) * (1.0 - Lcoords[2]) / 2 - 1.0;
198  Lcoords[0] = (1.0 + Lcoords[0]) * (-Lcoords[1] - Lcoords[2]) / 2 - 1.0;
199 
200  // Perform newton iteration to find local coordinates
201  NekDouble resid = 0.0;
202  NewtonIterationForLocCoord(coords, ptsx, ptsy, ptsz, Lcoords, resid);
203  }
204  return ptdist;
205 }
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, const Array< OneD, const NekDouble > &ptsz, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
Definition: Geometry3D.cpp:81
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
virtual void v_FillGeom()
Put all quadrature information into face/edge structure and backward transform.
Definition: Geometry3D.cpp:235
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_GetVertexEdgeMap()

int Nektar::SpatialDomains::TetGeom::v_GetVertexEdgeMap ( const int  i,
const int  j 
) const
protectedvirtual

Returns the standard element edge IDs that are connected to a given vertex.

For example, on a prism, vertex 0 is connnected to edges 0, 3, and 4; GetVertexEdgeMap(0,j) would therefore return the values 0, 1 and 4 respectively. We assume that j runs between 0 and 2 inclusive, which is true for every 3D element asides from the pyramid.

This function is used in the construction of the low-energy preconditioner.

Parameters
iThe vertex to query connectivity for.
jThe local edge index between 0 and 2 connected to this element.
Todo:
Expand to work with pyramid elements.
See also
MultiRegions::PreconditionerLowEnergy

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 223 of file TetGeom.cpp.

References VertexEdgeConnectivity.

224 {
225  return VertexEdgeConnectivity[i][j];
226 }
static const unsigned int VertexEdgeConnectivity[4][3]
Definition: TetGeom.h:83

◆ v_GetVertexFaceMap()

int Nektar::SpatialDomains::TetGeom::v_GetVertexFaceMap ( const int  i,
const int  j 
) const
protectedvirtual

Returns the standard element face IDs that are connected to a given vertex.

For example, on a hexahedron, vertex 0 is connnected to faces 0, 1, and 4; GetVertexFaceMap(0,j) would therefore return the values 0, 1 and 4 respectively. We assume that j runs between 0 and 2 inclusive, which is true for every 3D element asides from the pyramid.

This is used in the construction of the low-energy preconditioner.

Parameters
iThe vertex to query connectivity for.
jThe local face index between 0 and 2 connected to this element.
Todo:
Expand to work with pyramid elements.
See also
MultiRegions::PreconditionerLowEnergy

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 228 of file TetGeom.cpp.

References VertexFaceConnectivity.

229 {
230  return VertexFaceConnectivity[i][j];
231 }
static const unsigned int VertexFaceConnectivity[4][3]
Definition: TetGeom.h:84

◆ v_Reset()

void Nektar::SpatialDomains::TetGeom::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 686 of file TetGeom.cpp.

References Nektar::SpatialDomains::Geometry3D::m_faces, and Nektar::SpatialDomains::Geometry::v_Reset().

687 {
688  Geometry::v_Reset(curvedEdges, curvedFaces);
689 
690  for (int i = 0; i < 4; ++i)
691  {
692  m_faces[i]->Reset(curvedEdges, curvedFaces);
693  }
694 }
virtual void v_Reset(CurveMap &curvedEdges, CurveMap &curvedFaces)
Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated Geo...
Definition: Geometry.cpp:335

◆ v_Setup()

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 696 of file TetGeom.cpp.

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

Referenced by v_GenGeomFactors().

697 {
698  if(!m_setupState)
699  {
700  for (int i = 0; i < 4; ++i)
701  {
702  m_faces[i]->Setup();
703  }
704  SetUpXmap();
705  SetUpCoeffs(m_xmap->GetNcoeffs());
706  m_setupState = true;
707  }
708 }
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
void SetUpXmap()
Set up the m_xmap object by determining the order of each direction from derived faces.
Definition: TetGeom.cpp:747
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

◆ EdgeFaceConnectivity

const unsigned int Nektar::SpatialDomains::TetGeom::EdgeFaceConnectivity
staticprivate
Initial value:
= {
{0, 1}, {0, 2}, {0, 3}, {1, 3}, {1, 2}, {2, 3}}

Definition at line 85 of file TetGeom.h.

Referenced by v_GetEdgeFaceMap().

◆ kNedges

const int Nektar::SpatialDomains::TetGeom::kNedges = 6
static

Definition at line 55 of file TetGeom.h.

Referenced by SetUpEdgeOrientation(), and TetGeom().

◆ kNfaces

const int Nektar::SpatialDomains::TetGeom::kNfaces = kNqfaces + kNtfaces
static

Definition at line 58 of file TetGeom.h.

Referenced by SetUpFaceOrientation(), and TetGeom().

◆ kNqfaces

const int Nektar::SpatialDomains::TetGeom::kNqfaces = 0
static

Definition at line 56 of file TetGeom.h.

Referenced by SetUpFaceOrientation().

◆ kNtfaces

const int Nektar::SpatialDomains::TetGeom::kNtfaces = 4
static

Definition at line 57 of file TetGeom.h.

Referenced by SetUpFaceOrientation().

◆ kNverts

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

Definition at line 54 of file TetGeom.h.

◆ VertexEdgeConnectivity

const unsigned int Nektar::SpatialDomains::TetGeom::VertexEdgeConnectivity
staticprivate
Initial value:
= {
{0, 2, 3}, {0, 1, 4}, {1, 2, 5}, {3, 4, 5}}

Definition at line 83 of file TetGeom.h.

Referenced by v_GetVertexEdgeMap().

◆ VertexFaceConnectivity

const unsigned int Nektar::SpatialDomains::TetGeom::VertexFaceConnectivity
staticprivate
Initial value:
= {
{0, 1, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}}

Definition at line 84 of file TetGeom.h.

Referenced by v_GetVertexFaceMap().

◆ XMLElementType

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

Definition at line 59 of file TetGeom.h.