Reference documentation for deal.II version 9.3.3
\(\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\}}\)
access_traits.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_access_traits_h
17#define dealii_arborx_access_traits_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_ARBORX
23
24# include <ArborX.hpp>
25
26
28
30{
36 {
37 protected:
41 template <int dim, typename Number>
42 PointPredicate(const std::vector<::Point<dim, Number>> &points);
43
47 std::size_t
48 size() const;
49
53 const ::Point<3, float> &
54 get(unsigned int i) const;
55
56 private:
57 std::vector<::Point<3, float>> points;
58 };
59
60
61
69 {
70 public:
75 template <int dim, typename Number>
77 const std::vector<::Point<dim, Number>> &points);
78
79 // We need these since we inherit privately to avoid polymorphic use.
82 };
83
84
85
93 {
94 public:
100 template <int dim, typename Number>
102 const unsigned int n_nearest_neighbors);
103
107 unsigned int
109
110 // We need these since we inherit privately to avoid polymorphic use.
113
114 private:
116 };
117
118
119
125 {
126 protected:
131 template <int dim, typename Number>
133 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes);
134
138 std::size_t
139 size() const;
140
144 const ::BoundingBox<3, float> &
145 get(unsigned int i) const;
146
147 private:
148 std::vector<::BoundingBox<3, float>> bounding_boxes;
149 };
150
151
152
160 {
161 public:
166 template <int dim, typename Number>
168 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes);
169
170 // We need these since we inherit privately to avoid polymorphic use.
173 };
174
175
183 {
184 public:
190 template <int dim, typename Number>
192 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes,
193 const unsigned int n_nearest_neighbors);
194
198 unsigned int
200
201 // We need these since we inherit privately to avoid polymorphic use.
204
205 private:
207 };
208} // namespace ArborXWrappers
209
211
215namespace ArborX
216{
221 template <int dim, typename Number>
222 struct AccessTraits<std::vector<::Point<dim, Number>>, PrimitivesTag>
223 {
224 using memory_space = Kokkos::HostSpace;
225
229 static std::size_t
230 size(const std::vector<::Point<dim, Number>> &v);
231
235 static Point
236 get(const std::vector<::Point<dim, Number>> &v, std::size_t i);
237 };
238
239
240
245 template <int dim, typename Number>
246 struct AccessTraits<std::vector<::BoundingBox<dim, Number>>,
247 PrimitivesTag>
248 {
249 using memory_space = Kokkos::HostSpace;
250
254 static std::size_t
255 size(const std::vector<::BoundingBox<dim, Number>> &v);
256
260 static Box
261 get(const std::vector<::BoundingBox<dim, Number>> &v, std::size_t i);
262 };
263
264
265
269 template <>
271 PredicatesTag>
272 {
273 using memory_space = Kokkos::HostSpace;
274
278 static std::size_t
279 size(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect);
280
285 static auto
286 get(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect,
287 std::size_t i);
288 };
289
290
294 template <>
296 PredicatesTag>
297 {
298 using memory_space = Kokkos::HostSpace;
299
303 static std::size_t
304 size(const ::ArborXWrappers::PointNearestPredicate &pt_nearest);
305
311 static auto
312 get(const ::ArborXWrappers::PointNearestPredicate &pt_nearest,
313 std::size_t i);
314 };
315
316
321 template <>
323 PredicatesTag>
324 {
325 using memory_space = Kokkos::HostSpace;
326
330 static std::size_t
331 size(const ::ArborXWrappers::BoundingBoxIntersectPredicate
332 &bb_intersect);
333
338 static auto
339 get(
340 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect,
341 std::size_t i);
342 };
343
344
349 template <>
351 PredicatesTag>
352 {
353 using memory_space = Kokkos::HostSpace;
354
358 static std::size_t
359 size(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest);
360
368 static auto
369 get(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest,
370 std::size_t i);
371 };
372
373 // ------------------------------- Inline ----------------------------------//
374
375 // The implementation of AccessTraits<..., PredicatesTag> needs to be in the
376 // header file otherwise the return type of auto get() cannot be determined.
377 // We use auto because ArborX does not expose the type of intersects
378
379 inline std::size_t
380 AccessTraits<::ArborXWrappers::PointIntersectPredicate, PredicatesTag>::
381 size(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect)
382 {
383 return pt_intersect.size();
384 }
385
386
387
388 inline auto
389 AccessTraits<::ArborXWrappers::PointIntersectPredicate, PredicatesTag>::
390 get(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect,
391 std::size_t i)
392 {
393 const auto dealii_point = pt_intersect.get(i);
394 return intersects(Point{dealii_point[0], dealii_point[1], dealii_point[2]});
395 }
396
397
398
399 inline std::size_t
400 AccessTraits<::ArborXWrappers::PointNearestPredicate, PredicatesTag>::
401 size(const ::ArborXWrappers::PointNearestPredicate &pt_nearest)
402 {
403 return pt_nearest.size();
404 }
405
406
407
408 inline auto
409 AccessTraits<::ArborXWrappers::PointNearestPredicate, PredicatesTag>::
410 get(const ::ArborXWrappers::PointNearestPredicate &pt_nearest,
411 std::size_t i)
412 {
413 const auto dealii_point = pt_nearest.get(i);
414 return nearest(Point{dealii_point[0], dealii_point[1], dealii_point[2]},
415 pt_nearest.get_n_nearest_neighbors());
416 }
417
418
419
420 inline std::size_t
422 PredicatesTag>::
423 size(
424 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect)
425 {
426 return bb_intersect.size();
427 }
428
429
430
431 inline auto
433 PredicatesTag>::
434 get(
435 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect,
436 std::size_t i)
437 {
438 const auto boundary_points = bb_intersect.get(i).get_boundary_points();
439 const ::Point<3, float> min_corner = boundary_points.first;
440 const ::Point<3, float> max_corner = boundary_points.second;
441
442 return intersects(Box{{min_corner[0], min_corner[1], min_corner[2]},
443 {max_corner[0], max_corner[1], max_corner[2]}});
444 }
445
446
447
448 inline std::size_t
450 PredicatesTag>::
451 size(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest)
452 {
453 return bb_nearest.size();
454 }
455
456
457
458 inline auto
460 PredicatesTag>::
461 get(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest,
462 std::size_t i)
463 {
464 const auto boundary_points = bb_nearest.get(i).get_boundary_points();
465 const ::Point<3, float> min_corner = boundary_points.first;
466 const ::Point<3, float> max_corner = boundary_points.second;
467
468 return nearest(Box{{min_corner[0], min_corner[1], min_corner[2]},
469 {max_corner[0], max_corner[1], max_corner[2]}},
470 bb_nearest.get_n_nearest_neighbors());
471 }
472} // namespace ArborX
473
474#endif
475
476#endif
BoundingBoxIntersectPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes)
const ::BoundingBox< 3, float > & get(unsigned int i) const
BoundingBoxNearestPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes, const unsigned int n_nearest_neighbors)
const ::BoundingBox< 3, float > & get(unsigned int i) const
BoundingBoxPredicate(const std::vector<::BoundingBox< dim, Number > > &bounding_boxes)
std::vector<::BoundingBox< 3, float > > bounding_boxes
const ::BoundingBox< 3, float > & get(unsigned int i) const
PointIntersectPredicate(const std::vector<::Point< dim, Number > > &points)
unsigned int get_n_nearest_neighbors() const
PointNearestPredicate(const std::vector<::Point< dim, Number > > &points, const unsigned int n_nearest_neighbors)
std::vector<::Point< 3, float > > points
Definition: access_traits.h:57
PointPredicate(const std::vector<::Point< dim, Number > > &points)
const ::Point< 3, float > & get(unsigned int i) const
std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points()
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
STL namespace.