Reference documentation for deal.II version 9.4.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\}}\)
bvh.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_arborx_bvh_h
17#define dealii_arborx_bvh_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_ARBORX
23
24# include <ArborX_LinearBVH.hpp>
25# include <Kokkos_Core.hpp>
26
28
32namespace ArborXWrappers
33{
54 class BVH
55 {
56 public:
60 template <int dim, typename Number>
61 BVH(const std::vector<BoundingBox<dim, Number>> &bounding_boxes);
62
66 template <int dim, typename Number>
67 BVH(const std::vector<Point<dim, Number>> &points);
68
138 template <typename QueryType>
139 std::pair<std::vector<int>, std::vector<int>>
140 query(const QueryType &queries);
141
142 private:
146 ArborX::BVH<Kokkos::HostSpace> bvh;
147 };
148
149
150
151 template <int dim, typename Number>
152 BVH::BVH(const std::vector<BoundingBox<dim, Number>> &bounding_boxes)
153 : bvh(Kokkos::DefaultHostExecutionSpace{}, bounding_boxes)
154 {}
155
156
157
158 template <int dim, typename Number>
159 BVH::BVH(const std::vector<Point<dim, Number>> &points)
160 : bvh(Kokkos::DefaultHostExecutionSpace{}, points)
161 {}
162
163
164
165 template <typename QueryType>
166 std::pair<std::vector<int>, std::vector<int>>
167 BVH::query(const QueryType &queries)
168 {
169 Kokkos::View<int *, Kokkos::HostSpace> indices("indices", 0);
170
171 Kokkos::View<int *, Kokkos::HostSpace> offset("offset", 0);
172 ArborX::query(
173 bvh, Kokkos::DefaultHostExecutionSpace{}, queries, indices, offset);
174 std::vector<int> indices_vector;
175 indices_vector.insert(indices_vector.begin(),
176 indices.data(),
177 indices.data() + indices.extent(0));
178 std::vector<int> offset_vector;
179 offset_vector.insert(offset_vector.begin(),
180 offset.data(),
181 offset.data() + offset.extent(0));
182
183 return {indices_vector, offset_vector};
184 }
185} // namespace ArborXWrappers
186
188
189#endif
190#endif
ArborX::BVH< Kokkos::HostSpace > bvh
Definition: bvh.h:146
std::pair< std::vector< int >, std::vector< int > > query(const QueryType &queries)
Definition: bvh.h:167
BVH(const std::vector< BoundingBox< dim, Number > > &bounding_boxes)
Definition: bvh.h:152
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443