deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ArborXWrappers::BVH Class Reference

#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
 

Detailed Description

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.

Definition at line 53 of file bvh.h.

Constructor & Destructor Documentation

◆ BVH() [1/2]

template<int dim, typename Number >
ArborXWrappers::BVH::BVH ( const std::vector< BoundingBox< dim, Number > > &  bounding_boxes)

Constructor. Use a vector of BoundingBox bounding_boxes as primitives.

Definition at line 151 of file bvh.h.

◆ BVH() [2/2]

template<int dim, typename Number >
ArborXWrappers::BVH::BVH ( const std::vector< Point< dim, Number > > &  points)

Constructor. Use a vector of points as primitives.

Definition at line 158 of file bvh.h.

Member Function Documentation

◆ query()

template<typename QueryType >
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:

const std::vector<BoundingBox<dim>> query_bounding_boxes = ...
ArborXWrappers::BoundingBoxIntersectPredicate
bb_intersect(query_bounding_boxes);
const std::vector<BoundingBox<dim>> bvh_bounding_boxes = ...
ArborxWrappers::BVH bvh(bvh_bounding_boxes);
auto [indices, offset] = bvh.query(bb_intersect);
ArborX::BVH< Kokkos::HostSpace > bvh
Definition bvh.h:145

The elements of bvh_bounding_boxes that intersect the jth BoundingBox of query_bounding_boxes are given by:

std::vector<int> bvh_bounding_box_indices;
for (int i = offset[j]; i < offset[j+1]; ++i)
bvh_bounding_box_indices.push_back(indices[i]);

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:

const std::vector<Point<dim>> query_points = ...
ArborXWrappers::PointIntersectPredicate pt_intersect(query_points);
const std::vector<BoundingBox<dim>> bvh_bounding_boxes = ...
ArborxWrappers::BVH bvh(bvh_bounding_boxes);
auto [indices, offset] = bvh.query(pt_intersect);

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:

const std::vector<Point<dim>> query_points = ...
ArborXWrappers::PointNearestPredicate pt_nearest(query_points, 5);
const std::vector<Point<dim>> bvh_points = ...
ArborxWrappers::BVH bvh(bvh_points);
auto [indices, offset] = bvh.query(pt_nearest);

Definition at line 166 of file bvh.h.

Member Data Documentation

◆ bvh

ArborX::BVH<Kokkos::HostSpace> ArborXWrappers::BVH::bvh
private

Underlying ArborX object.

Definition at line 145 of file bvh.h.


The documentation for this class was generated from the following file: