12#ifndef DUMUX_GEOMETRY_DISTANCE_FIELD_HH 
   13#define DUMUX_GEOMETRY_DISTANCE_FIELD_HH 
   31template<
class Geometry>
 
   34    using Point = 
typename Geometry::GlobalCoordinate;
 
   35    using Scalar = 
typename Geometry::ctype;
 
   42        static constexpr int mydimension = 0;
 
   43        static constexpr int coorddimension = Geometry::coorddimension;
 
   44        using ctype = 
typename Geometry::ctype;
 
   46        PointGeometry(Point&& point) : point_(std::move(point)) {}
 
   47        const Point& corner(std::size_t i)
 const { assert(i == 0); 
return point_; }
 
   48        std::size_t corners()
 const { 
return 1; }
 
   62    : tree_(std::make_unique<AABBTree>(std::make_shared<GeoSet>(geometries)))
 
   64        std::vector<PointGeometry> points;
 
   65        points.reserve(geometries.size());
 
   66        for (
const auto& geo : geometries)
 
   68            auto center = geo.center();
 
   69            points.emplace_back(std::move(
center));
 
   72        pointTree_ = std::make_unique<AABBTreeMidPoints>(
 
   73            std::make_shared<PointGeoSet>(std::move(points))
 
 
   83    { 
return distanceAndIndex_(p); }
 
 
   90    { 
return distanceAndIndex_(p).first; }
 
 
   93    std::pair<Scalar, std::size_t> distanceAndIndex_(
const Point& p)
 const 
   96        const auto minSquaredDistanceEstimate = 
squaredDistance(p, *pointTree_);
 
  106    std::unique_ptr<AABBTree> tree_;
 
  107    std::unique_ptr<AABBTreeMidPoints> pointTree_;
 
 
  116template<
class Geometry>
 
An axis-aligned bounding box volume hierarchy for dune grids.
Class to calculate the closest distance from a point to a given set of geometries describing the doma...
Definition distancefield.hh:33
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:82
Scalar distance(const Point &p) const
Returns the distance from a point to the closest geometry on the domain's boundary.
Definition distancefield.hh:89
AABBDistanceField(const std::vector< Geometry > &geometries)
The constructor.
Definition distancefield.hh:61
An axis-aligned bounding box volume tree implementation.
Definition boundingboxtree.hh:67
An interface for a set of geometric entities.
Definition geometricentityset.hh:160
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:291
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:494
Corners::value_type center(const Corners &corners)
The center of a given list of corners.
Definition center.hh:24
AABBDistanceField< Geometry > DistanceField
Class to calculate the closest distance from a point to a given set of geometries describing the doma...
Definition distancefield.hh:117