46 namespace SpatialDomains
56 "Coordinate dimension should be at least 3 for a 3D geometry.");
97 const Array<OneD, const NekDouble> &coords,
98 const Array<OneD, const NekDouble> &ptsx,
99 const Array<OneD, const NekDouble> &ptsy,
100 const Array<OneD, const NekDouble> &ptsz,
101 Array<OneD, NekDouble> &Lcoords,
105 const int MaxIterations = 51;
111 Array<OneD, const NekDouble > Jac =
120 NekDouble derx_1, derx_2, derx_3, dery_1, dery_2, dery_3,
121 derz_1, derz_2, derz_3, jac;
124 NekDouble init0 = Lcoords[0], init1 = Lcoords[1], init2 = Lcoords[2];
126 Array<OneD, NekDouble> DxD1(ptsx.num_elements());
127 Array<OneD, NekDouble> DxD2(ptsx.num_elements());
128 Array<OneD, NekDouble> DxD3(ptsx.num_elements());
129 Array<OneD, NekDouble> DyD1(ptsx.num_elements());
130 Array<OneD, NekDouble> DyD2(ptsx.num_elements());
131 Array<OneD, NekDouble> DyD3(ptsx.num_elements());
132 Array<OneD, NekDouble> DzD1(ptsx.num_elements());
133 Array<OneD, NekDouble> DzD2(ptsx.num_elements());
134 Array<OneD, NekDouble> DzD3(ptsx.num_elements());
137 m_xmap->PhysDeriv(ptsx,DxD1,DxD2,DxD3);
138 m_xmap->PhysDeriv(ptsy,DyD1,DyD2,DyD3);
139 m_xmap->PhysDeriv(ptsz,DzD1,DzD2,DzD3);
142 Array<OneD, DNekMatSharedPtr > I(3);
143 Array<OneD, NekDouble> eta(3);
147 while(cnt++ < MaxIterations)
150 m_xmap->LocCoordToLocCollapsed(Lcoords,eta);
151 I[0] =
m_xmap->GetBasis(0)->GetI(eta );
152 I[1] =
m_xmap->GetBasis(1)->GetI(eta+1);
153 I[2] =
m_xmap->GetBasis(2)->GetI(eta+2);
156 xmap =
m_xmap->PhysEvaluate(I, ptsx);
157 ymap =
m_xmap->PhysEvaluate(I, ptsy);
158 zmap =
m_xmap->PhysEvaluate(I, ptsz);
160 F1 = coords[0] - xmap;
161 F2 = coords[1] - ymap;
162 F3 = coords[2] - zmap;
164 if(F1*F1 + F2*F2 + F3*F3 < ScaledTol)
166 resid = sqrt(F1*F1 + F2*F2 + F3*F3);
171 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
172 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
173 derx_3 =
m_xmap->PhysEvaluate(I, DxD3);
174 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
175 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
176 dery_3 =
m_xmap->PhysEvaluate(I, DyD3);
177 derz_1 =
m_xmap->PhysEvaluate(I, DzD1);
178 derz_2 =
m_xmap->PhysEvaluate(I, DzD2);
179 derz_3 =
m_xmap->PhysEvaluate(I, DzD3);
181 jac = derx_1*(dery_2*derz_3 - dery_3*derz_2)
182 - derx_2*(dery_1*derz_3 - dery_3*derz_1)
183 + derx_3*(dery_1*derz_2 - dery_2*derz_1);
187 Lcoords[0] = Lcoords[0]
188 +((dery_2*derz_3 - dery_3*derz_2)*(coords[0]-xmap)
189 - (derx_2*derz_3 - derx_3*derz_2)*(coords[1]-ymap)
190 + (derx_2*dery_3 - derx_3*dery_2)*(coords[2]-zmap)
193 Lcoords[1] = Lcoords[1]
194 -((dery_1*derz_3 - dery_3*derz_1)*(coords[0]-xmap)
195 - (derx_1*derz_3 - derx_3*derz_1)*(coords[1]-ymap)
196 + (derx_1*dery_3 - derx_3*dery_1)*(coords[2]-zmap)
199 Lcoords[2] = Lcoords[2]
200 +((dery_1*derz_2 - dery_2*derz_1)*(coords[0]-xmap)
201 - (derx_1*derz_2 - derx_2*derz_1)*(coords[1]-ymap)
202 + (derx_1*dery_2 - derx_2*dery_1)*(coords[2]-zmap)
205 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
206 fabs(Lcoords[0]) > LcoordDiv)
212 resid = sqrt(F1*F1 + F2*F2 + F3*F3);
214 if(cnt >= MaxIterations)
216 Array<OneD, NekDouble> collCoords(3);
217 m_xmap->LocCoordToLocCollapsed(Lcoords,collCoords);
220 if((collCoords[0] >= -1.0 && collCoords[0] <= 1.0)&&
221 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0)&&
222 (collCoords[2] >= -1.0 && collCoords[2] <= 1.0))
224 std::ostringstream ss;
226 ss <<
"Reached MaxIterations (" << MaxIterations <<
") in Newton iteration ";
227 ss <<
"Init value ("<< setprecision(4) << init0 <<
"," << init1<<
"," << init2 <<
") ";
228 ss <<
"Fin value ("<<Lcoords[0] <<
"," << Lcoords[1]<<
"," << Lcoords[2] <<
") ";
229 ss <<
"Resid = " << resid <<
" Tolerance = " << sqrt(ScaledTol) ;
255 int nFaceCoeffs =
m_faces[i]->GetXmap()->GetNcoeffs();
257 Array<OneD, unsigned int> mapArray (nFaceCoeffs);
258 Array<OneD, int> signArray(nFaceCoeffs);
262 m_xmap->GetFaceToElementMap(
269 m_xmap->GetFaceToElementMap(
277 const Array<OneD, const NekDouble> &coeffs =
280 for (k = 0; k < nFaceCoeffs; k++)
305 if (
m_xmap->GetBasisNumModes(0) != 2 ||
306 m_xmap->GetBasisNumModes(1) != 2 ||
307 m_xmap->GetBasisNumModes(2) != 2)
324 const int i,
const Array<OneD, const NekDouble> &Lcoord)
327 "Geometry is not in physical space");
329 Array<OneD, NekDouble> tmp(
m_xmap->GetTotPoints());
332 return m_xmap->PhysEvaluate(Lcoord, tmp);
354 "Vertex ID must be between 0 and "+
355 boost::lexical_cast<
string>(
m_verts.size() - 1));
373 "Edge ID must be between 0 and "+
374 boost::lexical_cast<
string>(
m_edges.size() - 1));
385 "Edge ID must be between 0 and "+
386 boost::lexical_cast<
string>(
m_edges.size() - 1));
396 "Edge ID must be between 0 and "+
397 boost::lexical_cast<
string>(
m_edges.size() - 1));
406 ASSERTL2((i >=0) && (i <= 5),
"Edge id must be between 0 and 4");
416 "Face ID must be between 0 and "+
417 boost::lexical_cast<
string>(
m_faces.size() - 1));
427 "Face ID must be between 0 and "+
428 boost::lexical_cast<
string>(
m_faces.size() - 1));
446 return m_xmap->GetBasis(i);
462 for (i=0,edgeIter =
m_edges.begin(); edgeIter !=
m_edges.end(); ++edgeIter,++i)
464 if (*edgeIter == edge)
512 std::list<CompToElmt>::const_iterator def;