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

#include <SegGeom.h>

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

Public Member Functions

 SegGeom ()
 
 SegGeom (int id, const int coordim, const PointGeomSharedPtr vertex[], const CurveSharedPtr curve=CurveSharedPtr())
 
 SegGeom (const SegGeom &in)
 
SegGeomSharedPtr GenerateOneSpaceDimGeom (void)
 Generate a one dimensional space segment geometry where the vert[0] has the same x value and vert[1] is set to vert[0] plus the length of the original segment. More...
 
 ~SegGeom () override=default
 
CurveSharedPtr GetCurve ()
 
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry1D
 Geometry1D ()
 
 Geometry1D (const int coordim)
 
 ~Geometry1D () override=default
 
- 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
 
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...
 
void ClearBoundingBox ()
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\). 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 &dist)
 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...
 
int PreliminaryCheck (const Array< OneD, const NekDouble > &gloCoord)
 A fast and robust check if a given global coord is outside of a deformed element. For regular elements, this check is unnecessary. More...
 
bool MinMaxCheck (const Array< OneD, const NekDouble > &gloCoord)
 Check if given global coord is within the BoundingBox of the element. More...
 
bool ClampLocCoords (Array< OneD, NekDouble > &locCoord, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
 Clamp local coords to be within standard regions [-1, 1]^dim. More...
 
NekDouble FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
 
int GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex. 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...
 
int GetEdgeNormalToFaceVert (int i, int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex. More...
 
int GetDir (const int i, const int j=0) const
 Returns the element coordinate direction corresponding to a given face coordinate direction. 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 ResetNonRecursive (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object non-recursively: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors. More...
 
void Setup ()
 
void GenGeomFactors ()
 Handles generation of geometry factors. More...
 

Static Public Member Functions

static StdRegions::Orientation GetEdgeOrientation (const SegGeom &edge1, const SegGeom &edge2)
 Get the orientation of edge1. More...
 

Static Public Attributes

static const int kNverts = 2
 
- Static Public Attributes inherited from Nektar::SpatialDomains::Geometry1D
static const int kDim = 1
 

Protected Member Functions

PointGeomSharedPtr v_GetVertex (const int i) const override
 
virtual LibUtilities::ShapeType v_GetShapeType () const
 
void v_GenGeomFactors () override
 
void v_FillGeom () override
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements. More...
 
void v_Reset (CurveMap &curvedEdges, CurveMap &curvedFaces) override
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors. More...
 
void v_Setup () override
 
NekDouble v_GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord) override
 Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i. More...
 
int v_GetNumVerts () const override
 Get the number of vertices of this object. More...
 
NekDouble v_FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) override
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry1D
int v_GetShapeDim () const override
 Get the object's shape dimension. More...
 
NekDouble v_GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
 Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this geometry object. More...
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
virtual PointGeomSharedPtr v_GetVertex (int i) const =0
 
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...
 
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 int v_GetShapeDim () const
 Get the object's shape dimension. 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 void v_FillGeom ()
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements. More...
 
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\). More...
 
virtual int v_AllLeftCheck (const Array< OneD, const NekDouble > &gloCoord)
 
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 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 NekDouble v_FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
 
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...
 
virtual int v_GetEdgeNormalToFaceVert (const int i, const int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex. More...
 
virtual int v_GetDir (const int faceidx, const int facedir) const
 Returns the element coordinate direction corresponding to a given face coordinate direction. More...
 
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 ()=0
 
void SetUpCoeffs (const int nCoeffs)
 Initialise the Geometry::m_coeffs array. More...
 
virtual void v_CalculateInverseIsoParam ()
 

Protected Attributes

SpatialDomains::PointGeomSharedPtr m_verts [kNverts]
 
StdRegions::Orientation m_porient [kNverts]
 
- 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...
 
Array< OneD, NekDoublem_boundingBox
 Array containing bounding box. More...
 
Array< OneD, Array< OneD, NekDouble > > m_isoParameter
 
Array< OneD, Array< OneD, NekDouble > > m_invIsoParam
 
int m_straightEdge
 

Private Member Functions

void SetUpXmap ()
 

Private Attributes

CurveSharedPtr m_curve
 Boolean indicating whether object owns the data. More...
 

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...
 
- Static Protected Attributes inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsVector m_regGeomFactorsManager
 

Detailed Description

Definition at line 52 of file SegGeom.h.

Constructor & Destructor Documentation

◆ SegGeom() [1/3]

Nektar::SpatialDomains::SegGeom::SegGeom ( )

Definition at line 45 of file SegGeom.cpp.

46{
48}
LibUtilities::ShapeType m_shapeType
Type of shape.
Definition: Geometry.h:202

References Nektar::LibUtilities::eSegment, and Nektar::SpatialDomains::Geometry::m_shapeType.

◆ SegGeom() [2/3]

Nektar::SpatialDomains::SegGeom::SegGeom ( int  id,
const int  coordim,
const PointGeomSharedPtr  vertex[],
const CurveSharedPtr  curve = CurveSharedPtr() 
)

Definition at line 50 of file SegGeom.cpp.

52 : Geometry1D(coordim)
53{
55 m_globalID = id;
57 m_curve = curve;
58
59 m_verts[0] = vertex[0];
60 m_verts[1] = vertex[1];
61}
GeomState m_state
Enumeration to dictate whether coefficients are filled.
Definition: Geometry.h:196
CurveSharedPtr m_curve
Boolean indicating whether object owns the data.
Definition: SegGeom.h:94
SpatialDomains::PointGeomSharedPtr m_verts[kNverts]
Definition: SegGeom.h:77
@ eNotFilled
Geometric information has not been generated.

References Nektar::SpatialDomains::eNotFilled, Nektar::LibUtilities::eSegment, m_curve, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_shapeType, Nektar::SpatialDomains::Geometry::m_state, and m_verts.

◆ SegGeom() [3/3]

Nektar::SpatialDomains::SegGeom::SegGeom ( const SegGeom in)

Definition at line 63 of file SegGeom.cpp.

63 : Geometry1D(in)
64{
65 // From Geometry class
66 m_shapeType = in.m_shapeType;
67
68 // info from EdgeComponent class
69 m_globalID = in.m_globalID;
70 m_xmap = in.m_xmap;
71 SetUpCoeffs(m_xmap->GetNcoeffs());
72
73 // info from SegGeom class
74 m_coordim = in.m_coordim;
75 m_verts[0] = in.m_verts[0];
76 m_verts[1] = in.m_verts[1];
77
78 m_state = in.m_state;
79}
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition: Geometry.h:700
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:194
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:188

References Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_shapeType, Nektar::SpatialDomains::Geometry::m_state, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, and Nektar::SpatialDomains::Geometry::SetUpCoeffs().

◆ ~SegGeom()

Nektar::SpatialDomains::SegGeom::~SegGeom ( )
overridedefault

Member Function Documentation

◆ GenerateOneSpaceDimGeom()

SegGeomSharedPtr Nektar::SpatialDomains::SegGeom::GenerateOneSpaceDimGeom ( void  )

Generate a one dimensional space segment geometry where the vert[0] has the same x value and vert[1] is set to vert[0] plus the length of the original segment.

Definition at line 105 of file SegGeom.cpp.

106{
108
109 // info about numbering
110 returnval->m_globalID = m_globalID;
111
112 // geometric information.
113 returnval->m_coordim = 1;
114 NekDouble x0 = (*m_verts[0])[0];
116 1, m_verts[0]->GetGlobalID(), x0, 0.0, 0.0);
117 vert0->SetGlobalID(vert0->GetGlobalID());
118 returnval->m_verts[0] = vert0;
119
120 // Get information to calculate length.
121 const Array<OneD, const LibUtilities::BasisSharedPtr> base =
122 m_xmap->GetBase();
124 v.push_back(base[0]->GetPointsKey());
126
127 const Array<OneD, const NekDouble> jac = m_geomFactors->GetJac(v);
128
129 NekDouble len = 0.0;
130 if (jac.size() == 1)
131 {
132 len = jac[0] * 2.0;
133 }
134 else
135 {
136 Array<OneD, const NekDouble> w0 = base[0]->GetW();
137 len = 0.0;
138
139 for (int i = 0; i < jac.size(); ++i)
140 {
141 len += jac[i] * w0[i];
142 }
143 }
144 // Set up second vertex.
146 1, m_verts[1]->GetGlobalID(), x0 + len, 0.0, 0.0);
147 vert1->SetGlobalID(vert1->GetGlobalID());
148
149 returnval->m_verts[1] = vert1;
150
151 // at present just use previous m_xmap[0];
152 returnval->m_xmap = m_xmap;
153 returnval->SetUpCoeffs(m_xmap->GetNcoeffs());
154 returnval->m_state = eNotFilled;
155
156 return returnval;
157}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
int GetGlobalID(void) const
Get the ID of this object.
Definition: Geometry.h:326
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
Definition: Geometry.h:190
void v_GenGeomFactors() override
Definition: SegGeom.cpp:214
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:231
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:58
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:57
double NekDouble

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::eNotFilled, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::m_geomFactors, Nektar::SpatialDomains::Geometry::m_globalID, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, and v_GenGeomFactors().

◆ GetCurve()

CurveSharedPtr Nektar::SpatialDomains::SegGeom::GetCurve ( )
inline

Definition at line 69 of file SegGeom.h.

70 {
71 return m_curve;
72 }

References m_curve.

◆ GetEdgeOrientation()

StdRegions::Orientation Nektar::SpatialDomains::SegGeom::GetEdgeOrientation ( const SegGeom edge1,
const SegGeom edge2 
)
static

Get the orientation of edge1.

If edge1 is connected to edge2 in the same direction as the points comprising edge1 then it is forward, otherwise it is backward.

For example, assume edge1 is comprised of points 1 and 2, and edge2 is comprised of points 2 and 3, then edge1 is forward.

If edge1 is comprised of points 2 and 1 and edge2 is comprised of points 3 and 2, then edge1 is backward.

Since both edges are passed, it does not need any information from the EdgeComponent instance.

Definition at line 190 of file SegGeom.cpp.

192{
194
195 if ((*edge1.GetVertex(0) == *edge2.GetVertex(0)) ||
196 (*edge1.GetVertex(0) == *edge2.GetVertex(1)))
197 {
198 // Backward direction. Vertex 0 is connected to edge 2.
199 returnval = StdRegions::eBackwards;
200 }
201 else if ((*edge1.GetVertex(1) != *edge2.GetVertex(0)) &&
202 (*edge1.GetVertex(1) != *edge2.GetVertex(1)))
203 {
204 // Not forward either, then we have a problem.
205 std::ostringstream errstrm;
206 errstrm << "Connected edges do not share a vertex. Edges ";
207 errstrm << edge1.GetGlobalID() << ", " << edge2.GetGlobalID();
208 ASSERTL0(false, errstrm.str());
209 }
210
211 return returnval;
212}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::SpatialDomains::Geometry::GetGlobalID(), and Nektar::SpatialDomains::Geometry::GetVertex().

Referenced by Nektar::SpatialDomains::QuadGeom::QuadGeom(), and Nektar::SpatialDomains::TriGeom::TriGeom().

◆ SetUpXmap()

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

Definition at line 81 of file SegGeom.cpp.

82{
83 if (m_curve)
84 {
85 int npts = m_curve->m_points.size();
86 LibUtilities::PointsKey pkey(npts + 1,
88 const LibUtilities::BasisKey B(LibUtilities::eModified_A, npts, pkey);
90 }
91 else
92 {
93 const LibUtilities::BasisKey B(
95 LibUtilities::PointsKey(2, LibUtilities::eGaussLobattoLegendre));
97 }
98}
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:48

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

Referenced by v_Reset(), and v_Setup().

◆ v_FillGeom()

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

Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.

See also
v_FillGeom()

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 237 of file SegGeom.cpp.

238{
239 if (m_state != ePtsFilled)
240 {
241 int i;
242
243 if (m_coordim > 0 && m_curve)
244 {
245 int npts = m_curve->m_points.size();
246 LibUtilities::PointsKey pkey(npts + 1,
248 Array<OneD, NekDouble> tmp(npts);
249
250 if (m_verts[0]->dist(*(m_curve->m_points[0])) >
252 {
253 std::string err =
254 "Vertex 0 is separated from first point by more than ";
255 std::stringstream strstrm;
256 strstrm << NekConstants::kVertexTheSameDouble << " in edge "
257 << m_globalID;
258 err += strstrm.str();
259 NEKERROR(ErrorUtil::ewarning, err.c_str());
260 }
261
262 if (m_verts[1]->dist(*(m_curve->m_points[npts - 1])) >
264 {
265 std::string err =
266 "Vertex 1 is separated from last point by more than ";
267 std::stringstream strstrm;
268 strstrm << NekConstants::kVertexTheSameDouble << " in edge "
269 << m_globalID;
270 err += strstrm.str();
271 NEKERROR(ErrorUtil::ewarning, err.c_str());
272 }
273
274 LibUtilities::PointsKey fkey(npts, m_curve->m_ptype);
276 LibUtilities::PointsManager()[fkey]->GetI(pkey);
277 NekVector<NekDouble> out(npts + 1);
278
279 for (int i = 0; i < m_coordim; ++i)
280 {
281 // Load up coordinate values into tmp
282 for (int j = 0; j < npts; ++j)
283 {
284 tmp[j] = (m_curve->m_points[j]->GetPtr())[i];
285 }
286
287 // Interpolate to GLL points
288 NekVector<NekDouble> in(npts, tmp, eWrapper);
289 out = (*I0) * in;
290
291 m_xmap->FwdTrans(out.GetPtr(), m_coeffs[i]);
292 }
293 }
294
295 for (i = 0; i < m_coordim; ++i)
296 {
297 m_coeffs[i][0] = (*m_verts[0])[i];
298 m_coeffs[i][1] = (*m_verts[1])[i];
299 }
300
302 }
303}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:206
PointsManagerT & PointsManager(void)
static const NekDouble kVertexTheSameDouble
@ ePtsFilled
Geometric information has been generated.
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75

References Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::SpatialDomains::ePtsFilled, Nektar::ErrorUtil::ewarning, Nektar::eWrapper, Nektar::NekVector< DataType >::GetPtr(), Nektar::NekConstants::kVertexTheSameDouble, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_coordim, m_curve, Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::Geometry::m_state, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, NEKERROR, and Nektar::LibUtilities::PointsManager().

Referenced by v_GenGeomFactors().

◆ v_FindDistance()

NekDouble Nektar::SpatialDomains::SegGeom::v_FindDistance ( const Array< OneD, const NekDouble > &  xs,
Array< OneD, NekDouble > &  xi 
)
overrideprotectedvirtual

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 346 of file SegGeom.cpp.

348{
349 if (m_geomFactors->GetGtype() == eRegular)
350 {
351 xiOut = Array<OneD, NekDouble>(1, 0.0);
352
353 GetLocCoords(xs, xiOut);
354 ClampLocCoords(xiOut);
355
356 Array<OneD, NekDouble> gloCoord(m_coordim);
357 NekDouble tmp = 0;
358 for (int i = 0; i < m_coordim; ++i)
359 {
360 gloCoord[i] = GetCoord(i, xiOut);
361 tmp += (xs[i] - gloCoord[i]) * (xs[i] - gloCoord[i]);
362 }
363
364 return sqrt(tmp);
365 }
366 // If deformed edge then the inverse mapping is non-linear so need to
367 // numerically solve for the local coordinate
368 else if (m_geomFactors->GetGtype() == eDeformed)
369 {
370 Array<OneD, NekDouble> xi(1, 0.0);
371
372 // Armijo constants:
373 // https://en.wikipedia.org/wiki/Backtracking_line_search
374 const NekDouble c1 = 1e-4, c2 = 0.9;
375
376 int dim = GetCoordim();
377 int nq = m_xmap->GetTotPoints();
378
379 Array<OneD, Array<OneD, NekDouble>> x(dim), xder(dim), xder2(dim);
380 // Get x,y,z phys values from coefficients
381 for (int i = 0; i < dim; ++i)
382 {
383 x[i] = Array<OneD, NekDouble>(nq);
384 xder[i] = Array<OneD, NekDouble>(nq);
385 xder2[i] = Array<OneD, NekDouble>(nq);
386
387 m_xmap->BwdTrans(m_coeffs[i], x[i]);
388 }
389
390 NekDouble fx_prev = std::numeric_limits<NekDouble>::max();
391
392 // Minimisation loop (Quasi-newton method)
393 for (int i = 0; i < NekConstants::kNewtonIterations; ++i)
394 {
395 // Compute the objective function, f(x_k) and its derivatives
396 Array<OneD, NekDouble> xc(dim);
397 Array<OneD, std::array<NekDouble, 3>> xc_der(dim);
398 Array<OneD, std::array<NekDouble, 6>> xc_der2(dim);
399 NekDouble fx = 0, fxp = 0, fxp2 = 0, xcDiff = 0;
400 for (int j = 0; j < dim; ++j)
401 {
402 xc[j] = m_xmap->PhysEvaluate(xi, x[j], xc_der[j], xc_der2[j]);
403
404 xcDiff = xc[j] - xs[j];
405 // Objective function is the distance to the search point
406 fx += xcDiff * xcDiff;
407 fxp += xc_der[j][0] * xcDiff;
408 fxp2 += xc_der2[j][0] * xcDiff + xc_der[j][0] * xc_der[j][0];
409 }
410
411 fxp *= 2;
412 fxp2 *= 2;
413
414 // Check for convergence
415 if (std::abs(fx - fx_prev) < 1e-12)
416 {
417 fx_prev = fx;
418 break;
419 }
420 else
421 {
422 fx_prev = fx;
423 }
424
425 NekDouble gamma = 1.0;
426 bool conv = false;
427
428 // Search direction: Newton's method
429 NekDouble pk = -fxp / fxp2;
430
431 // Perform backtracking line search
432 while (gamma > 1e-10)
433 {
434 Array<OneD, NekDouble> xi_pk(1);
435 xi_pk[0] = xi[0] + pk * gamma;
436
437 if (xi_pk[0] < -1.0 || xi_pk[0] > 1.0)
438 {
439 gamma /= 2.0;
440 continue;
441 }
442
443 Array<OneD, NekDouble> xc_pk(dim);
444 Array<OneD, std::array<NekDouble, 3>> xc_der_pk(dim);
445 NekDouble fx_pk = 0, fxp_pk = 0, xc_pkDiff = 0;
446 for (int j = 0; j < dim; ++j)
447 {
448 xc_pk[j] = m_xmap->PhysEvaluate(xi_pk, x[j], xc_der_pk[j]);
449
450 xc_pkDiff = xc_pk[j] - xs[j];
451 fx_pk += xc_pkDiff * xc_pkDiff;
452 fxp_pk += xc_der_pk[j][0] * xc_pkDiff;
453 }
454
455 fxp_pk *= 2;
456
457 // Check Wolfe conditions using Armijo constants
458 // https://en.wikipedia.org/wiki/Wolfe_conditions
459 if ((fx_pk - (fx + c1 * gamma * pk * fxp)) <
460 std::numeric_limits<NekDouble>::epsilon() &&
461 (-pk * fxp_pk + c2 * pk * fxp) <
462 std::numeric_limits<NekDouble>::epsilon())
463 {
464 conv = true;
465 break;
466 }
467
468 gamma /= 2.0;
469 }
470
471 if (!conv)
472 {
473 break;
474 }
475
476 xi[0] += gamma * pk;
477 }
478
479 xiOut = xi;
480 return sqrt(fx_prev);
481 }
482 else
483 {
484 ASSERTL0(false, "Geometry type unknown")
485 }
486
487 return -1.0;
488}
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.
Definition: Geometry.h:554
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:544
bool ClampLocCoords(Array< OneD, NekDouble > &locCoord, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
Clamp local coords to be within standard regions [-1, 1]^dim.
Definition: Geometry.cpp:530
int GetCoordim() const
Return the coordinate dimension of this object (i.e. the dimension of the space in which this object ...
Definition: Geometry.h:283
static const unsigned int kNewtonIterations
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eDeformed
Geometry is curved or has non-constant factors.
scalarT< T > abs(scalarT< T > in)
Definition: scalar.hpp:289
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285

References tinysimd::abs(), ASSERTL0, Nektar::SpatialDomains::Geometry::ClampLocCoords(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::GetCoord(), Nektar::SpatialDomains::Geometry::GetCoordim(), Nektar::SpatialDomains::Geometry::GetLocCoords(), Nektar::NekConstants::kNewtonIterations, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_coordim, Nektar::SpatialDomains::Geometry::m_geomFactors, Nektar::SpatialDomains::Geometry::m_xmap, and tinysimd::sqrt().

◆ v_GenGeomFactors()

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

Implements Nektar::SpatialDomains::Geometry.

Definition at line 214 of file SegGeom.cpp.

215{
216 if (!m_setupState)
217 {
219 }
220
222 {
225
226 if (m_xmap->GetBasisNumModes(0) != 2)
227 {
228 gType = eDeformed;
229 }
230
232 gType, m_coordim, m_xmap, m_coeffs);
234 }
235}
bool m_setupState
Wether or not the setup routines have been run.
Definition: Geometry.h:198
GeomState m_geomFactorsState
State of the geometric factors.
Definition: Geometry.h:192
void v_FillGeom() override
Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
Definition: SegGeom.cpp:237
GeomType
Indicates the type of element geometry.

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().

Referenced by GenerateOneSpaceDimGeom().

◆ v_GetCoord()

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

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 164 of file SegGeom.cpp.

166{
167 ASSERTL1(m_state == ePtsFilled, "Geometry is not in physical space");
168
169 Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
170 m_xmap->BwdTrans(m_coeffs[i], tmp);
171
172 return m_xmap->PhysEvaluate(Lcoord, tmp);
173}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242

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

◆ v_GetNumVerts()

int Nektar::SpatialDomains::SegGeom::v_GetNumVerts ( ) const
overrideprotectedvirtual

Get the number of vertices of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 341 of file SegGeom.cpp.

342{
343 return kNverts;
344}
static const int kNverts
Definition: SegGeom.h:74

References kNverts.

◆ v_GetShapeType()

LibUtilities::ShapeType Nektar::SpatialDomains::SegGeom::v_GetShapeType ( ) const
protectedvirtual

Definition at line 159 of file SegGeom.cpp.

160{
162}

References Nektar::LibUtilities::eSegment.

◆ v_GetVertex()

PointGeomSharedPtr Nektar::SpatialDomains::SegGeom::v_GetVertex ( const int  i) const
overrideprotectedvirtual

Implements Nektar::SpatialDomains::Geometry.

Definition at line 329 of file SegGeom.cpp.

330{
331 PointGeomSharedPtr returnval;
332
333 if (i >= 0 && i < kNverts)
334 {
335 returnval = m_verts[i];
336 }
337
338 return returnval;
339}

References kNverts, and m_verts.

◆ v_Reset()

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

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

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 305 of file SegGeom.cpp.

306{
307 Geometry::v_Reset(curvedEdges, curvedFaces);
308 CurveMap::iterator it = curvedEdges.find(m_globalID);
309
310 if (it != curvedEdges.end())
311 {
312 m_curve = it->second;
313 }
314
315 SetUpXmap();
316 SetUpCoeffs(m_xmap->GetNcoeffs());
317}
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:364

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

◆ v_Setup()

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

Member Data Documentation

◆ kNverts

const int Nektar::SpatialDomains::SegGeom::kNverts = 2
static

Definition at line 74 of file SegGeom.h.

Referenced by v_GetNumVerts(), and v_GetVertex().

◆ m_curve

CurveSharedPtr Nektar::SpatialDomains::SegGeom::m_curve
private

Boolean indicating whether object owns the data.

Definition at line 94 of file SegGeom.h.

Referenced by GetCurve(), SegGeom(), SetUpXmap(), v_FillGeom(), and v_Reset().

◆ m_porient

StdRegions::Orientation Nektar::SpatialDomains::SegGeom::m_porient[kNverts]
protected

Definition at line 78 of file SegGeom.h.

◆ m_verts

SpatialDomains::PointGeomSharedPtr Nektar::SpatialDomains::SegGeom::m_verts[kNverts]
protected

Definition at line 77 of file SegGeom.h.

Referenced by GenerateOneSpaceDimGeom(), SegGeom(), v_FillGeom(), and v_GetVertex().