|
Nektar++
|
Inverts the mapping \(\chi:\xi\mapsto x\) for one geometry. More...
#include <GeometryLocator.h>
Public Member Functions | |
| GeometryLocator (Geometry *geom) | |
| virtual | ~GeometryLocator ()=default |
| void | Build () |
| Populate the cache. Called by Create() once the concrete type exists, since it dispatches virtually. | |
| Geometry * | GetGeometry () const |
| std::array< NekDouble, 6 > | GetBoundingBox () |
| Generates the bounding box for the element. | |
| void | ClearBoundingBox () |
| bool | ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0) |
| Determine whether the element contains a Cartesian coordinate. | |
| bool | ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol) |
| Determine whether the element contains a Cartesian coordinate. | |
| bool | ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &dist) |
| NekDouble | GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) |
| Determine the local collapsed coordinates corresponding to a given Cartesian coordinate. | |
| NekDouble | FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) |
| int | PreliminaryCheck (const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist) |
| A fast and robust check if a given global coord is outside of a deformed element. For regular elements, this check is unnecessary. | |
| bool | MinMaxCheck (const Array< OneD, const NekDouble > &gloCoord) |
| Check if given global coord is within the BoundingBox of the element. | |
Static Public Member Functions | |
| static std::unique_ptr< GeometryLocator > | Create (Geometry *geom) |
Build the locator appropriate to geom's dimension, with its cache already populated. | |
| static bool | ClampLocCoords (Array< OneD, NekDouble > &locCoord, int dim, NekDouble tol=std::numeric_limits< NekDouble >::epsilon()) |
| Clamp local coordinates into the reference element \([-1-tol,1+tol]^{dim}\), returning whether anything was clamped. Depends only on the reference element, so it needs no locator. | |
Protected Member Functions | |
| virtual NekDouble | v_GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) |
| virtual NekDouble | v_FindDistance (const Array< OneD, const NekDouble > &xs, Array< OneD, NekDouble > &xi) |
| virtual int | v_AllLeftCheck (const Array< OneD, const NekDouble > &gloCoord, NekDouble &edgeDist) |
| virtual void | v_CalculateInverseIsoParam () |
| virtual void | v_PreSolveStraightEdge () |
Protected Attributes | |
| Geometry * | m_geom |
| The geometry being searched. Not owned. | |
| IsoParam | m_iso |
| The shape's isoparametric coefficients. The straight-edged 2D solve rewrites them into a factored form, so the locator keeps its own copy rather than sharing the geometry's. | |
| int | m_straightEdge = 0 |
| Non-zero if every \(\chi\) basis is linear. Bits 1 and 2 are used by the 2D straight-edged solve to record which axes were swapped. | |
| std::array< std::array< NekDouble, kMaxGeomDim >, kMaxGeomDim > | m_invIsoParam {} |
Inverse of the linear part of m_iso, for regular elements. | |
| bool | m_newtonConverged = false |
| Whether the Newton iteration of the last GetLocCoords call converged, i.e. whether its local coordinates map to the point. Set only by elements located by Newton iteration; read by ContainsPoint. | |
| bool | m_hasBoundingBox = false |
| Element bounding box as (xmin, ymin, zmin, xmax, ymax, zmax). | |
| std::array< NekDouble, 6 > | m_boundingBox {} |
| bool | m_edgeNormalBuilt = false |
2D only: inward edge normals used to reject points outside straight-sided elements. A curved edge gets no normal, so m_hasEdgeNormal records which entries are usable. | |
| std::array< bool, kMaxGeomVerts > | m_hasEdgeNormal {} |
| std::array< std::array< NekDouble, 2 >, kMaxGeomVerts > | m_edgeNormal {} |
Inverts the mapping \(\chi:\xi\mapsto x\) for one geometry.
Point location – deciding whether an element contains a Cartesian coordinate, recovering the local coordinate that maps to it, or measuring the distance to it – is an algorithm applied to a geometry, not a property of one. For anything but an affine element it is a nonlinear solve, and it needs a cache of derived quantities to be quick. Neither the algorithm nor the cache belongs on Geometry, so both live here and are owned by whoever does the searching.
Build one with GeometryLocator::Create() and keep it for as long as the geometry is unchanged; it must not outlive the geometry it refers to. A locator is invalidated by anything that moves or re-curves the geometry, which is to say by any of the Geometry Reset entry points.
The concrete algorithms differ by the dimension of the shape rather than by the shape itself, which is why the subclasses are per-dimension.
Definition at line 102 of file GeometryLocator.h.
|
explicit |
Definition at line 50 of file GeometryLocator.cpp.
|
virtualdefault |
| void Nektar::SpatialDomains::GeometryLocator::Build | ( | ) |
Populate the cache. Called by Create() once the concrete type exists, since it dispatches virtually.
Populate the cache of quantities derived from the geometry.
Separate from the constructor because it dispatches virtually: the inverse-coefficient and straight-edged forms differ by dimension.
Definition at line 61 of file GeometryLocator.cpp.
References Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::HasLinearXmap(), m_geom, m_iso, m_straightEdge, v_CalculateInverseIsoParam(), and v_PreSolveStraightEdge().
|
static |
Clamp local coordinates into the reference element \([-1-tol,1+tol]^{dim}\), returning whether anything was clamped. Depends only on the reference element, so it needs no locator.
Clamp local coords to be within standard regions [-1, 1]^dim.
| Lcoords | Corresponding local coordinates |
Definition at line 303 of file GeometryLocator.cpp.
References ASSERTL1.
Referenced by ContainsPoint(), Nektar::SpatialDomains::GeometryLocator2D::NewtonIterationForLocCoord(), Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord(), Nektar::FieldUtils::ProcessWallNormalData::NewtonIterForLocCoordOnBndElmt(), Nektar::SpatialDomains::GeometryLocator1D::v_FindDistance(), Nektar::SpatialDomains::GeometryLocator2D::v_FindDistance(), Nektar::SpatialDomains::GeometryLocator2D::v_GetLocCoords(), and Nektar::SpatialDomains::GeometryLocator3D::v_GetLocCoords().
| void Nektar::SpatialDomains::GeometryLocator::ClearBoundingBox | ( | ) |
Definition at line 235 of file GeometryLocator.cpp.
References m_hasBoundingBox.
| bool Nektar::SpatialDomains::GeometryLocator::ContainsPoint | ( | const Array< OneD, const NekDouble > & | gloCoord, |
| Array< OneD, NekDouble > & | locCoord, | ||
| NekDouble | tol | ||
| ) |
Determine whether the element contains a Cartesian coordinate.
Definition at line 119 of file GeometryLocator.cpp.
References ContainsPoint().
| bool Nektar::SpatialDomains::GeometryLocator::ContainsPoint | ( | const Array< OneD, const NekDouble > & | gloCoord, |
| Array< OneD, NekDouble > & | locCoord, | ||
| NekDouble | tol, | ||
| NekDouble & | dist | ||
| ) |
dist is assigned value for curved elements
Definition at line 342 of file GeometryLocator.cpp.
References Nektar::SpatialDomains::Geometry::CalcGeomType(), ClampLocCoords(), Nektar::SpatialDomains::eDeformed, Nektar::LibUtilities::eQuadrilateral, Nektar::SpatialDomains::eRegular, Nektar::LibUtilities::eTriangle, Nektar::SpatialDomains::Geometry::GetCoordim(), GetLocCoords(), Nektar::SpatialDomains::Geometry::GetShapeDim(), Nektar::SpatialDomains::Geometry::GetShapeType(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::StdRegions::StdExpansion::LocCollapsedToLocCoord(), Nektar::StdRegions::StdExpansion::LocCoordToLocCollapsed(), m_geom, m_iso, Nektar::SpatialDomains::IsoParam::m_nCoeff, m_newtonConverged, m_straightEdge, and PreliminaryCheck().
| bool Nektar::SpatialDomains::GeometryLocator::ContainsPoint | ( | const Array< OneD, const NekDouble > & | gloCoord, |
| NekDouble | tol = 0.0 |
||
| ) |
Determine whether the element contains a Cartesian coordinate.
Definition at line 108 of file GeometryLocator.cpp.
References ContainsPoint(), Nektar::SpatialDomains::Geometry::GetCoordim(), and m_geom.
Referenced by ContainsPoint(), and ContainsPoint().
|
static |
Build the locator appropriate to geom's dimension, with its cache already populated.
Definition at line 77 of file GeometryLocator.cpp.
References ASSERTL0, Nektar::ErrorUtil::efatal, Nektar::SpatialDomains::Geometry::GetShapeDim(), and NEKERROR.
Referenced by Geometry_ContainsPoint(), Nektar::LocalRegions::Expansion::GetLocator(), Nektar::SpatialDomains::MeshGraph::GeomRTree::InsertGeom(), and Nektar::PyrInverseMapTests::WorstRoundTrip().
| NekDouble Nektar::SpatialDomains::GeometryLocator::FindDistance | ( | const Array< OneD, const NekDouble > & | xs, |
| Array< OneD, NekDouble > & | xi | ||
| ) |
Definition at line 145 of file GeometryLocator.cpp.
References v_FindDistance().
| std::array< NekDouble, 6 > Nektar::SpatialDomains::GeometryLocator::GetBoundingBox | ( | ) |
Generates the bounding box for the element.
For regular elements, the vertices are sufficient to define the extent of the bounding box. For non-regular elements, the extremes of the quadrature point coordinates are used. A 10% margin is added around this computed region to account for convex hull elements where the true extent of the element may extend slightly beyond the quadrature points.
Definition at line 160 of file GeometryLocator.cpp.
References Nektar::StdRegions::StdExpansion::BwdTrans(), Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::eRegular, Nektar::SpatialDomains::Geometry::GetCoeffs(), Nektar::SpatialDomains::Geometry::GetCoordim(), Nektar::SpatialDomains::Geometry::GetNumVerts(), Nektar::StdRegions::StdExpansion::GetTotPoints(), Nektar::SpatialDomains::Geometry::GetVertex(), Nektar::SpatialDomains::Geometry::GetXmap(), Nektar::NekConstants::kFindDistanceMin, Nektar::NekConstants::kGeomFactorsTol, m_boundingBox, m_geom, m_hasBoundingBox, tinysimd::max(), and tinysimd::min().
Referenced by MinMaxCheck().
|
inline |
| NekDouble Nektar::SpatialDomains::GeometryLocator::GetLocCoords | ( | const Array< OneD, const NekDouble > & | coords, |
| Array< OneD, NekDouble > & | Lcoords | ||
| ) |
Determine the local collapsed coordinates corresponding to a given Cartesian coordinate.
For curvilinear and non-affine elements this is a nonlinear optimisation problem solved by Newton iteration, so it can be expensive.
| coords | Input Cartesian global coordinates |
| Lcoords | Corresponding local coordinates |
Definition at line 139 of file GeometryLocator.cpp.
References v_GetLocCoords().
Referenced by ContainsPoint(), Nektar::SpatialDomains::GeometryLocator1D::v_FindDistance(), Nektar::SpatialDomains::GeometryLocator2D::v_FindDistance(), Nektar::LocalRegions::HexExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::PrismExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::PyrExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::QuadExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::SegExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::TetExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::TriExp::v_PhysEvalFirstDeriv(), Nektar::LocalRegions::SegExp::v_PhysEvalFirstSecondDeriv(), and Nektar::LocalRegions::Expansion::v_PhysEvaluate().
| bool Nektar::SpatialDomains::GeometryLocator::MinMaxCheck | ( | const Array< OneD, const NekDouble > & | gloCoord | ) |
Check if given global coord is within the BoundingBox of the element.
| coords | Input Cartesian global coordinates |
Definition at line 280 of file GeometryLocator.cpp.
References ASSERTL1, GetBoundingBox(), Nektar::SpatialDomains::Geometry::GetCoordim(), and m_geom.
Referenced by PreliminaryCheck().
| int Nektar::SpatialDomains::GeometryLocator::PreliminaryCheck | ( | const Array< OneD, const NekDouble > & | gloCoord, |
| NekDouble & | edgeDist | ||
| ) |
A fast and robust check if a given global coord is outside of a deformed element. For regular elements, this check is unnecessary.
| coords | Input Cartesian global coordinates |
| edgeDist | For a point just outside straight edges of the element (see v_AllLeftCheck), its distance from them. Otherwise the largest double. |
Definition at line 253 of file GeometryLocator.cpp.
References Nektar::SpatialDomains::Geometry::CalcGeomType(), Nektar::SpatialDomains::eRegular, m_geom, MinMaxCheck(), and v_AllLeftCheck().
Referenced by ContainsPoint().
|
protectedvirtual |
Reimplemented in Nektar::SpatialDomains::GeometryLocator2D.
Definition at line 443 of file GeometryLocator.cpp.
Referenced by PreliminaryCheck().
|
protectedvirtual |
Nothing to do by default. Build() drives this for every shape, but only the 2D and 3D inverse maps are expressed through an inverted coefficient matrix; a segment inverts \(\chi\) in closed form straight from its quadrature points.
Nothing to do by default. Build() drives this for every shape, but only the 2D and 3D inverse maps are expressed through an inverted coefficient matrix; a segment inverts \(\chi\) in closed form straight from its quadrature points.
Reimplemented in Nektar::SpatialDomains::GeometryLocator2D, and Nektar::SpatialDomains::GeometryLocator3D.
Definition at line 460 of file GeometryLocator.cpp.
Referenced by Build().
|
protectedvirtual |
Reimplemented in Nektar::SpatialDomains::GeometryLocator1D, and Nektar::SpatialDomains::GeometryLocator2D.
Definition at line 434 of file GeometryLocator.cpp.
References Nektar::ErrorUtil::efatal, and NEKERROR.
Referenced by FindDistance().
|
protectedvirtual |
Reimplemented in Nektar::SpatialDomains::GeometryLocator1D, Nektar::SpatialDomains::GeometryLocator2D, and Nektar::SpatialDomains::GeometryLocator3D.
Definition at line 425 of file GeometryLocator.cpp.
References Nektar::ErrorUtil::efatal, and NEKERROR.
Referenced by GetLocCoords().
|
protectedvirtual |
Only the quadrilateral has a straight-edged solve to prepare for.
Only the quadrilateral has a straight-edged solve to prepare for.
Reimplemented in Nektar::SpatialDomains::GeometryLocator2D.
Definition at line 469 of file GeometryLocator.cpp.
Referenced by Build().
|
protected |
|
protected |
Definition at line 184 of file GeometryLocator.h.
Referenced by Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck().
|
protected |
2D only: inward edge normals used to reject points outside straight-sided elements. A curved edge gets no normal, so m_hasEdgeNormal records which entries are usable.
Definition at line 182 of file GeometryLocator.h.
Referenced by Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck().
|
protected |
The geometry being searched. Not owned.
Definition at line 156 of file GeometryLocator.h.
Referenced by Build(), ContainsPoint(), ContainsPoint(), GeometryLocator(), GetBoundingBox(), GetGeometry(), MinMaxCheck(), Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord(), Nektar::SpatialDomains::GeometryLocator2D::NewtonIterationForLocCoord(), Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord(), PreliminaryCheck(), Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck(), Nektar::SpatialDomains::GeometryLocator1D::v_FindDistance(), Nektar::SpatialDomains::GeometryLocator2D::v_FindDistance(), Nektar::SpatialDomains::GeometryLocator1D::v_GetLocCoords(), Nektar::SpatialDomains::GeometryLocator2D::v_GetLocCoords(), and Nektar::SpatialDomains::GeometryLocator3D::v_GetLocCoords().
|
protected |
Element bounding box as (xmin, ymin, zmin, xmax, ymax, zmax).
Definition at line 176 of file GeometryLocator.h.
Referenced by ClearBoundingBox(), and GetBoundingBox().
|
protected |
Definition at line 183 of file GeometryLocator.h.
Referenced by Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck().
|
protected |
Inverse of the linear part of m_iso, for regular elements.
Definition at line 168 of file GeometryLocator.h.
Referenced by Nektar::SpatialDomains::GeometryLocator2D::v_CalculateInverseIsoParam(), Nektar::SpatialDomains::GeometryLocator3D::v_CalculateInverseIsoParam(), Nektar::SpatialDomains::GeometryLocator2D::v_GetLocCoords(), and Nektar::SpatialDomains::GeometryLocator3D::v_GetLocCoords().
|
protected |
The shape's isoparametric coefficients. The straight-edged 2D solve rewrites them into a factored form, so the locator keeps its own copy rather than sharing the geometry's.
Definition at line 161 of file GeometryLocator.h.
Referenced by Build(), ContainsPoint(), Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord(), Nektar::SpatialDomains::GeometryLocator2D::SolveStraightEdgeQuad(), Nektar::SpatialDomains::GeometryLocator2D::v_AllLeftCheck(), Nektar::SpatialDomains::GeometryLocator2D::v_CalculateInverseIsoParam(), Nektar::SpatialDomains::GeometryLocator3D::v_CalculateInverseIsoParam(), Nektar::SpatialDomains::GeometryLocator2D::v_GetLocCoords(), Nektar::SpatialDomains::GeometryLocator3D::v_GetLocCoords(), and Nektar::SpatialDomains::GeometryLocator2D::v_PreSolveStraightEdge().
|
protected |
Whether the Newton iteration of the last GetLocCoords call converged, i.e. whether its local coordinates map to the point. Set only by elements located by Newton iteration; read by ContainsPoint.
Definition at line 173 of file GeometryLocator.h.
Referenced by ContainsPoint(), Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord(), Nektar::SpatialDomains::GeometryLocator2D::NewtonIterationForLocCoord(), and Nektar::SpatialDomains::GeometryLocator3D::NewtonIterationForLocCoord().
|
protected |
Non-zero if every \(\chi\) basis is linear. Bits 1 and 2 are used by the 2D straight-edged solve to record which axes were swapped.
Definition at line 165 of file GeometryLocator.h.
Referenced by Build(), ContainsPoint(), Nektar::SpatialDomains::GeometryLocator2D::SolveStraightEdgeQuad(), Nektar::SpatialDomains::GeometryLocator2D::v_GetLocCoords(), Nektar::SpatialDomains::GeometryLocator3D::v_GetLocCoords(), and Nektar::SpatialDomains::GeometryLocator2D::v_PreSolveStraightEdge().