![]() |
Reference documentation for deal.II version 9.6.0
|
#include <deal.II/arborx/bvh.h>
Public Member Functions | |
template<int dim, typename Number > | |
BVH (const std::vector< BoundingBox< dim, Number > > &bounding_boxes) | |
template<int dim, typename Number > | |
BVH (const std::vector< Point< dim, Number > > &points) | |
template<typename QueryType > | |
std::pair< std::vector< int >, std::vector< int > > | query (const QueryType &queries) |
Private Attributes | |
ArborX::BVH< Kokkos::HostSpace > | bvh |
This class implements a wrapper around ArborX::BVH. BVH stands for Bounding Volume Hierarchy.
From Wikipedia:
A bounding volume hierarchy (BVH) is a tree structure on a set of geometric objects. All geometric objects are wrapped in bounding volumes that form the leaf nodes of the tree. These nodes are then grouped as small sets and enclosed within larger bounding volumes. These, in turn, are also grouped and enclosed within other larger bounding volumes in a recursive fashion, eventually resulting in a tree structure with a single bounding volume at the top of the tree. Bounding volume hierarchies are used to support several operations on sets of geometric objects efficiently, such as in collision detection and ray tracing.
Because ArborX uses Kokkos, Kokkos needs to be initialized and finalized before using this class.
ArborXWrappers::BVH::BVH | ( | const std::vector< BoundingBox< dim, Number > > & | bounding_boxes | ) |
Constructor. Use a vector of BoundingBox bounding_boxes
as primitives.
std::pair< std::vector< int >, std::vector< int > > ArborXWrappers::BVH::query | ( | const QueryType & | queries | ) |
Return the indices of those BoundingBox objects that satisfy the queries
. Because queries
can contain multiple queries, the function returns a pair of indices and offsets.
Below is an example piece of code that does the following: Let us assume that we have a set of bounding boxes for objects – say, the bounding boxes of each of the cells in a triangulation, or the bounding boxes for each of the parts of a triangulation in a parallel triangulation. We will store those in the bvh_bounding_boxes
array below.
Let us then also assume that we have a set of other bounding boxes, let's say for small objects that are moving around in our domain. We will put these bounding boxes into the bb_intersect
array. The question we would then like to answer is the following: with which of the BVH bounding box(es) do each of the bb_intersect bounding boxes intersect? In other words, in which cell(s) or partition(s) are the particles?
This query is answered by the following piece of code:
The elements of bvh_bounding_boxes
that intersect the j
th BoundingBox of query_bounding_boxes
are given by:
In many other applications, we are interested not only in finding which bounding boxes another bounding box lies in, but in fact which bounding boxes individual points lie in – say, if instead of objects we have point-like particles moving around. In that case, we would need to answer a query for points, and this can be done as follows:
As a final example, we want to show how to find the five nearest points of a given set of points. This can done as follows:
|
private |