Nektar++
Loading...
Searching...
No Matches
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, int coordim, std::array< PointGeom *, kNverts > vertex, Curve *curve=nullptr)
 
 SegGeom (const SegGeom &in)
 
SegGeomUniquePtr GenerateOneSpaceDimGeom (EntityHolder1D &holder)
 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.
 
 ~SegGeom () override=default
 
CurveGetCurve ()
 
void SetCurve (Curve *curvePtr)
 
- 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.
 
 Geometry (int coordim)
 Constructor when supplied a coordinate dimension.
 
virtual ~Geometry ()=default
 
int GetCoordim () const
 Return the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded).
 
void SetCoordim (int coordim)
 Sets the coordinate dimension of this object (i.e. the dimension of the space in which this object is embedded).
 
GeomFactorsUniquePtr GenGeomFactors (LibUtilities::PointsKeyVector &keyTgt)
 Used by Expansion to generate associated GeomFactors.
 
LibUtilities::ShapeType GetShapeType (void)
 Get the geometric shape type of this object.
 
int GetGlobalID (void) const
 Get the ID of this object.
 
void SetGlobalID (int globalid)
 Set the ID of this object.
 
int GetVid (int i) const
 Returns global id of vertex i of this object.
 
int GetEid (int i) const
 Get the ID of edge i of this object.
 
int GetFid (int i) const
 Get the ID of face i of this object.
 
int GetTid (int i) const
 Get the ID of trace i of this object.
 
PointGeomGetVertex (int i) const
 Returns vertex i of this object.
 
Geometry1DGetEdge (int i) const
 Returns edge i of this object.
 
Geometry2DGetFace (int i) const
 Returns face i of this object.
 
StdRegions::Orientation GetEorient (const int i) const
 Returns the orientation of edge i with respect to the ordering of edges in the standard element.
 
StdRegions::Orientation GetForient (const int i) const
 Returns the orientation of face i with respect to the ordering of faces in the standard element.
 
int GetNumVerts () const
 Get the number of vertices of this object.
 
int GetNumEdges () const
 Get the number of edges of this object.
 
int GetNumFaces () const
 Get the number of faces of this object.
 
int GetShapeDim () const
 Get the object's shape dimension.
 
StdRegions::StdExpansionSharedPtr GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element.
 
const Array< OneD, const NekDouble > & GetCoeffs (const int i) const
 Return the coefficients of the transformation Geometry::m_xmap in coordinate direction i.
 
void FillGeom ()
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
 
std::array< NekDouble, 6 > GetBoundingBox ()
 Generates the bounding box for the element.
 
void ClearBoundingBox ()
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\).
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol)
 Determine whether an element contains a particular Cartesian coordinate \((x,y,z)\).
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\).
 
NekDouble GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
 Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this geometry object.
 
NekDouble GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord)
 Given local collapsed coordinate Lcoord, return the value of physical coordinate in direction i.
 
int PreliminaryCheck (const Array< OneD, const NekDouble > &gloCoord)
 A fast and robust check if a given global coord is outside of a deformed element. For regular elements, this check is unnecessary.
 
bool MinMaxCheck (const Array< OneD, const NekDouble > &gloCoord)
 Check if given global coord is within the BoundingBox of the element.
 
bool ClampLocCoords (Array< OneD, NekDouble > &locCoord, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
 Clamp local coords to be within standard regions [-1, 1]^dim.
 
NekDouble FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
 
int GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex.
 
int GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex.
 
int GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face.
 
int GetEdgeNormalToFaceVert (int i, int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex.
 
int GetDir (const int i, const int j=0) const
 Returns the element coordinate direction corresponding to a given face coordinate direction.
 
GeomType CalcGeomType ()
 
void Reset (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void ResetNonRecursive (CurveMap &curvedEdges, CurveMap &curvedFaces)
 Reset this geometry object non-recursively: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void Setup ()
 

Static Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

PointGeomv_GetVertex (const int i) const override
 Returns vertex i of this object.
 
virtual LibUtilities::ShapeType v_GetShapeType () const
 
GeomType v_CalcGeomType () override
 
GeomFactorsUniquePtr v_GenGeomFactors (LibUtilities::PointsKeyVector &keyTgt) override
 Used by Expansion to generate associated GeomFactors.
 
void v_FillGeom () override
 Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
 
void v_Reset (CurveMap &curvedEdges, CurveMap &curvedFaces) override
 Reset this geometry object: unset the current state, zero Geometry::m_coeffs and remove allocated GeomFactors.
 
void v_Setup () override
 
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.
 
int v_GetNumVerts () const override
 Get the number of vertices of this object.
 
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.
 
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.
 
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
virtual int v_GetVid (int i) const
 Get the ID of vertex i of this object.
 
virtual Geometry1Dv_GetEdge (const int i) const
 Returns edge i of this object.
 
virtual Geometry2Dv_GetFace (const int i) const
 Returns face i of this object.
 
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.
 
virtual StdRegions::Orientation v_GetForient (const int i) const
 Returns the orientation of face i with respect to the ordering of faces in the standard element.
 
virtual int v_GetNumEdges () const
 Get the number of edges of this object.
 
virtual int v_GetNumFaces () const
 Get the number of faces of this object.
 
virtual StdRegions::StdExpansionSharedPtr v_GetXmap () const
 Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standard element to physical element.
 
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 Determine whether an element contains a particular Cartesian coordinate \(\vec{x} = (x,y,z)\).
 
virtual int v_AllLeftCheck (const Array< OneD, const NekDouble > &gloCoord)
 
virtual int v_GetVertexEdgeMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given vertex.
 
virtual int v_GetVertexFaceMap (int i, int j) const
 Returns the standard element face IDs that are connected to a given vertex.
 
virtual int v_GetEdgeFaceMap (int i, int j) const
 Returns the standard element edge IDs that are connected to a given face.
 
virtual int v_GetEdgeNormalToFaceVert (const int i, const int j) const
 Returns the standard lement edge IDs that are normal to a given face vertex.
 
virtual int v_GetDir (const int faceidx, const int facedir) const
 Returns the element coordinate direction corresponding to a given face coordinate direction.
 
void SetUpCoeffs (const int nCoeffs)
 Initialise the Geometry::m_coeffs array.
 
virtual void v_CalculateInverseIsoParam ()
 

Protected Attributes

std::array< SpatialDomains::PointGeom *, kNvertsm_verts
 
StdRegions::Orientation m_porient [kNverts]
 
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry
int m_coordim
 Coordinate dimension of this geometry object.
 
StdRegions::StdExpansionSharedPtr m_xmap
 \(\chi\) mapping containing isoparametric transformation.
 
GeomState m_state
 Enumeration to dictate whether coefficients are filled.
 
bool m_setupState
 Wether or not the setup routines have been run.
 
LibUtilities::ShapeType m_shapeType
 Type of shape.
 
int m_globalID
 Global ID.
 
std::vector< Array< OneD, NekDouble > > m_coeffs
 Array containing expansion coefficients of m_xmap.
 
Array< OneD, NekDoublem_boundingBox
 Array containing bounding box.
 
Array< OneD, Array< OneD, NekDouble > > m_isoParameter
 
Array< OneD, Array< OneD, NekDouble > > m_invIsoParam
 
int m_straightEdge
 

Private Member Functions

void SetUpXmap ()
 

Private Attributes

Curvem_curve = nullptr
 Boolean indicating whether object owns the data.
 

Detailed Description

Definition at line 59 of file SegGeom.h.

Constructor & Destructor Documentation

◆ SegGeom() [1/3]

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

◆ SegGeom() [2/3]

Nektar::SpatialDomains::SegGeom::SegGeom ( int  id,
int  coordim,
std::array< PointGeom *, kNverts vertex,
Curve curve = nullptr 
)

Definition at line 69 of file SegGeom.cpp.

71 : Geometry1D(coordim)
72{
74 m_globalID = id;
76 m_curve = curve;
77 m_verts = vertex;
78}
GeomState m_state
Enumeration to dictate whether coefficients are filled.
Definition Geometry.h:188
std::array< SpatialDomains::PointGeom *, kNverts > m_verts
Definition SegGeom.h:90
Curve * m_curve
Boolean indicating whether object owns the data.
Definition SegGeom.h:109
@ 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 80 of file SegGeom.cpp.

80 : Geometry1D(in)
81{
82 // From Geometry class
83 m_shapeType = in.m_shapeType;
84
85 // info from EdgeComponent class
86 m_globalID = in.m_globalID;
87 m_xmap = in.m_xmap;
88 SetUpCoeffs(m_xmap->GetNcoeffs());
89
90 // info from SegGeom class
91 m_coordim = in.m_coordim;
92 m_verts[0] = in.m_verts[0];
93 m_verts[1] = in.m_verts[1];
94
95 m_state = in.m_state;
96}
void SetUpCoeffs(const int nCoeffs)
Initialise the Geometry::m_coeffs array.
Definition Geometry.h:694
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition Geometry.h:186
int m_coordim
Coordinate dimension of this geometry object.
Definition Geometry.h:184

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

SegGeomUniquePtr Nektar::SpatialDomains::SegGeom::GenerateOneSpaceDimGeom ( EntityHolder1D holder)

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 122 of file SegGeom.cpp.

123{
125
126 // info about numbering
127 returnval->m_globalID = m_globalID;
128
129 // geometric information.
130 returnval->m_coordim = 1;
131 NekDouble x0 = (*m_verts[0])[0];
133 1, m_verts[0]->GetGlobalID(), x0, 0.0, 0.0);
134 vert0->SetGlobalID(vert0->GetGlobalID());
135 returnval->m_verts[0] = vert0.get();
136 holder.m_pointVec.push_back(std::move(vert0));
137
138 // Get information to calculate length.
139 const Array<OneD, const LibUtilities::BasisSharedPtr> base =
140 m_xmap->GetBase();
142 v.push_back(base[0]->GetPointsKey());
143
144 const Array<OneD, const NekDouble> jac = v_GenGeomFactors(v)->GetJac();
145
146 NekDouble len = 0.0;
147 if (jac.size() == 1)
148 {
149 len = jac[0] * 2.0;
150 }
151 else
152 {
153 Array<OneD, const NekDouble> w0 = base[0]->GetW();
154 len = 0.0;
155
156 for (int i = 0; i < jac.size(); ++i)
157 {
158 len += jac[i] * w0[i];
159 }
160 }
161 // Set up second vertex.
163 1, m_verts[1]->GetGlobalID(), x0 + len, 0.0, 0.0);
164 vert1->SetGlobalID(vert1->GetGlobalID());
165
166 returnval->m_verts[1] = vert1.get();
167 holder.m_pointVec.push_back(std::move(vert1));
168
169 // at present just use previous m_xmap[0];
170 returnval->m_xmap = m_xmap;
171 returnval->SetUpCoeffs(m_xmap->GetNcoeffs());
172 returnval->m_state = eNotFilled;
173
174 return returnval;
175}
static std::unique_ptr< DataType, UniquePtrDeleter > AllocateUniquePtr(const Args &...args)
int GetGlobalID(void) const
Get the ID of this object.
Definition Geometry.h:314
GeomFactorsUniquePtr v_GenGeomFactors(LibUtilities::PointsKeyVector &keyTgt) override
Used by Expansion to generate associated GeomFactors.
Definition SegGeom.cpp:253
std::vector< PointsKey > PointsKeyVector
Definition Points.h:313
const Array< OneD, NekDouble > base(3, 0.0)
unique_ptr_objpool< SegGeom > SegGeomUniquePtr
Definition MeshGraph.h:102
unique_ptr_objpool< PointGeom > PointGeomUniquePtr
Definition MeshGraph.h:99

References Nektar::ObjPoolManager< DataType >::AllocateUniquePtr(), Nektar::SpatialDomains::eNotFilled, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::m_globalID, Nektar::SpatialDomains::EntityHolder1D::m_pointVec, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, and v_GenGeomFactors().

◆ GetCurve()

Curve * Nektar::SpatialDomains::SegGeom::GetCurve ( )
inline

Definition at line 80 of file SegGeom.h.

81 {
82 return m_curve;
83 }

References m_curve.

Referenced by export_GeomElements(), and Nektar::SpatialDomains::ZoneBase::ZoneBase().

◆ 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 211 of file SegGeom.cpp.

213{
215
216 if ((*edge1.GetVertex(0) == *edge2.GetVertex(0)) ||
217 (*edge1.GetVertex(0) == *edge2.GetVertex(1)))
218 {
219 // Backward direction. Vertex 0 is connected to edge 2.
220 returnval = StdRegions::eBackwards;
221 }
222 else if ((*edge1.GetVertex(1) != *edge2.GetVertex(0)) &&
223 (*edge1.GetVertex(1) != *edge2.GetVertex(1)))
224 {
225 // Not forward either, then we have a problem.
226 std::ostringstream errstrm;
227 errstrm << "Connected edges do not share a vertex. Edges ";
228 errstrm << edge1.GetGlobalID() << ", " << edge2.GetGlobalID();
229 NEKERROR(ErrorUtil::efatal, errstrm.str());
230 }
231
232 return returnval;
233}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...

References Nektar::StdRegions::eBackwards, Nektar::ErrorUtil::efatal, Nektar::StdRegions::eForwards, Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetVertex(), and NEKERROR.

Referenced by Nektar::SpatialDomains::TriGeom::TriGeom().

◆ SetCurve()

void Nektar::SpatialDomains::SegGeom::SetCurve ( Curve curvePtr)
inline

Definition at line 84 of file SegGeom.h.

85 {
86 m_curve = curvePtr;
87 }

References m_curve.

◆ SetUpXmap()

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

Definition at line 98 of file SegGeom.cpp.

99{
100 if (m_curve)
101 {
102 int npts = m_curve->m_points.size();
103 LibUtilities::PointsKey pkey(npts + 1,
105 const LibUtilities::BasisKey B(LibUtilities::eModified_A, npts, pkey);
107 }
108 else
109 {
110 const LibUtilities::BasisKey B(
112 LibUtilities::PointsKey(2, LibUtilities::eGaussLobattoLegendre));
114 }
115}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
std::vector< PointGeom * > m_points
Points along the curve.
Definition Curve.hpp:53

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

Referenced by v_Reset(), and v_Setup().

◆ v_CalcGeomType()

GeomType Nektar::SpatialDomains::SegGeom::v_CalcGeomType ( )
overrideprotectedvirtual

Calculates the GeomType (deformed, regular etc).

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 235 of file SegGeom.cpp.

236{
237 if (!m_setupState)
238 {
240 }
242
244
245 if (m_xmap->GetBasisNumModes(0) != 2)
246 {
247 gType = eDeformed;
248 }
249
250 return gType;
251}
bool m_setupState
Wether or not the setup routines have been run.
Definition Geometry.h:190
void v_FillGeom() override
Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
Definition SegGeom.cpp:261
GeomType
Indicates the type of element geometry.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eDeformed
Geometry is curved or has non-constant factors.

References Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::m_setupState, Nektar::SpatialDomains::Geometry::m_xmap, v_FillGeom(), 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 261 of file SegGeom.cpp.

262{
263 if (m_state != ePtsFilled)
264 {
265 int i;
266
267 if (m_coordim > 0 && m_curve)
268 {
269 int npts = m_curve->m_points.size();
270 LibUtilities::PointsKey pkey(npts + 1,
272 Array<OneD, NekDouble> tmp(npts);
273
274 if (m_verts[0]->dist(*(m_curve->m_points[0])) >
276 {
277 std::string err =
278 "Vertex 0 is separated from first point by more than ";
279 std::stringstream strstrm;
280 strstrm << NekConstants::kVertexTheSameDouble << " in edge "
281 << m_globalID;
282 err += strstrm.str();
283 NEKERROR(ErrorUtil::ewarning, err.c_str());
284 }
285
286 if (m_verts[1]->dist(*(m_curve->m_points[npts - 1])) >
288 {
289 std::string err =
290 "Vertex 1 is separated from last point by more than ";
291 std::stringstream strstrm;
292 strstrm << NekConstants::kVertexTheSameDouble << " in edge "
293 << m_globalID;
294 err += strstrm.str();
295 NEKERROR(ErrorUtil::ewarning, err.c_str());
296 }
297
298 LibUtilities::PointsKey fkey(npts, m_curve->m_ptype);
300 LibUtilities::PointsManager()[fkey]->GetI(pkey);
301 NekVector<NekDouble> out(npts + 1);
302
303 for (int i = 0; i < m_coordim; ++i)
304 {
305 // Load up coordinate values into tmp
306 for (int j = 0; j < npts; ++j)
307 {
308 tmp[j] = (m_curve->m_points[j]->GetPtr())[i];
309 }
310
311 // Interpolate to GLL points
312 NekVector<NekDouble> in(npts, tmp, eWrapper);
313 out = (*I0) * in;
314
315 m_xmap->FwdTrans(out.GetPtr(), m_coeffs[i]);
316 }
317 }
318
319 for (i = 0; i < m_coordim; ++i)
320 {
321 m_coeffs[i][0] = (*m_verts[0])[i];
322 m_coeffs[i][1] = (*m_verts[1])[i];
323 }
324
326 }
327}
std::vector< Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition Geometry.h:196
PointsManagerT & PointsManager(void)
static const NekDouble kVertexTheSameDouble
@ ePtsFilled
Geometric information has been generated.
std::shared_ptr< DNekMat > DNekMatSharedPtr
LibUtilities::PointsType m_ptype
Points distribution of this curve.
Definition Curve.hpp:57

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::Curve::m_points, Nektar::SpatialDomains::Curve::m_ptype, Nektar::SpatialDomains::Geometry::m_state, m_verts, Nektar::SpatialDomains::Geometry::m_xmap, NEKERROR, and Nektar::LibUtilities::PointsManager().

Referenced by v_CalcGeomType().

◆ 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 370 of file SegGeom.cpp.

372{
373 GeomType Gtype = CalcGeomType();
374 if (Gtype == eRegular)
375 {
376 xiOut = Array<OneD, NekDouble>(1, 0.0);
377
378 GetLocCoords(xs, xiOut);
379 ClampLocCoords(xiOut);
380
381 Array<OneD, NekDouble> gloCoord(m_coordim);
382 NekDouble tmp = 0;
383 for (int i = 0; i < m_coordim; ++i)
384 {
385 gloCoord[i] = GetCoord(i, xiOut);
386 tmp += (xs[i] - gloCoord[i]) * (xs[i] - gloCoord[i]);
387 }
388
389 return sqrt(tmp);
390 }
391 // If deformed edge then the inverse mapping is non-linear so need to
392 // numerically solve for the local coordinate
393 else if (Gtype == eDeformed)
394 {
395 Array<OneD, NekDouble> xi(1, 0.0);
396
397 // Armijo constants:
398 // https://en.wikipedia.org/wiki/Backtracking_line_search
399 const NekDouble c1 = 1e-4, c2 = 0.9;
400
401 int dim = GetCoordim();
402 int nq = m_xmap->GetTotPoints();
403
404 Array<OneD, Array<OneD, NekDouble>> x(dim), xder(dim), xder2(dim);
405 // Get x,y,z phys values from coefficients
406 for (int i = 0; i < dim; ++i)
407 {
408 x[i] = Array<OneD, NekDouble>(nq);
409 xder[i] = Array<OneD, NekDouble>(nq);
410 xder2[i] = Array<OneD, NekDouble>(nq);
411
412 m_xmap->BwdTrans(m_coeffs[i], x[i]);
413 }
414
415 NekDouble fx_prev = std::numeric_limits<NekDouble>::max();
416
417 // Minimisation loop (Quasi-newton method)
418 for (int i = 0; i < NekConstants::kNewtonIterations; ++i)
419 {
420 // Compute the objective function, f(x_k) and its derivatives
421 Array<OneD, NekDouble> xc(dim);
422 Array<OneD, std::array<NekDouble, 3>> xc_der(dim);
423 Array<OneD, std::array<NekDouble, 6>> xc_der2(dim);
424 NekDouble fx = 0, fxp = 0, fxp2 = 0, xcDiff = 0;
425 for (int j = 0; j < dim; ++j)
426 {
427 xc[j] = m_xmap->PhysEvaluate(xi, x[j], xc_der[j], xc_der2[j]);
428
429 xcDiff = xc[j] - xs[j];
430 // Objective function is the distance to the search point
431 fx += xcDiff * xcDiff;
432 fxp += xc_der[j][0] * xcDiff;
433 fxp2 += xc_der2[j][0] * xcDiff + xc_der[j][0] * xc_der[j][0];
434 }
435
436 fxp *= 2;
437 fxp2 *= 2;
438
439 // Check for convergence
440 if (std::abs(fx - fx_prev) < 1e-12)
441 {
442 fx_prev = fx;
443 break;
444 }
445 else
446 {
447 fx_prev = fx;
448 }
449
450 NekDouble gamma = 1.0;
451 bool conv = false;
452
453 // Search direction: Newton's method
454 NekDouble pk = -fxp / fxp2;
455
456 // Perform backtracking line search
457 while (gamma > 1e-10)
458 {
459 Array<OneD, NekDouble> xi_pk(1);
460 xi_pk[0] = xi[0] + pk * gamma;
461
462 if (xi_pk[0] < -1.0 || xi_pk[0] > 1.0)
463 {
464 gamma /= 2.0;
465 continue;
466 }
467
468 Array<OneD, NekDouble> xc_pk(dim);
469 Array<OneD, std::array<NekDouble, 3>> xc_der_pk(dim);
470 NekDouble fx_pk = 0, fxp_pk = 0, xc_pkDiff = 0;
471 for (int j = 0; j < dim; ++j)
472 {
473 xc_pk[j] = m_xmap->PhysEvaluate(xi_pk, x[j], xc_der_pk[j]);
474
475 xc_pkDiff = xc_pk[j] - xs[j];
476 fx_pk += xc_pkDiff * xc_pkDiff;
477 fxp_pk += xc_der_pk[j][0] * xc_pkDiff;
478 }
479
480 fxp_pk *= 2;
481
482 // Check Wolfe conditions using Armijo constants
483 // https://en.wikipedia.org/wiki/Wolfe_conditions
484 if ((fx_pk - (fx + c1 * gamma * pk * fxp)) <
485 std::numeric_limits<NekDouble>::epsilon() &&
486 (-pk * fxp_pk + c2 * pk * fxp) <
487 std::numeric_limits<NekDouble>::epsilon())
488 {
489 conv = true;
490 break;
491 }
492
493 gamma /= 2.0;
494 }
495
496 if (!conv)
497 {
498 break;
499 }
500
501 xi[0] += gamma * pk;
502 }
503
504 xiOut = xi;
505 return sqrt(fx_prev);
506 }
507 else
508 {
509 NEKERROR(ErrorUtil::efatal, "Geometry type unknown");
510 }
511
512 return -1.0;
513}
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:559
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:549
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:525
int GetCoordim() const
Return the coordinate dimension of this object (i.e. the dimension of the space in which this object ...
Definition Geometry.h:277
static const unsigned int kNewtonIterations
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:290

References Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::Geometry::ClampLocCoords(), Nektar::SpatialDomains::eDeformed, Nektar::ErrorUtil::efatal, 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_xmap, NEKERROR, and tinysimd::sqrt().

◆ v_GenGeomFactors()

GeomFactorsUniquePtr Nektar::SpatialDomains::SegGeom::v_GenGeomFactors ( LibUtilities::PointsKeyVector keyTgt)
overrideprotectedvirtual

◆ 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 182 of file SegGeom.cpp.

184{
185 if (m_state != ePtsFilled)
186 {
187 NEKERROR(ErrorUtil::ewarning, "Geometry is not in physical space");
188 }
189
190 Array<OneD, NekDouble> tmp(m_xmap->GetTotPoints());
191 m_xmap->BwdTrans(m_coeffs[i], tmp);
192
193 return m_xmap->PhysEvaluate(Lcoord, tmp);
194}

References Nektar::SpatialDomains::ePtsFilled, Nektar::ErrorUtil::ewarning, Nektar::SpatialDomains::Geometry::m_coeffs, Nektar::SpatialDomains::Geometry::m_state, Nektar::SpatialDomains::Geometry::m_xmap, and NEKERROR.

◆ 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 365 of file SegGeom.cpp.

366{
367 return kNverts;
368}
static const int kNverts
Definition SegGeom.h:62

References kNverts.

◆ v_GetShapeType()

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

Definition at line 177 of file SegGeom.cpp.

178{
180}

References Nektar::LibUtilities::eSegment.

◆ v_GetVertex()

PointGeom * Nektar::SpatialDomains::SegGeom::v_GetVertex ( const int  i) const
overrideprotectedvirtual

Returns vertex i of this object.

Reimplemented from Nektar::SpatialDomains::Geometry.

Definition at line 353 of file SegGeom.cpp.

354{
355 PointGeom *returnval = nullptr;
356
357 if (i >= 0 && i < kNverts)
358 {
359 returnval = m_verts[i];
360 }
361
362 return returnval;
363}

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 329 of file SegGeom.cpp.

330{
331 Geometry::v_Reset(curvedEdges, curvedFaces);
332 CurveMap::iterator it = curvedEdges.find(m_globalID);
333
334 if (it != curvedEdges.end())
335 {
336 m_curve = it->second.get();
337 }
338
339 SetUpXmap();
340 SetUpCoeffs(m_xmap->GetNcoeffs());
341}
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:366

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

◆ kNfacets

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

Definition at line 63 of file SegGeom.h.

◆ kNverts

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

Definition at line 62 of file SegGeom.h.

Referenced by v_GetNumVerts(), and v_GetVertex().

◆ m_curve

Curve* Nektar::SpatialDomains::SegGeom::m_curve = nullptr
private

Boolean indicating whether object owns the data.

Definition at line 109 of file SegGeom.h.

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

◆ m_porient

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

Definition at line 91 of file SegGeom.h.

◆ m_verts

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

Definition at line 90 of file SegGeom.h.

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