24#ifndef DUMUX_GEOMETRY_DISTANCE_FIELD_HH
25#define DUMUX_GEOMETRY_DISTANCE_FIELD_HH
43template<
class Geometry>
46 using Point =
typename Geometry::GlobalCoordinate;
47 using Scalar =
typename Geometry::ctype;
54 static constexpr int mydimension = 0;
55 static constexpr int coorddimension = Geometry::coorddimension;
56 using ctype =
typename Geometry::ctype;
58 PointGeometry(Point&& point) : point_(std::move(point)) {}
59 const Point& corner(std::size_t i)
const { assert(i == 0);
return point_; }
60 std::size_t corners()
const {
return 1; }
74 : tree_(std::make_unique<
AABBTree>(std::make_shared<
GeoSet>(geometries)))
76 std::vector<PointGeometry> points;
77 points.reserve(geometries.size());
78 for (
const auto& geo : geometries)
80 auto center = geo.center();
81 points.emplace_back(std::move(center));
84 pointTree_ = std::make_unique<AABBTreeMidPoints>(
85 std::make_shared<PointGeoSet>(std::move(points))
95 {
return distanceAndIndex_(p); }
102 {
return distanceAndIndex_(p).first; }
105 std::pair<Scalar, std::size_t> distanceAndIndex_(
const Point& p)
const
108 const auto minSquaredDistanceEstimate =
squaredDistance(p, *pointTree_);
118 std::unique_ptr<AABBTree> tree_;
119 std::unique_ptr<AABBTreeMidPoints> pointTree_;
128template<
class Geometry>
An axis-aligned bounding box volume hierarchy for dune grids.
Helper functions for distance queries.
An interface for a set of geometric entities.
static ctype squaredDistance(const Dune::FieldVector< ctype, dimWorld > &a, const Dune::FieldVector< ctype, dimWorld > &b)
Compute the shortest squared distance between two points.
Definition: distance.hh:301
std::pair< ctype, std::size_t > closestEntity(const Dune::FieldVector< ctype, dimworld > &point, const BoundingBoxTree< EntitySet > &tree, ctype minSquaredDistance=std::numeric_limits< ctype >::max())
Compute the closest entity in an AABB tree to a point (index and shortest squared distance)
Definition: distance.hh:504
An axis-aligned bounding box volume tree implementation.
Definition: boundingboxtree.hh:66
Class to calculate the closest distance from a point to a given set of geometries describing the doma...
Definition: distancefield.hh:45
std::pair< Scalar, std::size_t > distanceAndIndex(const Point &p) const
Returns the distance from a point to the closest geometry on the domain's boundary,...
Definition: distancefield.hh:94
Scalar distance(const Point &p) const
Returns the distance from a point to the closest geometry on the domain's boundary.
Definition: distancefield.hh:101
AABBDistanceField(const std::vector< Geometry > &geometries)
The constructor.
Definition: distancefield.hh:73
An interface for a set of geometric entities.
Definition: geometricentityset.hh:119