48 namespace SpatialDomains
51 Geometry3D::Geometry3D()
55 Geometry3D::Geometry3D(
const int coordim) :
Geometry(coordim)
58 "Coordinate dimension should be at least 3 for a 3D geometry.");
90 const int MaxIterations = 51;
105 NekDouble derx_1, derx_2, derx_3, dery_1, dery_2, dery_3, derz_1, derz_2,
109 NekDouble init0 = Lcoords[0], init1 = Lcoords[1], init2 = Lcoords[2];
122 m_xmap->PhysDeriv(ptsx, DxD1, DxD2, DxD3);
123 m_xmap->PhysDeriv(ptsy, DyD1, DyD2, DyD3);
124 m_xmap->PhysDeriv(ptsz, DzD1, DzD2, DzD3);
132 while (cnt++ < MaxIterations)
135 m_xmap->LocCoordToLocCollapsed(Lcoords, eta);
136 I[0] =
m_xmap->GetBasis(0)->GetI(eta);
137 I[1] =
m_xmap->GetBasis(1)->GetI(eta + 1);
138 I[2] =
m_xmap->GetBasis(2)->GetI(eta + 2);
141 xmap =
m_xmap->PhysEvaluate(I, ptsx);
142 ymap =
m_xmap->PhysEvaluate(I, ptsy);
143 zmap =
m_xmap->PhysEvaluate(I, ptsz);
145 F1 = coords[0] - xmap;
146 F2 = coords[1] - ymap;
147 F3 = coords[2] - zmap;
149 if (F1 * F1 + F2 * F2 + F3 * F3 < ScaledTol)
151 resid = sqrt(F1 * F1 + F2 * F2 + F3 * F3);
156 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
157 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
158 derx_3 =
m_xmap->PhysEvaluate(I, DxD3);
159 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
160 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
161 dery_3 =
m_xmap->PhysEvaluate(I, DyD3);
162 derz_1 =
m_xmap->PhysEvaluate(I, DzD1);
163 derz_2 =
m_xmap->PhysEvaluate(I, DzD2);
164 derz_3 =
m_xmap->PhysEvaluate(I, DzD3);
166 jac = derx_1 * (dery_2 * derz_3 - dery_3 * derz_2) -
167 derx_2 * (dery_1 * derz_3 - dery_3 * derz_1) +
168 derx_3 * (dery_1 * derz_2 - dery_2 * derz_1);
174 ((dery_2 * derz_3 - dery_3 * derz_2) * (coords[0] - xmap) -
175 (derx_2 * derz_3 - derx_3 * derz_2) * (coords[1] - ymap) +
176 (derx_2 * dery_3 - derx_3 * dery_2) * (coords[2] - zmap)) /
181 ((dery_1 * derz_3 - dery_3 * derz_1) * (coords[0] - xmap) -
182 (derx_1 * derz_3 - derx_3 * derz_1) * (coords[1] - ymap) +
183 (derx_1 * dery_3 - derx_3 * dery_1) * (coords[2] - zmap)) /
188 ((dery_1 * derz_2 - dery_2 * derz_1) * (coords[0] - xmap) -
189 (derx_1 * derz_2 - derx_2 * derz_1) * (coords[1] - ymap) +
190 (derx_1 * dery_2 - derx_2 * dery_1) * (coords[2] - zmap)) /
193 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
194 fabs(Lcoords[0]) > LcoordDiv)
200 resid = sqrt(F1 * F1 + F2 * F2 + F3 * F3);
202 if (cnt >= MaxIterations)
205 m_xmap->LocCoordToLocCollapsed(Lcoords, collCoords);
208 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
209 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0) &&
210 (collCoords[2] >= -1.0 && collCoords[2] <= 1.0))
212 std::ostringstream ss;
214 ss <<
"Reached MaxIterations (" << MaxIterations
215 <<
") in Newton iteration ";
216 ss <<
"Init value (" << setprecision(4) << init0 <<
"," << init1
217 <<
"," << init2 <<
") ";
218 ss <<
"Fin value (" << Lcoords[0] <<
"," << Lcoords[1] <<
"," 219 << Lcoords[2] <<
") ";
220 ss <<
"Resid = " << resid <<
" Tolerance = " << sqrt(ScaledTol);
222 WARNINGL1(cnt < MaxIterations, ss.str());
248 int nFaceCoeffs =
m_faces[i]->GetXmap()->GetNcoeffs();
255 m_xmap->GetFaceToElementMap(
265 m_xmap->GetFaceToElementMap(
279 for (k = 0; k < nFaceCoeffs; k++)
302 return m_xmap->PhysEvaluate(Lcoord, tmp);
337 "Edge ID must be between 0 and " +
338 boost::lexical_cast<
string>(
m_edges.size() - 1));
344 ASSERTL2((i >= 0) && (i <= 5),
"Edge id must be between 0 and 4");
351 "Edge ID must be between 0 and " +
352 boost::lexical_cast<
string>(
m_edges.size() - 1));
359 "Face ID must be between 0 and " +
360 boost::lexical_cast<
string>(
m_faces.size() - 1));
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
int GetDir(const int faceidx, const int facedir) const
Returns the element coordinate direction corresponding to a given face coordinate direction...
#define ASSERTL0(condition, msg)
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...
std::vector< StdRegions::Orientation > m_eorient
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
Base class for shape geometry information.
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
virtual PointGeomSharedPtr v_GetVertex(int i) const
virtual StdRegions::Orientation v_GetForient(const int i) const
Returns the orientation of face i with respect to the ordering of faces in the standard element...
std::vector< StdRegions::Orientation > m_forient
virtual int v_GetNumEdges() const
Get the number of edges of this object.
void NewtonIterationForLocCoord(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, const Array< OneD, const NekDouble > &ptsz, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
virtual Geometry1DSharedPtr v_GetEdge(int i) const
Returns edge i of this object.
virtual int v_GetDir(const int faceidx, const int facedir) const =0
std::shared_ptr< PointGeom > PointGeomSharedPtr
virtual int v_GetNumVerts() const
Get the number of vertices of this object.
virtual Geometry2DSharedPtr v_GetFace(int i) const
Returns face i of this object.
virtual void v_FillGeom()
Put all quadrature information into face/edge structure and backward transform.
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
#define WARNINGL1(condition, msg)
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
virtual int v_GetNumFaces() const
Get the number of faces of this object.
virtual NekDouble v_GetCoord(const int i, const Array< OneD, const NekDouble > &Lcoord)
Given local collapsed coordinate Lcoord return the value of physical coordinate in direction i...
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
virtual int v_GetShapeDim() const
Get the object's shape dimension.
Geometric information has been generated.
GeomState m_state
Enumeration to dictate whether coefficients are filled.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
int m_coordim
Coordinate dimension of this geometry object.