Reference documentation for deal.II version 9.6.0
\(\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
bvh.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2021 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_arborx_bvh_h
16#define dealii_arborx_bvh_h
17
18#include <deal.II/base/config.h>
19
20#ifdef DEAL_II_WITH_ARBORX
22
23# include <ArborX_LinearBVH.hpp>
24# include <Kokkos_Core.hpp>
25
27
31namespace ArborXWrappers
32{
53 class BVH
54 {
55 public:
59 template <int dim, typename Number>
60 BVH(const std::vector<BoundingBox<dim, Number>> &bounding_boxes);
61
65 template <int dim, typename Number>
66 BVH(const std::vector<Point<dim, Number>> &points);
67
137 template <typename QueryType>
138 std::pair<std::vector<int>, std::vector<int>>
139 query(const QueryType &queries);
140
141 private:
145 ArborX::BVH<Kokkos::HostSpace> bvh;
146 };
147
148
149
150 template <int dim, typename Number>
151 BVH::BVH(const std::vector<BoundingBox<dim, Number>> &bounding_boxes)
152 : bvh(Kokkos::DefaultHostExecutionSpace{}, bounding_boxes)
153 {}
154
155
156
157 template <int dim, typename Number>
158 BVH::BVH(const std::vector<Point<dim, Number>> &points)
159 : bvh(Kokkos::DefaultHostExecutionSpace{}, points)
160 {}
161
162
163
164 template <typename QueryType>
165 std::pair<std::vector<int>, std::vector<int>>
166 BVH::query(const QueryType &queries)
167 {
168 Kokkos::View<int *, Kokkos::HostSpace> indices("indices", 0);
169
170 Kokkos::View<int *, Kokkos::HostSpace> offset("offset", 0);
171 ArborX::query(
172 bvh, Kokkos::DefaultHostExecutionSpace{}, queries, indices, offset);
173 std::vector<int> indices_vector;
174 indices_vector.insert(indices_vector.begin(),
175 indices.data(),
176 indices.data() + indices.extent(0));
177 std::vector<int> offset_vector;
178 offset_vector.insert(offset_vector.begin(),
179 offset.data(),
180 offset.data() + offset.extent(0));
181
182 return {indices_vector, offset_vector};
183 }
184} // namespace ArborXWrappers
185
187
188#endif
189#endif
ArborX::BVH< Kokkos::HostSpace > bvh
Definition bvh.h:145
std::pair< std::vector< int >, std::vector< int > > query(const QueryType &queries)
Definition bvh.h:166
BVH(const std::vector< BoundingBox< dim, Number > > &bounding_boxes)
Definition bvh.h:151
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504