46 namespace SpatialDomains
56 "Coordinate dimension should be at least 3 for a 3D geometry.");
106 const Array<OneD, const NekDouble> &coords,
107 const Array<OneD, const NekDouble> &ptsx,
108 const Array<OneD, const NekDouble> &ptsy,
109 const Array<OneD, const NekDouble> &ptsz,
110 Array<OneD, NekDouble> &Lcoords,
114 const int MaxIterations = 51;
120 Array<OneD, const NekDouble > Jac =
129 NekDouble derx_1, derx_2, derx_3, dery_1, dery_2, dery_3,
130 derz_1, derz_2, derz_3, jac;
133 NekDouble init0 = Lcoords[0], init1 = Lcoords[1], init2 = Lcoords[2];
135 Array<OneD, NekDouble> DxD1(ptsx.num_elements());
136 Array<OneD, NekDouble> DxD2(ptsx.num_elements());
137 Array<OneD, NekDouble> DxD3(ptsx.num_elements());
138 Array<OneD, NekDouble> DyD1(ptsx.num_elements());
139 Array<OneD, NekDouble> DyD2(ptsx.num_elements());
140 Array<OneD, NekDouble> DyD3(ptsx.num_elements());
141 Array<OneD, NekDouble> DzD1(ptsx.num_elements());
142 Array<OneD, NekDouble> DzD2(ptsx.num_elements());
143 Array<OneD, NekDouble> DzD3(ptsx.num_elements());
146 m_xmap->PhysDeriv(ptsx,DxD1,DxD2,DxD3);
147 m_xmap->PhysDeriv(ptsy,DyD1,DyD2,DyD3);
148 m_xmap->PhysDeriv(ptsz,DzD1,DzD2,DzD3);
151 Array<OneD, DNekMatSharedPtr > I(3);
152 Array<OneD, NekDouble> eta(3);
156 while(cnt++ < MaxIterations)
159 m_xmap->LocCoordToLocCollapsed(Lcoords,eta);
160 I[0] =
m_xmap->GetBasis(0)->GetI(eta );
161 I[1] =
m_xmap->GetBasis(1)->GetI(eta+1);
162 I[2] =
m_xmap->GetBasis(2)->GetI(eta+2);
165 xmap =
m_xmap->PhysEvaluate(I, ptsx);
166 ymap =
m_xmap->PhysEvaluate(I, ptsy);
167 zmap =
m_xmap->PhysEvaluate(I, ptsz);
169 F1 = coords[0] - xmap;
170 F2 = coords[1] - ymap;
171 F3 = coords[2] - zmap;
173 if(F1*F1 + F2*F2 + F3*F3 < ScaledTol)
175 resid = sqrt(F1*F1 + F2*F2 + F3*F3);
180 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
181 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
182 derx_3 =
m_xmap->PhysEvaluate(I, DxD3);
183 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
184 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
185 dery_3 =
m_xmap->PhysEvaluate(I, DyD3);
186 derz_1 =
m_xmap->PhysEvaluate(I, DzD1);
187 derz_2 =
m_xmap->PhysEvaluate(I, DzD2);
188 derz_3 =
m_xmap->PhysEvaluate(I, DzD3);
190 jac = derx_1*(dery_2*derz_3 - dery_3*derz_2)
191 - derx_2*(dery_1*derz_3 - dery_3*derz_1)
192 + derx_3*(dery_1*derz_2 - dery_2*derz_1);
196 Lcoords[0] = Lcoords[0]
197 +((dery_2*derz_3 - dery_3*derz_2)*(coords[0]-xmap)
198 - (derx_2*derz_3 - derx_3*derz_2)*(coords[1]-ymap)
199 + (derx_2*dery_3 - derx_3*dery_2)*(coords[2]-zmap)
202 Lcoords[1] = Lcoords[1]
203 -((dery_1*derz_3 - dery_3*derz_1)*(coords[0]-xmap)
204 - (derx_1*derz_3 - derx_3*derz_1)*(coords[1]-ymap)
205 + (derx_1*dery_3 - derx_3*dery_1)*(coords[2]-zmap)
208 Lcoords[2] = Lcoords[2]
209 +((dery_1*derz_2 - dery_2*derz_1)*(coords[0]-xmap)
210 - (derx_1*derz_2 - derx_2*derz_1)*(coords[1]-ymap)
211 + (derx_1*dery_2 - derx_2*dery_1)*(coords[2]-zmap)
214 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
215 fabs(Lcoords[0]) > LcoordDiv)
221 resid = sqrt(F1*F1 + F2*F2 + F3*F3);
223 if(cnt >= MaxIterations)
225 Array<OneD, NekDouble> collCoords(3);
226 m_xmap->LocCoordToLocCollapsed(Lcoords,collCoords);
229 if((collCoords[0] >= -1.0 && collCoords[0] <= 1.0)&&
230 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0)&&
231 (collCoords[2] >= -1.0 && collCoords[2] <= 1.0))
233 std::ostringstream ss;
235 ss <<
"Reached MaxIterations (" << MaxIterations <<
") in Newton iteration ";
236 ss <<
"Init value ("<< setprecision(4) << init0 <<
"," << init1<<
"," << init2 <<
") ";
237 ss <<
"Fin value ("<<Lcoords[0] <<
"," << Lcoords[1]<<
"," << Lcoords[2] <<
") ";
238 ss <<
"Resid = " << resid <<
" Tolerance = " << sqrt(ScaledTol) ;
264 int nFaceCoeffs =
m_faces[i]->GetXmap()->GetNcoeffs();
266 Array<OneD, unsigned int> mapArray (nFaceCoeffs);
267 Array<OneD, int> signArray(nFaceCoeffs);
271 m_xmap->GetFaceToElementMap(
278 m_xmap->GetFaceToElementMap(
286 const Array<OneD, const NekDouble> &coeffs =
289 for (k = 0; k < nFaceCoeffs; k++)
314 if (
m_xmap->GetBasisNumModes(0) != 2 ||
315 m_xmap->GetBasisNumModes(1) != 2 ||
316 m_xmap->GetBasisNumModes(2) != 2)
333 const int i,
const Array<OneD, const NekDouble> &Lcoord)
336 "Geometry is not in physical space");
338 Array<OneD, NekDouble> tmp(
m_xmap->GetTotPoints());
341 return m_xmap->PhysEvaluate(Lcoord, tmp);
363 "Vertex ID must be between 0 and "+
364 boost::lexical_cast<
string>(
m_verts.size() - 1));
382 "Edge ID must be between 0 and "+
383 boost::lexical_cast<
string>(
m_edges.size() - 1));
394 "Edge ID must be between 0 and "+
395 boost::lexical_cast<
string>(
m_edges.size() - 1));
405 "Edge ID must be between 0 and "+
406 boost::lexical_cast<
string>(
m_edges.size() - 1));
415 ASSERTL2((i >=0) && (i <= 5),
"Edge id must be between 0 and 4");
425 "Face ID must be between 0 and "+
426 boost::lexical_cast<
string>(
m_faces.size() - 1));
436 "Face ID must be between 0 and "+
437 boost::lexical_cast<
string>(
m_faces.size() - 1));
455 return m_xmap->GetBasis(i);
471 for (i=0,edgeIter =
m_edges.begin(); edgeIter !=
m_edges.end(); ++edgeIter,++i)
473 if (*edgeIter == edge)
521 std::list<CompToElmt>::const_iterator def;