Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Nektar::SpatialDomains::GeometryLocator2D Class Referencefinal

Inverse mapping for a triangle or quadrilateral, including the closed-form solve available when every edge is straight. More...

#include <GeometryLocator.h>

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

Public Member Functions

 GeometryLocator (Geometry *geom)
 
- Public Member Functions inherited from Nektar::SpatialDomains::GeometryLocator
 GeometryLocator (Geometry *geom)
 
virtual ~GeometryLocator ()=default
 
void Build ()
 Populate the cache. Called by Create() once the concrete type exists, since it dispatches virtually.
 
Geometry * GetGeometry () const
 
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 the element contains a Cartesian coordinate.
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol)
 Determine whether the element contains a Cartesian coordinate.
 
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist)
 
NekDouble GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
 Determine the local collapsed coordinates corresponding to a given Cartesian coordinate.
 
NekDouble FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi)
 
int PreliminaryCheck (const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist)
 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.
 

Protected Member Functions

NekDouble v_GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
 
NekDouble v_FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) override
 
int v_AllLeftCheck (const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist) override
 
void v_CalculateInverseIsoParam () override
 
void v_PreSolveStraightEdge () override
 

Private Member Functions

void SolveStraightEdgeQuad (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
 
void NewtonIterationForLocCoord (const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &dist)
 

Additional Inherited Members

- Static Public Member Functions inherited from Nektar::SpatialDomains::GeometryLocator
static std::unique_ptr< GeometryLocator > Create (Geometry *geom)
 Build the locator appropriate to geom's dimension, with its cache already populated.
 
static bool ClampLocCoords (Array< OneD, NekDouble > &locCoord, int dim, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
 Clamp local coordinates into the reference element \([-1-tol,1+tol]^{dim}\), returning whether anything was clamped. Depends only on the reference element, so it needs no locator.
 
- Protected Attributes inherited from Nektar::SpatialDomains::GeometryLocator
Geometry * m_geom
 The geometry being searched. Not owned.
 
IsoParam m_iso
 The shape's isoparametric coefficients. The straight-edged 2D solve rewrites them into a factored form, so the locator keeps its own copy rather than sharing the geometry's.
 
int m_straightEdge = 0
 Non-zero if every \(\chi\) basis is linear. Bits 1 and 2 are used by the 2D straight-edged solve to record which axes were swapped.
 
std::array< std::array< NekDouble, kMaxGeomDim >, kMaxGeomDim > m_invIsoParam {}
 Inverse of the linear part of m_iso, for regular elements.
 
bool m_newtonConverged = false
 Whether the Newton iteration of the last GetLocCoords call converged, i.e. whether its local coordinates map to the point. Set only by elements located by Newton iteration; read by ContainsPoint.
 
bool m_hasBoundingBox = false
 Element bounding box as (xmin, ymin, zmin, xmax, ymax, zmax).
 
std::array< NekDouble, 6 > m_boundingBox {}
 
bool m_edgeNormalBuilt = false
 2D only: inward edge normals used to reject points outside straight-sided elements. A curved edge gets no normal, so m_hasEdgeNormal records which entries are usable.
 
std::array< bool, kMaxGeomVerts > m_hasEdgeNormal {}
 
std::array< std::array< NekDouble, 2 >, kMaxGeomVerts > m_edgeNormal {}
 

Detailed Description

Inverse mapping for a triangle or quadrilateral, including the closed-form solve available when every edge is straight.

Definition at line 213 of file GeometryLocator.h.

Member Function Documentation

◆ GeometryLocator()

Nektar::SpatialDomains::GeometryLocator::GeometryLocator ( Geometry *  geom)
explicit

Definition at line 105 of file GeometryLocator.cpp.

50 : m_geom(geom)
51{
52 ASSERTL0(m_geom != nullptr, "A locator needs a geometry to search.");
53}
#define ASSERTL0(condition, msg)
Geometry * m_geom
The geometry being searched. Not owned.

◆ NewtonIterationForLocCoord()

void Nektar::SpatialDomains::GeometryLocator2D::NewtonIterationForLocCoord ( const Array< OneD, const NekDouble > &  coords,
const Array< OneD, const NekDouble > &  ptsx,
const Array< OneD, const NekDouble > &  ptsy,
Array< OneD, NekDouble > &  Lcoords,
NekDouble &  dist 
)
private

Definition at line 687 of file GeometryLocator.cpp.

692{
693 // Maximum iterations for convergence
694 const int MaxIterations = NekConstants::kNewtonIterations;
695 // |x-xp|^2 < EPSILON error tolerance
696 const NekDouble Tol = 1.e-8;
697 // |r,s| > LcoordDIV stop the search
698 const NekDouble LcoordDiv = 15.0;
699
701 Array<OneD, const NekDouble> Jac =
702 m_geom->GenGeomFactors(ptsKeys)->GetJac();
703
704 NekDouble ScaledTol =
705 Vmath::Vsum(Jac.size(), Jac, 1) / ((NekDouble)Jac.size());
706 ScaledTol *= Tol;
707
708 NekDouble xmap, ymap, F1, F2;
709 NekDouble derx_1, derx_2, dery_1, dery_2, jac;
710
711 // save intiial guess for later reference if required.
712 NekDouble init0 = Lcoords[0], init1 = Lcoords[1];
713
714 Array<OneD, NekDouble> DxD1(ptsx.size());
715 Array<OneD, NekDouble> DxD2(ptsx.size());
716 Array<OneD, NekDouble> DyD1(ptsx.size());
717 Array<OneD, NekDouble> DyD2(ptsx.size());
718
719 // Ideally this will be stored in m_geomfactors
720 m_geom->GetXmap()->PhysDeriv(ptsx, DxD1, DxD2);
721 m_geom->GetXmap()->PhysDeriv(ptsy, DyD1, DyD2);
722
723 int cnt = 0;
724 Array<OneD, DNekMatSharedPtr> I(2);
725 Array<OneD, NekDouble> eta(2);
726
727 F1 = F2 = 2000; // Starting value of Function
728 NekDouble resid = sqrt(F1 * F1 + F2 * F2);
729 m_newtonConverged = false;
730 while (cnt++ < MaxIterations)
731 {
732 // evaluate lagrange interpolant at Lcoords
733 m_geom->GetXmap()->LocCoordToLocCollapsed(Lcoords, eta);
734 I[0] = m_geom->GetXmap()->GetBasis(0)->GetI(eta);
735 I[1] = m_geom->GetXmap()->GetBasis(1)->GetI(eta + 1);
736
737 // calculate the global point `corresponding to Lcoords
738 xmap = m_geom->GetXmap()->PhysEvaluate(I, ptsx);
739 ymap = m_geom->GetXmap()->PhysEvaluate(I, ptsy);
740
741 F1 = coords[0] - xmap;
742 F2 = coords[1] - ymap;
743
744 if (F1 * F1 + F2 * F2 < ScaledTol)
745 {
746 resid = sqrt(F1 * F1 + F2 * F2);
747 m_newtonConverged = true;
748 break;
749 }
750
751 // Interpolate derivative metric at Lcoords
752 derx_1 = m_geom->GetXmap()->PhysEvaluate(I, DxD1);
753 derx_2 = m_geom->GetXmap()->PhysEvaluate(I, DxD2);
754 dery_1 = m_geom->GetXmap()->PhysEvaluate(I, DyD1);
755 dery_2 = m_geom->GetXmap()->PhysEvaluate(I, DyD2);
756
757 jac = dery_2 * derx_1 - dery_1 * derx_2;
758
759 // use analytical inverse of derivitives which are
760 // also similar to those of metric factors.
761 Lcoords[0] =
762 Lcoords[0] +
763 (dery_2 * (coords[0] - xmap) - derx_2 * (coords[1] - ymap)) / jac;
764
765 Lcoords[1] =
766 Lcoords[1] +
767 (-dery_1 * (coords[0] - xmap) + derx_1 * (coords[1] - ymap)) / jac;
768
769 if (!(std::isfinite(Lcoords[0]) && std::isfinite(Lcoords[1])))
770 {
771 dist = 1e16;
772 std::ostringstream ss;
773 ss << "nan or inf found in NewtonIterationForLocCoord in element "
774 << m_geom->GetGlobalID();
775 WARNINGL1(false, ss.str());
776 return;
777 }
778 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv)
779 {
780 break; // lcoords have diverged so stop iteration
781 }
782 }
783
784 m_geom->GetXmap()->LocCoordToLocCollapsed(Lcoords, eta);
785 if (ClampLocCoords(eta, m_geom->GetShapeDim(), 0.))
786 {
787 I[0] = m_geom->GetXmap()->GetBasis(0)->GetI(eta);
788 I[1] = m_geom->GetXmap()->GetBasis(1)->GetI(eta + 1);
789 // calculate the global point corresponding to Lcoords
790 xmap = m_geom->GetXmap()->PhysEvaluate(I, ptsx);
791 ymap = m_geom->GetXmap()->PhysEvaluate(I, ptsy);
792 F1 = coords[0] - xmap;
793 F2 = coords[1] - ymap;
794 dist = sqrt(F1 * F1 + F2 * F2);
795 }
796 else if (m_newtonConverged)
797 {
798 dist = 0.;
799 }
800 else
801 {
802 // Inside the element but not converged: Lcoords does not map to
803 // coords, so report the residual rather than claiming a match
804 I[0] = m_geom->GetXmap()->GetBasis(0)->GetI(eta);
805 I[1] = m_geom->GetXmap()->GetBasis(1)->GetI(eta + 1);
806 xmap = m_geom->GetXmap()->PhysEvaluate(I, ptsx);
807 ymap = m_geom->GetXmap()->PhysEvaluate(I, ptsy);
808 F1 = coords[0] - xmap;
809 F2 = coords[1] - ymap;
810 dist = std::sqrt(F1 * F1 + F2 * F2);
811 resid = dist;
812 }
813
814 if (cnt >= MaxIterations)
815 {
816 Array<OneD, NekDouble> collCoords(2);
817 m_geom->GetXmap()->LocCoordToLocCollapsed(Lcoords, collCoords);
818
819 // if coordinate is inside element dump error!
820 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
821 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0))
822 {
823 std::ostringstream ss;
824
825 ss << "Reached MaxIterations (" << MaxIterations
826 << ") in Newton iteration ";
827 ss << "Init value (" << std::setprecision(4) << init0 << ","
828 << init1 << ","
829 << ") ";
830 ss << "Fin value (" << Lcoords[0] << "," << Lcoords[1] << ","
831 << ") ";
832 ss << "Resid = " << resid
833 << " Tolerance = " << std::sqrt(ScaledTol);
834
835 WARNINGL1(cnt < MaxIterations, ss.str());
836 }
837 }
838}
#define WARNINGL1(condition, msg)
int GetShapeDim() const
Dimension of the shape itself, which may be less than GetCoordim().
Definition Geometry.h:557
int GetGlobalID(void) const
Get the ID of this object.
Definition Geometry.h:465
StdRegions::StdExpansion * GetXmap() const
The expansion holding the mapping from the standard element to this one. Shared between geometries a...
Definition Geometry.h:571
GeomFactorsUniquePtr GenGeomFactors(LibUtilities::PointsKeyVector &keyTgt)
Build the #GeomFactors for this object at the quadrature points keyTgt.
Definition Geometry.h:565
static bool ClampLocCoords(Array< OneD, NekDouble > &locCoord, int dim, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
Clamp local coordinates into the reference element , returning whether anything was clamped....
bool m_newtonConverged
Whether the Newton iteration of the last GetLocCoords call converged, i.e. whether its local coordina...
const LibUtilities::BasisSharedPtr & GetBasis(int dir) const
This function gets the shared point to basis in the dir direction.
const LibUtilities::PointsKeyVector GetPointsKeys() const
void LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta)
Convert local cartesian coordinate xi into local collapsed coordinates eta.
NekDouble PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
This function evaluates the expansion at a single (arbitrary) point of the domain.
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
std::vector< PointsKey > PointsKeyVector
Definition Points.h:309
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT jac
static const unsigned int kNewtonIterations
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition Vmath.hpp:611
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289

References Nektar::SpatialDomains::GeometryLocator::ClampLocCoords(), Nektar::SpatialDomains::Geometry::GenGeomFactors(), Nektar::StdRegions::StdExpansion::GetBasis(), Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::StdRegions::StdExpansion::GetPointsKeys(), Nektar::SpatialDomains::Geometry::GetShapeDim(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::NekConstants::kNewtonIterations, Nektar::StdRegions::StdExpansion::LocCoordToLocCollapsed(), Nektar::SpatialDomains::GeometryLocator::m_geom, Nektar::SpatialDomains::GeometryLocator::m_newtonConverged, Nektar::StdRegions::StdExpansion::PhysDeriv(), Nektar::StdRegions::StdExpansion::PhysEvaluate(), tinysimd::sqrt(), Vmath::Vsum(), and WARNINGL1.

Referenced by v_GetLocCoords().

◆ SolveStraightEdgeQuad()

void Nektar::SpatialDomains::GeometryLocator2D::SolveStraightEdgeQuad ( const Array< OneD, const NekDouble > &  coords,
Array< OneD, NekDouble > &  Lcoords 
)
private

Definition at line 661 of file GeometryLocator.cpp.

663{
664 auto &isoParam = m_iso.m_coeff;
665 int i0 = 0, i1 = 1, j1 = 0, j2 = 1;
666 if (m_straightEdge & 2)
667 {
668 i0 = 1;
669 i1 = 0;
670 }
671 if (m_straightEdge & 4)
672 {
673 j1 = 1;
674 j2 = 0;
675 }
676 NekDouble beta = isoParam[1][2];
677 NekDouble gamma = isoParam[1][3];
678 NekDouble tty =
679 (coords[i1] - gamma * coords[i0] - isoParam[1][0]) * isoParam[1][1];
680 NekDouble denom = 1. / (isoParam[0][2] + isoParam[0][3] * tty);
681 NekDouble epsilon = -isoParam[0][3] * beta * denom;
682 NekDouble h = (isoParam[0][0] + isoParam[0][1] * tty - coords[i0]) * denom;
683 Lcoords[j2] = -h / (0.5 + sqrt(0.25 - epsilon * h));
684 Lcoords[j1] = -beta * Lcoords[j2] + tty;
685}
IsoParam m_iso
The shape's isoparametric coefficients. The straight-edged 2D solve rewrites them into a factored for...
int m_straightEdge
Non-zero if every basis is linear. Bits 1 and 2 are used by the 2D straight-edged solve to record wh...
@ beta
Gauss Radau pinned at x=-1,.
Definition PointsType.h:59
std::array< std::array< NekDouble, kMaxGeomIsoCoeff >, kMaxGeomDim > m_coeff

References Nektar::LibUtilities::beta, Nektar::SpatialDomains::IsoParam::m_coeff, Nektar::SpatialDomains::GeometryLocator::m_iso, Nektar::SpatialDomains::GeometryLocator::m_straightEdge, and tinysimd::sqrt().

Referenced by v_GetLocCoords().

◆ v_AllLeftCheck()

int Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck ( const Array< OneD, const NekDouble > &  gloCoord,
NekDouble &  edgeDist 
)
overrideprotectedvirtual

Reimplemented from Nektar::SpatialDomains::GeometryLocator.

Definition at line 1170 of file GeometryLocator.cpp.

1172{
1173 int nc = 1, d0 = m_iso.m_manifold[0], d1 = m_iso.m_manifold[1];
1174 NekDouble nearDist = -1.; // >= 0 once the point is just outside an edge
1175 if (!m_edgeNormalBuilt)
1176 {
1177 m_edgeNormalBuilt = true;
1178 std::array<std::array<NekDouble, 3>, 2> x;
1179 m_geom->GetVertex(0)->GetCoords(x[0][0], x[0][1], x[0][2]);
1180 int i0 = 1, i1 = 0, direction = 1;
1181 for (size_t i = 0; i < m_geom->GetNumVerts(); ++i)
1182 {
1183 i0 ^= 1;
1184 i1 ^= 1;
1185 m_geom->GetVertex((i + 1) % m_geom->GetNumVerts())
1186 ->GetCoords(x[i1][0], x[i1][1], x[i1][2]);
1187 if (m_geom->GetEdge(i)->GetXmap()->GetBasis(0)->GetNumModes() > 2)
1188 {
1189 continue;
1190 }
1191 m_hasEdgeNormal[i] = true;
1192 m_edgeNormal[i][0] = x[i0][d1] - x[i1][d1];
1193 m_edgeNormal[i][1] = x[i1][d0] - x[i0][d0];
1194 }
1195 if (m_geom->GetCoordim() == 3)
1196 {
1197 for (size_t i = 0; i < m_geom->GetNumVerts(); ++i)
1198 {
1199 if (m_hasEdgeNormal[i])
1200 {
1201 m_geom->GetVertex(i)->GetCoords(x[0][0], x[0][1], x[0][2]);
1202 m_geom->GetVertex((i + 2) % m_geom->GetNumVerts())
1203 ->GetCoords(x[1][0], x[1][1], x[1][2]);
1204 if (m_edgeNormal[i][0] * (x[1][d0] - x[0][d0]) <
1205 m_edgeNormal[i][1] * (x[0][d1] - x[1][d1]))
1206 {
1207 direction = -1;
1208 }
1209 break;
1210 }
1211 }
1212 }
1213 if (direction == -1)
1214 {
1215 for (size_t i = 0; i < m_geom->GetNumVerts(); ++i)
1216 {
1217 if (m_hasEdgeNormal[i])
1218 {
1219 m_edgeNormal[i][0] = -m_edgeNormal[i][0];
1220 m_edgeNormal[i][1] = -m_edgeNormal[i][1];
1221 }
1222 }
1223 }
1224 }
1225
1226 std::array<NekDouble, 3> vertex;
1227 for (size_t i = 0; i < m_geom->GetNumVerts(); ++i)
1228 {
1229 int i1 = (i + 1) % m_geom->GetNumVerts();
1230 if (m_geom->GetVertex(i)->GetGlobalID() <
1232 {
1233 m_geom->GetVertex(i)->GetCoords(vertex[0], vertex[1], vertex[2]);
1234 }
1235 else
1236 {
1237 m_geom->GetVertex(i1)->GetCoords(vertex[0], vertex[1], vertex[2]);
1238 }
1239 if (!m_hasEdgeNormal[i])
1240 {
1241 nc = 0; // not sure
1242 continue;
1243 }
1244 // s is the signed distance from the edge times its length L, the
1245 // length of the normal. Both elements sharing the edge use the same
1246 // vertex and exactly opposite normals, so their values of s are
1247 // exactly opposite: the test s < 0 never rejects a point in both, and
1248 // a point off the edge passes it only in the element on its side.
1249 // A point that fails by less than kGeomFactorsTol * L is just
1250 // outside: its distance is returned in edgeDist, so that
1251 // ContainsPoint can still offer the element as the nearest one.
1252 NekDouble n2 = m_edgeNormal[i][0] * m_edgeNormal[i][0] +
1253 m_edgeNormal[i][1] * m_edgeNormal[i][1];
1254 NekDouble s = m_edgeNormal[i][0] * (gloCoord[d0] - vertex[d0]) +
1255 m_edgeNormal[i][1] * (gloCoord[d1] - vertex[d1]);
1256 if (s < -NekConstants::kGeomFactorsTol * n2)
1257 {
1258 return -1; // outside
1259 }
1260 if (s < 0.)
1261 {
1262 nearDist = std::max(nearDist, -s / std::sqrt(n2));
1263 }
1264 }
1265 if (nearDist >= 0.)
1266 {
1267 edgeDist = nearDist;
1268 return -1; // just outside
1269 }
1270 // 3D manifold needs to check the distance
1271 if (m_geom->GetCoordim() == 3)
1272 {
1273 nc = 0;
1274 }
1275 // nc: 1 (side element), 0 (maybe inside), -1 (outside)
1276 return nc;
1277}
PointGeom * GetVertex(int i) const
Get vertex i of this object.
Definition Geometry.h:495
int GetCoordim() const
Dimension of the space this object is embedded in.
Definition Geometry.h:447
int GetNumVerts() const
Get the number of vertices of this object.
Definition Geometry.h:520
Geometry1D * GetEdge(int i) const
Get edge i of this object.
Definition Geometry.h:500
bool m_edgeNormalBuilt
2D only: inward edge normals used to reject points outside straight-sided elements....
std::array< std::array< NekDouble, 2 >, kMaxGeomVerts > m_edgeNormal
std::array< bool, kMaxGeomVerts > m_hasEdgeNormal
void GetCoords(NekDouble &x, NekDouble &y, NekDouble &z)
Definition PointGeom.cpp:84
static const NekDouble kGeomFactorsTol
std::array< int, kMaxGeomDim > m_manifold
2D only: coordinate directions spanning the manifold.

References Nektar::StdRegions::StdExpansion::GetBasis(), Nektar::SpatialDomains::Geometry::GetCoordim(), Nektar::SpatialDomains::PointGeom::GetCoords(), Nektar::SpatialDomains::Geometry::GetEdge(), Nektar::SpatialDomains::Geometry::GetGlobalID(), Nektar::SpatialDomains::Geometry::GetNumVerts(), Nektar::SpatialDomains::Geometry::GetVertex(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::NekConstants::kGeomFactorsTol, Nektar::SpatialDomains::GeometryLocator::m_edgeNormal, Nektar::SpatialDomains::GeometryLocator::m_edgeNormalBuilt, Nektar::SpatialDomains::GeometryLocator::m_geom, Nektar::SpatialDomains::GeometryLocator::m_hasEdgeNormal, Nektar::SpatialDomains::GeometryLocator::m_iso, and Nektar::SpatialDomains::IsoParam::m_manifold.

◆ v_CalculateInverseIsoParam()

void Nektar::SpatialDomains::GeometryLocator2D::v_CalculateInverseIsoParam ( )
overrideprotectedvirtual

Nothing to do by default. Build() drives this for every shape, but only the 2D and 3D inverse maps are expressed through an inverted coefficient matrix; a segment inverts \(\chi\) in closed form straight from its quadrature points.

See also
Geometry1D::v_GetLocCoords

Nothing to do by default. Build() drives this for every shape, but only the 2D and 3D inverse maps are expressed through an inverted coefficient matrix; a segment inverts \(\chi\) in closed form straight from its quadrature points.

See also
Geometry1D::v_GetLocCoords

Reimplemented from Nektar::SpatialDomains::GeometryLocator.

Definition at line 1158 of file GeometryLocator.cpp.

1159{
1160 NekDouble Jac = m_iso.m_coeff[0][1] * m_iso.m_coeff[1][2] -
1161 m_iso.m_coeff[1][1] * m_iso.m_coeff[0][2];
1162 Jac = 1. / Jac;
1163 // a12, -a02, -a11, a01
1164 m_invIsoParam[0][0] = m_iso.m_coeff[1][2] * Jac;
1165 m_invIsoParam[0][1] = -m_iso.m_coeff[0][2] * Jac;
1166 m_invIsoParam[1][0] = -m_iso.m_coeff[1][1] * Jac;
1167 m_invIsoParam[1][1] = m_iso.m_coeff[0][1] * Jac;
1168}
std::array< std::array< NekDouble, kMaxGeomDim >, kMaxGeomDim > m_invIsoParam
Inverse of the linear part of m_iso, for regular elements.

References Nektar::SpatialDomains::IsoParam::m_coeff, Nektar::SpatialDomains::GeometryLocator::m_invIsoParam, and Nektar::SpatialDomains::GeometryLocator::m_iso.

◆ v_FindDistance()

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

Reimplemented from Nektar::SpatialDomains::GeometryLocator.

Definition at line 919 of file GeometryLocator.cpp.

921{
922 GeomType Gtype = m_geom->CalcGeomType();
923 if (Gtype == eRegular)
924 {
925 xiOut = Array<OneD, NekDouble>(2, 0.0);
926
927 GetLocCoords(xs, xiOut);
929
930 Array<OneD, NekDouble> gloCoord(3);
931 gloCoord[0] = m_geom->GetCoord(0, xiOut);
932 gloCoord[1] = m_geom->GetCoord(1, xiOut);
933 gloCoord[2] = m_geom->GetCoord(2, xiOut);
934
935 return sqrt((xs[0] - gloCoord[0]) * (xs[0] - gloCoord[0]) +
936 (xs[1] - gloCoord[1]) * (xs[1] - gloCoord[1]) +
937 (xs[2] - gloCoord[2]) * (xs[2] - gloCoord[2]));
938 }
939 // If deformed edge then the inverse mapping is non-linear so need to
940 // numerically solve for the local coordinate
941 else if (Gtype == eDeformed)
942 {
943 // Choose starting based on closest quad
944 Array<OneD, NekDouble> xi(2, 0.0), eta(2, 0.0);
946
947 // Armijo constants:
948 // https://en.wikipedia.org/wiki/Backtracking_line_search
949 const NekDouble c1 = 1e-4, c2 = 0.9;
950
951 int nq = m_geom->GetXmap()->GetTotPoints();
952
953 Array<OneD, NekDouble> x(nq), y(nq), z(nq);
957
958 Array<OneD, NekDouble> xderxi1(nq, 0.0), yderxi1(nq, 0.0),
959 zderxi1(nq, 0.0), xderxi2(nq, 0.0), yderxi2(nq, 0.0),
960 zderxi2(nq, 0.0), xderxi1xi1(nq, 0.0), yderxi1xi1(nq, 0.0),
961 zderxi1xi1(nq, 0.0), xderxi1xi2(nq, 0.0), yderxi1xi2(nq, 0.0),
962 zderxi1xi2(nq, 0.0), xderxi2xi1(nq, 0.0), yderxi2xi1(nq, 0.0),
963 zderxi2xi1(nq, 0.0), xderxi2xi2(nq, 0.0), yderxi2xi2(nq, 0.0),
964 zderxi2xi2(nq, 0.0);
965
966 // Get first & second derivatives & partial derivatives of x,y,z values
967 std::array<NekDouble, 3> xc_derxi, yc_derxi, zc_derxi;
968
969 m_geom->GetXmap()->PhysDeriv(x, xderxi1, xderxi2);
970 m_geom->GetXmap()->PhysDeriv(y, yderxi1, yderxi2);
971 m_geom->GetXmap()->PhysDeriv(z, zderxi1, zderxi2);
972
973 m_geom->GetXmap()->PhysDeriv(xderxi1, xderxi1xi1, xderxi1xi2);
974 m_geom->GetXmap()->PhysDeriv(yderxi1, yderxi1xi1, yderxi1xi2);
975 m_geom->GetXmap()->PhysDeriv(zderxi1, zderxi1xi1, zderxi1xi2);
976
977 m_geom->GetXmap()->PhysDeriv(yderxi2, yderxi2xi1, yderxi2xi2);
978 m_geom->GetXmap()->PhysDeriv(xderxi2, xderxi2xi1, xderxi2xi2);
979 m_geom->GetXmap()->PhysDeriv(zderxi2, zderxi2xi1, zderxi2xi2);
980
981 // Minimisation loop (Quasi-newton method)
982 NekDouble fx_prev = std::numeric_limits<NekDouble>::max();
983 for (int i = 0; i < NekConstants::kNewtonIterations; ++i)
984 {
985 // Compute the objective function, f(x_k) and its derivatives
986 NekDouble xc = m_geom->GetXmap()->PhysEvaluate(xi, x, xc_derxi);
987 NekDouble yc = m_geom->GetXmap()->PhysEvaluate(xi, y, yc_derxi);
988 NekDouble zc = m_geom->GetXmap()->PhysEvaluate(xi, z, zc_derxi);
989
990 NekDouble xc_derxi1xi1 =
991 m_geom->GetXmap()->PhysEvaluate(xi, xderxi1xi1);
992 NekDouble yc_derxi1xi1 =
993 m_geom->GetXmap()->PhysEvaluate(xi, yderxi1xi1);
994 NekDouble zc_derxi1xi1 =
995 m_geom->GetXmap()->PhysEvaluate(xi, zderxi1xi1);
996
997 NekDouble xc_derxi1xi2 =
998 m_geom->GetXmap()->PhysEvaluate(xi, xderxi1xi2);
999 NekDouble yc_derxi1xi2 =
1000 m_geom->GetXmap()->PhysEvaluate(xi, yderxi1xi2);
1001 NekDouble zc_derxi1xi2 =
1002 m_geom->GetXmap()->PhysEvaluate(xi, zderxi1xi2);
1003
1004 NekDouble xc_derxi2xi2 =
1005 m_geom->GetXmap()->PhysEvaluate(xi, xderxi2xi2);
1006 NekDouble yc_derxi2xi2 =
1007 m_geom->GetXmap()->PhysEvaluate(xi, yderxi2xi2);
1008 NekDouble zc_derxi2xi2 =
1009 m_geom->GetXmap()->PhysEvaluate(xi, zderxi2xi2);
1010
1011 // Objective function is the distance to the search point
1012 NekDouble xdiff = xc - xs[0];
1013 NekDouble ydiff = yc - xs[1];
1014 NekDouble zdiff = zc - xs[2];
1015
1016 NekDouble fx = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
1017
1018 NekDouble fx_derxi1 = 2.0 * xdiff * xc_derxi[0] +
1019 2.0 * ydiff * yc_derxi[0] +
1020 2.0 * zdiff * zc_derxi[0];
1021
1022 NekDouble fx_derxi2 = 2.0 * xdiff * xc_derxi[1] +
1023 2.0 * ydiff * yc_derxi[1] +
1024 2.0 * zdiff * zc_derxi[1];
1025
1026 NekDouble fx_derxi1xi1 =
1027 2.0 * xdiff * xc_derxi1xi1 + 2.0 * xc_derxi[0] * xc_derxi[0] +
1028 2.0 * ydiff * yc_derxi1xi1 + 2.0 * yc_derxi[0] * yc_derxi[0] +
1029 2.0 * zdiff * zc_derxi1xi1 + 2.0 * zc_derxi[0] * zc_derxi[0];
1030
1031 NekDouble fx_derxi1xi2 =
1032 2.0 * xdiff * xc_derxi1xi2 + 2.0 * xc_derxi[1] * xc_derxi[0] +
1033 2.0 * ydiff * yc_derxi1xi2 + 2.0 * yc_derxi[1] * yc_derxi[0] +
1034 2.0 * zdiff * zc_derxi1xi2 + 2.0 * zc_derxi[1] * zc_derxi[0];
1035
1036 NekDouble fx_derxi2xi2 =
1037 2.0 * xdiff * xc_derxi2xi2 + 2.0 * xc_derxi[1] * xc_derxi[1] +
1038 2.0 * ydiff * yc_derxi2xi2 + 2.0 * yc_derxi[1] * yc_derxi[1] +
1039 2.0 * zdiff * zc_derxi2xi2 + 2.0 * zc_derxi[1] * zc_derxi[1];
1040
1041 // Jacobian
1042 NekDouble jac[2];
1043 jac[0] = fx_derxi1;
1044 jac[1] = fx_derxi2;
1045
1046 // Inverse of 2x2 hessian
1047 NekDouble hessInv[2][2];
1048
1049 NekDouble det =
1050 1 / (fx_derxi1xi1 * fx_derxi2xi2 - fx_derxi1xi2 * fx_derxi1xi2);
1051 hessInv[0][0] = det * fx_derxi2xi2;
1052 hessInv[0][1] = det * -fx_derxi1xi2;
1053 hessInv[1][0] = det * -fx_derxi1xi2;
1054 hessInv[1][1] = det * fx_derxi1xi1;
1055
1056 // Check for convergence
1057 if (std::abs(fx - fx_prev) < 1e-12)
1058 {
1059 fx_prev = fx;
1060 break;
1061 }
1062 else
1063 {
1064 fx_prev = fx;
1065 }
1066
1067 NekDouble gamma = 1.0;
1068 bool conv = false;
1069
1070 // Search direction: Newton's method
1071 NekDouble pk[2];
1072 pk[0] = -(hessInv[0][0] * jac[0] + hessInv[1][0] * jac[1]);
1073 pk[1] = -(hessInv[0][1] * jac[0] + hessInv[1][1] * jac[1]);
1074
1075 // Backtracking line search
1076 while (gamma > 1e-10)
1077 {
1078 Array<OneD, NekDouble> xi_pk(2);
1079 xi_pk[0] = xi[0] + pk[0] * gamma;
1080 xi_pk[1] = xi[1] + pk[1] * gamma;
1081
1082 Array<OneD, NekDouble> eta_pk(2, 0.0);
1083 m_geom->GetXmap()->LocCoordToLocCollapsed(xi_pk, eta_pk);
1084
1085 if (eta_pk[0] <
1086 (-1 - std::numeric_limits<NekDouble>::epsilon()) ||
1087 eta_pk[0] >
1088 (1 + std::numeric_limits<NekDouble>::epsilon()) ||
1089 eta_pk[1] <
1090 (-1 - std::numeric_limits<NekDouble>::epsilon()) ||
1091 eta_pk[1] > (1 + std::numeric_limits<NekDouble>::epsilon()))
1092 {
1093 gamma /= 2.0;
1094 continue;
1095 }
1096
1097 std::array<NekDouble, 3> xc_pk_derxi, yc_pk_derxi, zc_pk_derxi;
1098
1099 NekDouble xc_pk =
1100 m_geom->GetXmap()->PhysEvaluate(xi_pk, x, xc_pk_derxi);
1101 NekDouble yc_pk =
1102 m_geom->GetXmap()->PhysEvaluate(xi_pk, y, yc_pk_derxi);
1103 NekDouble zc_pk =
1104 m_geom->GetXmap()->PhysEvaluate(xi_pk, z, zc_pk_derxi);
1105
1106 NekDouble xc_pk_diff = xc_pk - xs[0];
1107 NekDouble yc_pk_diff = yc_pk - xs[1];
1108 NekDouble zc_pk_diff = zc_pk - xs[2];
1109
1110 NekDouble fx_pk = xc_pk_diff * xc_pk_diff +
1111 yc_pk_diff * yc_pk_diff +
1112 zc_pk_diff * zc_pk_diff;
1113
1114 NekDouble fx_pk_derxi1 = 2.0 * xc_pk_diff * xc_pk_derxi[0] +
1115 2.0 * yc_pk_diff * yc_pk_derxi[0] +
1116 2.0 * zc_pk_diff * zc_pk_derxi[0];
1117
1118 NekDouble fx_pk_derxi2 = 2.0 * xc_pk_diff * xc_pk_derxi[1] +
1119 2.0 * yc_pk_diff * yc_pk_derxi[1] +
1120 2.0 * zc_pk_diff * zc_pk_derxi[1];
1121
1122 // Check Wolfe conditions using Armijo constants
1123 // https://en.wikipedia.org/wiki/Wolfe_conditions
1124 NekDouble tmp = pk[0] * fx_derxi1 + pk[1] * fx_derxi2;
1125 NekDouble tmp2 = pk[0] * fx_pk_derxi1 + pk[1] * fx_pk_derxi2;
1126 if ((fx_pk - (fx + c1 * gamma * tmp)) <
1127 std::numeric_limits<NekDouble>::epsilon() &&
1128 (-tmp2 - (-c2 * tmp)) <
1129 std::numeric_limits<NekDouble>::epsilon())
1130 {
1131 conv = true;
1132 break;
1133 }
1134
1135 gamma /= 2.0;
1136 }
1137
1138 if (!conv)
1139 {
1140 break;
1141 }
1142
1143 xi[0] += gamma * pk[0];
1144 xi[1] += gamma * pk[1];
1145 }
1146
1147 xiOut = xi;
1148 return sqrt(fx_prev);
1149 }
1150 else
1151 {
1152 NEKERROR(ErrorUtil::efatal, "Geometry type unknown");
1153 }
1154
1155 return -1.0;
1156}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
NekDouble GetCoord(const int i, const Array< OneD, const NekDouble > &Lcoord)
Evaluate the mapping: physical coordinate in direction i at the local collapsed coordinate Lcoord.
Definition Geometry.h:615
GeomType CalcGeomType()
Classify whether this shape is regular or deformed.
Definition Geometry.cpp:151
const Array< OneD, const NekDouble > & GetCoeffs(const int i)
The coefficients of in coordinate direction i, filling them first if that has not happened yet.
Definition Geometry.h:576
NekDouble GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
Determine the local collapsed coordinates corresponding to a given Cartesian coordinate.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Backward transformation from coefficient space to physical space.
void LocCollapsedToLocCoord(const Array< OneD, const NekDouble > &eta, Array< OneD, NekDouble > &xi)
Convert local collapsed coordinates eta into local cartesian coordinate xi.
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::StdRegions::StdExpansion::BwdTrans(), Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::GeometryLocator::ClampLocCoords(), Nektar::SpatialDomains::eDeformed, Nektar::ErrorUtil::efatal, Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::GetCoeffs(), Nektar::SpatialDomains::Geometry::GetCoord(), Nektar::SpatialDomains::GeometryLocator::GetLocCoords(), Nektar::SpatialDomains::Geometry::GetShapeDim(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::NekConstants::kNewtonIterations, Nektar::StdRegions::StdExpansion::LocCollapsedToLocCoord(), Nektar::StdRegions::StdExpansion::LocCoordToLocCollapsed(), Nektar::SpatialDomains::GeometryLocator::m_geom, NEKERROR, Nektar::StdRegions::StdExpansion::PhysDeriv(), Nektar::StdRegions::StdExpansion::PhysEvaluate(), and tinysimd::sqrt().

◆ v_GetLocCoords()

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

Reimplemented from Nektar::SpatialDomains::GeometryLocator.

Definition at line 840 of file GeometryLocator.cpp.

842{
843 NekDouble dist = std::numeric_limits<double>::max();
844 Array<OneD, NekDouble> tmpcoords(2);
845 tmpcoords[0] = coords[m_iso.m_manifold[0]];
846 tmpcoords[1] = coords[m_iso.m_manifold[1]];
847 GeomType Gtype = m_geom->CalcGeomType();
848 if (Gtype == eRegular)
849 {
850 tmpcoords[0] -= m_iso.m_coeff[0][0];
851 tmpcoords[1] -= m_iso.m_coeff[1][0];
852 Lcoords[0] = m_invIsoParam[0][0] * tmpcoords[0] +
853 m_invIsoParam[0][1] * tmpcoords[1];
854 Lcoords[1] = m_invIsoParam[1][0] * tmpcoords[0] +
855 m_invIsoParam[1][1] * tmpcoords[1];
856 }
857 else if (m_straightEdge)
858 {
859 SolveStraightEdgeQuad(tmpcoords, Lcoords);
860 }
861 else if (Gtype == eDeformed)
862 {
863 m_geom->FillGeom();
864 // Determine nearest point of coords to values in m_geom->GetXmap()
865 int npts = m_geom->GetXmap()->GetTotPoints();
866 Array<OneD, NekDouble> ptsx(npts), ptsy(npts);
867 Array<OneD, NekDouble> tmpx(npts), tmpy(npts);
868
869 // Determine 3D manifold orientation
871 ptsx);
873 ptsy);
874
875 // Start from the nearest quadrature point: from the centre, the
876 // iteration can diverge for points near the corners of strongly
877 // curved elements
878 Vmath::Sadd(npts, -tmpcoords[0], ptsx, 1, tmpx, 1);
879 Vmath::Sadd(npts, -tmpcoords[1], ptsy, 1, tmpy, 1);
880 Vmath::Vmul(npts, tmpx, 1, tmpx, 1, tmpx, 1);
881 Vmath::Vvtvp(npts, tmpy, 1, tmpy, 1, tmpx, 1, tmpx, 1);
882
883 int min_i = Vmath::Imin(npts, tmpx, 1);
884
885 const Array<OneD, const NekDouble> za = m_geom->GetXmap()->GetPoints(0);
886 const Array<OneD, const NekDouble> zb = m_geom->GetXmap()->GetPoints(1);
887 Array<OneD, NekDouble> eta(2, 0.);
888 eta[0] = za[min_i % za.size()];
889 eta[1] = zb[min_i / za.size()];
890 m_geom->GetXmap()->LocCollapsedToLocCoord(eta, Lcoords);
891
892 // Perform newton iteration to find local coordinates
893 NewtonIterationForLocCoord(tmpcoords, ptsx, ptsy, Lcoords, dist);
894 }
895 if (m_geom->GetCoordim() == 3)
896 {
897 Array<OneD, NekDouble> eta(2, 0.), xi(2, 0.);
898 m_geom->GetXmap()->LocCoordToLocCollapsed(Lcoords, eta);
899 ClampLocCoords(eta, m_geom->GetShapeDim(), 0.);
901 int npts = m_geom->GetXmap()->GetTotPoints();
902 Array<OneD, NekDouble> ptsz(npts);
904 ptsz);
905 NekDouble z = m_geom->GetXmap()->PhysEvaluate(xi, ptsz) -
906 coords[m_iso.m_manifold[2]];
907 if (Gtype == eDeformed)
908 {
909 dist = sqrt(z * z + dist * dist);
910 }
911 else
912 {
913 dist = fabs(z);
914 }
915 }
916 return dist;
917}
void FillGeom()
Gather the coefficients of from this object's boundary, unless that has already been done.
Definition Geometry.h:591
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &dist)
void SolveStraightEdgeQuad(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
const Array< OneD, const NekDouble > & GetPoints(const int dir) const
This function returns a pointer to the array containing the quadrature points in dir direction.
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.hpp:74
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.hpp:368
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
Definition Vmath.hpp:707
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.hpp:196

References Nektar::StdRegions::StdExpansion::BwdTrans(), Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::GeometryLocator::ClampLocCoords(), Nektar::SpatialDomains::eDeformed, Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::FillGeom(), Nektar::SpatialDomains::Geometry::GetCoeffs(), Nektar::SpatialDomains::Geometry::GetCoordim(), Nektar::StdRegions::StdExpansion::GetPoints(), Nektar::SpatialDomains::Geometry::GetShapeDim(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::SpatialDomains::Geometry::GetXmap(), Vmath::Imin(), Nektar::StdRegions::StdExpansion::LocCollapsedToLocCoord(), Nektar::StdRegions::StdExpansion::LocCoordToLocCollapsed(), Nektar::SpatialDomains::IsoParam::m_coeff, Nektar::SpatialDomains::GeometryLocator::m_geom, Nektar::SpatialDomains::GeometryLocator::m_invIsoParam, Nektar::SpatialDomains::GeometryLocator::m_iso, Nektar::SpatialDomains::IsoParam::m_manifold, Nektar::SpatialDomains::GeometryLocator::m_straightEdge, NewtonIterationForLocCoord(), Nektar::StdRegions::StdExpansion::PhysEvaluate(), Vmath::Sadd(), SolveStraightEdgeQuad(), tinysimd::sqrt(), Vmath::Vmul(), and Vmath::Vvtvp().

◆ v_PreSolveStraightEdge()

void Nektar::SpatialDomains::GeometryLocator2D::v_PreSolveStraightEdge ( )
overrideprotectedvirtual

Only the quadrilateral has a straight-edged solve to prepare for.

Only the quadrilateral has a straight-edged solve to prepare for.

Reimplemented from Nektar::SpatialDomains::GeometryLocator.

Definition at line 1279 of file GeometryLocator.cpp.

1280{
1281 int i0, i1, j1, j2;
1282 if (fabs(m_iso.m_coeff[0][3]) >= fabs(m_iso.m_coeff[1][3]))
1283 {
1284 i0 = 0;
1285 i1 = 1;
1286 }
1287 else
1288 {
1289 i1 = 0;
1290 i0 = 1;
1291 m_straightEdge |= 2;
1292 }
1293 NekDouble gamma = m_iso.m_coeff[i1][3] / m_iso.m_coeff[i0][3];
1294 std::vector<NekDouble> c(3);
1295 for (int i = 0; i < 3; ++i)
1296 {
1297 c[i] = m_iso.m_coeff[i1][i] - gamma * m_iso.m_coeff[i0][i];
1298 }
1299 if (fabs(c[1]) >= fabs(c[2]))
1300 {
1301 j1 = 1;
1302 j2 = 2;
1303 }
1304 else
1305 {
1306 j1 = 2;
1307 j2 = 1;
1308 m_straightEdge |= 4;
1309 }
1310 NekDouble beta = c[j2] / c[j1];
1311 if (i0 == 1)
1312 {
1313 m_iso.m_coeff[0] = m_iso.m_coeff[1];
1314 }
1315 if (j1 == 2)
1316 {
1317 NekDouble temp = m_iso.m_coeff[0][j1];
1318 m_iso.m_coeff[0][j1] = m_iso.m_coeff[0][j2];
1319 m_iso.m_coeff[0][j2] = temp;
1320 }
1321 m_iso.m_coeff[0][2] -= m_iso.m_coeff[0][1] * beta;
1322 m_iso.m_coeff[1][0] = c[0];
1323 m_iso.m_coeff[1][1] = 1. / c[j1];
1324 m_iso.m_coeff[1][2] = beta;
1325 m_iso.m_coeff[1][3] = gamma;
1326}

References Nektar::LibUtilities::beta, Nektar::SpatialDomains::IsoParam::m_coeff, Nektar::SpatialDomains::GeometryLocator::m_iso, and Nektar::SpatialDomains::GeometryLocator::m_straightEdge.