38 #include <boost/shared_ptr.hpp>
43 namespace SpatialDomains
53 "Coordinate dimension should be at least 2 for a 2D geometry");
108 const int MaxIterations = 51;
122 NekDouble derx_1, derx_2, dery_1, dery_2,jac;
125 NekDouble init0 = Lcoords[0], init1 = Lcoords[1];
133 m_xmap->PhysDeriv(ptsx,DxD1,DxD2);
134 m_xmap->PhysDeriv(ptsy,DyD1,DyD2);
142 while(cnt++ < MaxIterations)
145 m_xmap->LocCoordToLocCollapsed(Lcoords,eta);
146 I[0] =
m_xmap->GetBasis(0)->GetI(eta);
147 I[1] =
m_xmap->GetBasis(1)->GetI(eta+1);
150 xmap =
m_xmap->PhysEvaluate(I, ptsx);
151 ymap =
m_xmap->PhysEvaluate(I, ptsy);
153 F1 = coords[0] - xmap;
154 F2 = coords[1] - ymap;
156 if(F1*F1 + F2*F2 < ScaledTol)
158 resid = sqrt(F1*F1 + F2*F2);
163 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
164 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
165 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
166 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
168 jac = dery_2*derx_1 - dery_1*derx_2;
172 Lcoords[0] = Lcoords[0] + (dery_2*(coords[0]-xmap) -
173 derx_2*(coords[1]-ymap))/jac;
175 Lcoords[1] = Lcoords[1] + ( - dery_1*(coords[0]-xmap)
176 + derx_1*(coords[1]-ymap))/jac;
178 if(fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv)
184 resid = sqrt(F1*F1 + F2*F2);
186 if(cnt >= MaxIterations)
189 m_xmap->LocCoordToLocCollapsed(Lcoords,collCoords);
192 if((collCoords[0] >= -1.0 && collCoords[0] <= 1.0)&&
193 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0))
195 std::ostringstream ss;
197 ss <<
"Reached MaxIterations (" << MaxIterations
198 <<
") in Newton iteration ";
199 ss <<
"Init value ("<< setprecision(4) << init0 <<
","
200 << init1<<
"," <<
") ";
201 ss <<
"Fin value ("<<Lcoords[0] <<
"," << Lcoords[1]
203 ss <<
"Resid = " << resid <<
" Tolerance = "
214 "This function is only valid for shape type geometries");
221 "This function is only valid for shape type geometries");
230 "This function is only valid for shape type geometries");
237 "This function is only valid for shape type geometries");
245 "This function is only valid for shape type geometries");
253 "This function is only valid for shape type geometries");
260 "This function is only valid for shape type geometries");
268 "This function is only valid for shape type geometries");
275 "This function is only valid for shape type geometries");
282 "This function is only valid for shape type geometries");
289 "This function is only valid for shape type geometries");
303 "This function has not been defined for this geometry");
StdRegions::StdExpansionSharedPtr m_xmap
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
int WhichEdge(SegGeomSharedPtr edge)
Base class for shape geometry information.
GeomFactorsSharedPtr m_geomFactors
virtual int v_WhichFace(Geometry2DSharedPtr face)
const LibUtilities::BasisSharedPtr GetEdgeBasis(const int i)
StdRegions::Orientation GetCartesianEorient(const int i) const
const Geometry2DSharedPtr GetFace(int i) const
virtual int v_WhichEdge(SegGeomSharedPtr edge)
virtual PointGeomSharedPtr v_GetVertex(int i) const
virtual int v_GetShapeDim() const
virtual StdRegions::Orientation v_GetCartesianEorient(const int i) const
virtual const LibUtilities::BasisSharedPtr v_GetEdgeBasis(const int i)
boost::shared_ptr< SegGeom > SegGeomSharedPtr
virtual StdRegions::Orientation v_GetEorient(const int i) const
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)
virtual bool v_ContainsPoint(const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
virtual int v_GetFid() const
StdRegions::Orientation GetFaceOrient(const int i) const
int WhichFace(Geometry2DSharedPtr face)
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
virtual StdRegions::Orientation v_GetFaceOrient(const int i) const
virtual const Geometry2DSharedPtr v_GetFace(int i) const
#define WARNINGL1(condition, msg)
const Geometry1DSharedPtr GetEdge(int i) const
boost::shared_ptr< Geometry1D > Geometry1DSharedPtr
virtual const Geometry1DSharedPtr v_GetEdge(int i) const
boost::shared_ptr< Basis > BasisSharedPtr
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
int m_coordim
coordinate dimension
virtual int v_GetEid(int i) const
boost::shared_ptr< PointGeom > PointGeomSharedPtr