22#ifndef DUMUX_INTERSECTING_ENTITIES_HH
23#define DUMUX_INTERSECTING_ENTITIES_HH
28#include <dune/common/fvector.hh>
43template<
class EntitySet,
class ctype,
int dimworld>
44inline std::vector<std::size_t>
47 bool isCartesianGrid =
false)
50 std::vector<std::size_t> entities;
59template<
class EntitySet,
class ctype,
int dimworld>
63 std::vector<std::size_t>& entities,
64 bool isCartesianGrid =
false)
74 else if (tree.
isLeaf(bBox, node))
76 const std::size_t entityIdx = bBox.child1;
79 entities.push_back(entityIdx);
82 const auto geometry = tree.
entitySet().entity(entityIdx).geometry();
85 entities.push_back(entityIdx);
101template<
class EntitySet0,
class EntitySet1>
102inline std::vector<BoundingBoxTreeIntersection<EntitySet0, EntitySet1>>
107 static_assert(int(EntitySet0::dimensionworld) == int(EntitySet1::dimensionworld),
108 "Can only intersect bounding box trees of same world dimension");
111 std::vector<BoundingBoxTreeIntersection<EntitySet0, EntitySet1>>
intersections;
126template<
class EntitySet0,
class EntitySet1>
129 std::size_t nodeA, std::size_t nodeB,
137 static constexpr int dimworld = EntitySet0::dimensionworld;
143 const bool isLeafA = treeA.
isLeaf(bBoxA, nodeA);
144 const bool isLeafB = treeB.
isLeaf(bBoxB, nodeB);
147 if (isLeafA && isLeafB)
149 const auto eIdxA = bBoxA.child1;
150 const auto eIdxB = bBoxB.child1;
152 const auto geometryA = treeA.
entitySet().entity(eIdxA).geometry();
153 const auto geometryB = treeB.
entitySet().entity(eIdxB).geometry();
155 using GeometryA = std::decay_t<
decltype(geometryA)>;
156 using GeometryB = std::decay_t<
decltype(geometryB)>;
159 using Intersection =
typename IntersectionAlgorithm::Intersection;
160 Intersection intersection;
162 if (IntersectionAlgorithm::intersection(geometryA, geometryB, intersection))
164 static constexpr int dimIntersection = Policy::dimIntersection;
166 if (dimIntersection >= 2)
168 const auto triangulation = triangulate<dimIntersection, dimworld>(intersection);
169 for (
unsigned int i = 0; i < triangulation.size(); ++i)
170 intersections.emplace_back(eIdxA, eIdxB, std::move(triangulation[i]));
193 else if (nodeA > nodeB)
A class storing intersections from intersecting two bounding box trees.
A class for collision detection of two geometries and computation of intersection corners.
Detect if a point intersects a geometry.
Functionality to triangulate point clouds.
Define some often used mathematical functions.
bool intersectsPointGeometry(const Dune::FieldVector< ctype, dimworld > &point, const Geometry &g)
Find out whether a point is inside a three-dimensional geometry.
Definition: intersectspointgeometry.hh:38
std::vector< std::size_t > intersectingEntities(const Dune::FieldVector< ctype, dimworld > &point, const BoundingBoxTree< EntitySet > &tree, bool isCartesianGrid=false)
Compute all intersections between entities and a point.
Definition: intersectingentities.hh:45
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition: glue.hh:62
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
bool intersectsPointBoundingBox(const Dune::FieldVector< ctype, dimworld > &point, const ctype *b)
Check whether a point is intersectin a bounding box (dimworld == 3)
Definition: geometry/boundingboxtree.hh:304
typename DefaultPolicyChooser< Geometry1, Geometry2 >::type DefaultPolicy
Helper alias to define the default intersection policy.
Definition: geometryintersection.hh:94
An axis-aligned bounding box volume tree implementation.
Definition: geometry/boundingboxtree.hh:66
const ctype * getBoundingBoxCoordinates(std::size_t nodeIdx) const
Get an existing bounding box for a given node.
Definition: geometry/boundingboxtree.hh:145
bool isLeaf(const BoundingBoxNode &node, std::size_t nodeIdx) const
Definition: geometry/boundingboxtree.hh:154
const EntitySet & entitySet() const
the entity set this tree was built with
Definition: geometry/boundingboxtree.hh:133
std::size_t numBoundingBoxes() const
Get the number of bounding boxes currently in the tree.
Definition: geometry/boundingboxtree.hh:149
const BoundingBoxNode & getBoundingBoxNode(std::size_t nodeIdx) const
Interface to be used by other bounding box trees.
Definition: geometry/boundingboxtree.hh:141
An intersection object resulting from the intersection of two bounding box tree primitives.
Definition: boundingboxtreeintersection.hh:41
A class for geometry collision detection and intersection calculation The class can be specialized fo...
Definition: geometryintersection.hh:197
An axis-aligned bounding box volume hierarchy for dune grids.