47 namespace SpatialDomains
50 Geometry2D::Geometry2D()
58 "Coordinate dimension should be at least 2 for a 2D geometry");
73 const int MaxIterations = 51;
87 NekDouble derx_1, derx_2, dery_1, dery_2, jac;
90 NekDouble init0 = Lcoords[0], init1 = Lcoords[1];
98 m_xmap->PhysDeriv(ptsx, DxD1, DxD2);
99 m_xmap->PhysDeriv(ptsy, DyD1, DyD2);
107 while (cnt++ < MaxIterations)
110 m_xmap->LocCoordToLocCollapsed(Lcoords, eta);
111 I[0] =
m_xmap->GetBasis(0)->GetI(eta);
112 I[1] =
m_xmap->GetBasis(1)->GetI(eta + 1);
115 xmap =
m_xmap->PhysEvaluate(I, ptsx);
116 ymap =
m_xmap->PhysEvaluate(I, ptsy);
118 F1 = coords[0] - xmap;
119 F2 = coords[1] - ymap;
121 if (F1 * F1 + F2 * F2 < ScaledTol)
123 resid = sqrt(F1 * F1 + F2 * F2);
128 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
129 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
130 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
131 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
133 jac = dery_2 * derx_1 - dery_1 * derx_2;
139 (dery_2 * (coords[0] - xmap) - derx_2 * (coords[1] - ymap)) / jac;
143 (-dery_1 * (coords[0] - xmap) + derx_1 * (coords[1] - ymap)) / jac;
145 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv)
151 resid = sqrt(F1 * F1 + F2 * F2);
153 if (cnt >= MaxIterations)
156 m_xmap->LocCoordToLocCollapsed(Lcoords, collCoords);
159 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
160 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0))
162 std::ostringstream ss;
164 ss <<
"Reached MaxIterations (" << MaxIterations
165 <<
") in Newton iteration ";
166 ss <<
"Init value (" << setprecision(4) << init0 <<
"," << init1
169 ss <<
"Fin value (" << Lcoords[0] <<
"," << Lcoords[1] <<
"," 171 ss <<
"Resid = " << resid <<
" Tolerance = " << sqrt(ScaledTol);
173 WARNINGL1(cnt < MaxIterations, ss.str());
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
#define ASSERTL0(condition, msg)
Base class for shape geometry information.
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
virtual int v_GetShapeDim() const
Get the object's shape dimension.
virtual Geometry1DSharedPtr v_GetEdge(int i) const
Returns edge i of this object.
std::vector< StdRegions::Orientation > m_eorient
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
std::shared_ptr< PointGeom > PointGeomSharedPtr
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 int v_GetNumVerts() const
Get the number of vertices of this object.
#define WARNINGL1(condition, msg)
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
std::shared_ptr< Curve > CurveSharedPtr
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
virtual PointGeomSharedPtr v_GetVertex(int i) const
virtual int v_GetNumEdges() const
Get the number of edges of this object.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
int m_coordim
Coordinate dimension of this geometry object.