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.");
95 NekDouble derx_1, derx_2, derx_3, dery_1, dery_2, dery_3, derz_1, derz_2,
99 NekDouble init0 = Lcoords[0], init1 = Lcoords[1], init2 = Lcoords[2];
112 m_xmap->PhysDeriv(ptsx, DxD1, DxD2, DxD3);
113 m_xmap->PhysDeriv(ptsy, DyD1, DyD2, DyD3);
114 m_xmap->PhysDeriv(ptsz, DzD1, DzD2, DzD3);
122 while (cnt++ < MaxIterations)
125 m_xmap->LocCoordToLocCollapsed(Lcoords, eta);
126 I[0] =
m_xmap->GetBasis(0)->GetI(eta);
127 I[1] =
m_xmap->GetBasis(1)->GetI(eta + 1);
128 I[2] =
m_xmap->GetBasis(2)->GetI(eta + 2);
131 xmap =
m_xmap->PhysEvaluate(I, ptsx);
132 ymap =
m_xmap->PhysEvaluate(I, ptsy);
133 zmap =
m_xmap->PhysEvaluate(I, ptsz);
135 F1 = coords[0] - xmap;
136 F2 = coords[1] - ymap;
137 F3 = coords[2] - zmap;
139 if (F1 * F1 + F2 * F2 + F3 * F3 < ScaledTol)
141 resid =
sqrt(F1 * F1 + F2 * F2 + F3 * F3);
146 derx_1 =
m_xmap->PhysEvaluate(I, DxD1);
147 derx_2 =
m_xmap->PhysEvaluate(I, DxD2);
148 derx_3 =
m_xmap->PhysEvaluate(I, DxD3);
149 dery_1 =
m_xmap->PhysEvaluate(I, DyD1);
150 dery_2 =
m_xmap->PhysEvaluate(I, DyD2);
151 dery_3 =
m_xmap->PhysEvaluate(I, DyD3);
152 derz_1 =
m_xmap->PhysEvaluate(I, DzD1);
153 derz_2 =
m_xmap->PhysEvaluate(I, DzD2);
154 derz_3 =
m_xmap->PhysEvaluate(I, DzD3);
156 jac = derx_1 * (dery_2 * derz_3 - dery_3 * derz_2) -
157 derx_2 * (dery_1 * derz_3 - dery_3 * derz_1) +
158 derx_3 * (dery_1 * derz_2 - dery_2 * derz_1);
164 ((dery_2 * derz_3 - dery_3 * derz_2) * (coords[0] - xmap) -
165 (derx_2 * derz_3 - derx_3 * derz_2) * (coords[1] - ymap) +
166 (derx_2 * dery_3 - derx_3 * dery_2) * (coords[2] - zmap)) /
171 ((dery_1 * derz_3 - dery_3 * derz_1) * (coords[0] - xmap) -
172 (derx_1 * derz_3 - derx_3 * derz_1) * (coords[1] - ymap) +
173 (derx_1 * dery_3 - derx_3 * dery_1) * (coords[2] - zmap)) /
178 ((dery_1 * derz_2 - dery_2 * derz_1) * (coords[0] - xmap) -
179 (derx_1 * derz_2 - derx_2 * derz_1) * (coords[1] - ymap) +
180 (derx_1 * dery_2 - derx_2 * dery_1) * (coords[2] - zmap)) /
183 if (!(std::isfinite(Lcoords[0]) && std::isfinite(Lcoords[1]) &&
184 std::isfinite(Lcoords[2])))
187 std::ostringstream ss;
188 ss <<
"nan or inf found in NewtonIterationForLocCoord in element "
193 if (fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv ||
194 fabs(Lcoords[0]) > LcoordDiv)
200 m_xmap->LocCoordToLocCollapsed(Lcoords, eta);
203 I[0] =
m_xmap->GetBasis(0)->GetI(eta);
204 I[1] =
m_xmap->GetBasis(1)->GetI(eta + 1);
205 I[2] =
m_xmap->GetBasis(2)->GetI(eta + 2);
207 xmap =
m_xmap->PhysEvaluate(I, ptsx);
208 ymap =
m_xmap->PhysEvaluate(I, ptsy);
209 zmap =
m_xmap->PhysEvaluate(I, ptsz);
210 F1 = coords[0] - xmap;
211 F2 = coords[1] - ymap;
212 F3 = coords[2] - zmap;
213 dist =
sqrt(F1 * F1 + F2 * F2 + F3 * F3);
220 if (cnt >= MaxIterations)
223 m_xmap->LocCoordToLocCollapsed(Lcoords, collCoords);
226 if ((collCoords[0] >= -1.0 && collCoords[0] <= 1.0) &&
227 (collCoords[1] >= -1.0 && collCoords[1] <= 1.0) &&
228 (collCoords[2] >= -1.0 && collCoords[2] <= 1.0))
230 std::ostringstream ss;
232 ss <<
"Reached MaxIterations (" << MaxIterations
233 <<
") in Newton iteration ";
234 ss <<
"Init value (" << setprecision(4) << init0 <<
"," << init1
235 <<
"," << init2 <<
") ";
236 ss <<
"Fin value (" << Lcoords[0] <<
"," << Lcoords[1] <<
","
237 << Lcoords[2] <<
") ";
238 ss <<
"Resid = " << resid <<
" Tolerance = " <<
sqrt(ScaledTol);
240 WARNINGL1(cnt < MaxIterations, ss.str());
271 ASSERTL0(
false,
"unrecognized 3D element type");
285 cp1020.
Mult(e10, e20);
286 cp2030.
Mult(e20, e30);
287 cp3010.
Mult(e30, e10);
291 2. / e30.
dot(cp1020);
292 Lcoords[0] = er0.
dot(cp2030) * iV - 1.0;
293 Lcoords[1] = er0.
dot(cp3010) * iV - 1.0;
294 Lcoords[2] = er0.
dot(cp1020) * iV - 1.0;
298 m_xmap->LocCoordToLocCollapsed(Lcoords, eta);
302 m_xmap->LocCollapsedToLocCoord(eta, xi);
303 xi[0] = (xi[0] + 1.) * 0.5;
304 xi[1] = (xi[1] + 1.) * 0.5;
305 xi[2] = (xi[2] + 1.) * 0.5;
309 xi[0] * e10[i] + xi[1] * e20[i] + xi[2] * e30[i] - er0[i];
319 int npts =
m_xmap->GetTotPoints();
342 int qa = za.size(), qb = zb.size();
345 eta[2] = zc[min_i / (qa * qb)];
346 min_i = min_i % (qa * qb);
347 eta[1] = zb[min_i / qa];
348 eta[0] = za[min_i % qa];
349 m_xmap->LocCollapsedToLocCoord(eta, Lcoords);
378 int nFaceCoeffs =
m_faces[i]->GetXmap()->GetNcoeffs();
385 m_xmap->GetTraceToElementMap(
392 m_xmap->GetTraceToElementMap(
403 for (k = 0; k < nFaceCoeffs; k++)
426 return m_xmap->PhysEvaluate(Lcoord, tmp);
461 "Edge ID must be between 0 and " +
462 boost::lexical_cast<string>(
m_edges.size() - 1));
468 ASSERTL2((i >= 0) && (i <= 5),
"Edge id must be between 0 and 4");
475 "Edge ID must be between 0 and " +
476 boost::lexical_cast<string>(
m_edges.size() - 1));
483 "Face ID must be between 0 and " +
484 boost::lexical_cast<string>(
m_faces.size() - 1));
#define WARNINGL1(condition, msg)
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
virtual Geometry2DSharedPtr v_GetFace(int i) const override
Returns face i of this object.
virtual int v_GetNumFaces() const override
Get the number of faces of this object.
virtual NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this ge...
virtual int v_GetNumEdges() const override
Get the number of edges of this object.
std::vector< StdRegions::Orientation > m_forient
virtual void v_FillGeom() override
Put all quadrature information into face/edge structure and backward transform.
virtual NekDouble v_GetCoord(const int i, const Array< OneD, const NekDouble > &Lcoord) override
Given local collapsed coordinate Lcoord return the value of physical coordinate in direction i.
virtual PointGeomSharedPtr v_GetVertex(int i) const override
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 &dist)
virtual Geometry1DSharedPtr v_GetEdge(int i) const override
Returns edge i of this object.
virtual StdRegions::Orientation v_GetForient(const int i) const override
Returns the orientation of face i with respect to the ordering of faces in the standard element.
virtual int v_GetShapeDim() const override
Get the object's shape dimension.
virtual StdRegions::Orientation v_GetEorient(const int i) const override
Returns the orientation of edge i with respect to the ordering of edges in the standard element.
std::vector< StdRegions::Orientation > m_eorient
virtual int v_GetNumVerts() const override
Get the number of vertices of this object.
Base class for shape geometry information.
GeomState m_state
Enumeration to dictate whether coefficients are filled.
bool ClampLocCoords(Array< OneD, NekDouble > &locCoord, NekDouble tol=std::numeric_limits< NekDouble >::epsilon())
Clamp local coords to be within standard regions [-1, 1]^dim.
int GetGlobalID(void) const
Get the ID of this object.
LibUtilities::ShapeType m_shapeType
Type of shape.
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
GeomFactorsSharedPtr GetMetricInfo()
Get the geometric factors for this object.
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
StdRegions::StdExpansionSharedPtr GetXmap() const
Return the mapping object Geometry::m_xmap that represents the coordinate transformation from standar...
GeomFactorsSharedPtr m_geomFactors
Geometric factors.
int m_coordim
Coordinate dimension of this geometry object.
void Sub(PointGeom &a, PointGeom &b)
void Mult(PointGeom &a, PointGeom &b)
_this = a x b
NekDouble dot(PointGeom &a)
retun the dot product between this and input a
static const unsigned int kNewtonIterations
@ eRegular
Geometry is straight-sided with constant geometric factors.
std::shared_ptr< PointGeom > PointGeomSharedPtr
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
@ ePtsFilled
Geometric information has been generated.
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
The above copyright notice and this permission notice shall be included.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add scalar y = alpha + x.
scalarT< T > sqrt(scalarT< T > in)