Reference documentation for deal.II version 9.4.1
\(\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
access_traits.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2021 - 2022 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# include <utility>
27
28
30
32{
38 {
39 protected:
43 template <int dim, typename Number>
44 PointPredicate(const std::vector<::Point<dim, Number>> &points);
45
49 std::size_t
50 size() const;
51
55 const ::Point<3, float> &
56 get(unsigned int i) const;
57
58 private:
59 std::vector<::Point<3, float>> points;
60 };
61
62
63
71 {
72 public:
77 template <int dim, typename Number>
79 const std::vector<::Point<dim, Number>> &points);
80
81 // We need these since we inherit privately to avoid polymorphic use.
84 };
85
86
87
95 {
96 public:
102 template <int dim, typename Number>
104 const unsigned int n_nearest_neighbors);
105
109 unsigned int
111
112 // We need these since we inherit privately to avoid polymorphic use.
115
116 private:
118 };
119
120
121
127 {
128 protected:
133 template <int dim, typename Number>
135 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes);
136
140 std::size_t
141 size() const;
142
146 const ::BoundingBox<3, float> &
147 get(unsigned int i) const;
148
149 private:
150 std::vector<::BoundingBox<3, float>> bounding_boxes;
151 };
152
153
154
162 {
163 public:
168 template <int dim, typename Number>
170 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes);
171
172 // We need these since we inherit privately to avoid polymorphic use.
175 };
176
177
185 {
186 public:
192 template <int dim, typename Number>
194 const std::vector<::BoundingBox<dim, Number>> &bounding_boxes,
195 const unsigned int n_nearest_neighbors);
196
200 unsigned int
202
203 // We need these since we inherit privately to avoid polymorphic use.
206
207 private:
209 };
210
211
212
218 {
219 protected:
224 template <int dim, typename Number>
226 const std::vector<std::pair<::Point<dim, Number>, Number>>
227 &spheres);
228
232 std::size_t
233 size() const;
234
238 const std::pair<::Point<3, float>, float> &
239 get(unsigned int) const;
240
241 private:
242 std::vector<std::pair<::Point<3, float>, float>> spheres;
243 };
244
245
246
254 {
255 public:
260 template <int dim, typename Number>
262 const std::vector<std::pair<::Point<dim, Number>, Number>>
263 &spheres);
264
265 // We need these since we inherit privately to avoid polymorphic use.
268 };
269
270
271
279 {
280 public:
286 template <int dim, typename Number>
288 const std::vector<std::pair<::Point<dim, Number>, Number>> &spheres,
289 const unsigned int n_nearest_neighbors);
290
294 unsigned int
296
297 // We need these since we inherit privately to avoid polymorphic use.
300
301 private:
303 };
304} // namespace ArborXWrappers
305
307
311namespace ArborX
312{
317 template <int dim, typename Number>
318 struct AccessTraits<std::vector<::Point<dim, Number>>, PrimitivesTag>
319 {
320 using memory_space = Kokkos::HostSpace;
321
325 static std::size_t
326 size(const std::vector<::Point<dim, Number>> &v);
327
331 static Point
332 get(const std::vector<::Point<dim, Number>> &v, std::size_t i);
333 };
334
335
336
341 template <int dim, typename Number>
342 struct AccessTraits<std::vector<::BoundingBox<dim, Number>>,
343 PrimitivesTag>
344 {
345 using memory_space = Kokkos::HostSpace;
346
350 static std::size_t
351 size(const std::vector<::BoundingBox<dim, Number>> &v);
352
356 static Box
357 get(const std::vector<::BoundingBox<dim, Number>> &v, std::size_t i);
358 };
359
360
361
366 template <int dim, typename Number>
367 struct AccessTraits<
368 std::vector<std::pair<::Point<dim, Number>, Number>>,
369 PrimitivesTag>
370 {
371 using memory_space = Kokkos::HostSpace;
372
376 static std::size_t
377 size(const std::vector<std::pair<::Point<dim, Number>, Number>> &v);
378
383 static Sphere
384 get(const std::vector<std::pair<::Point<dim, Number>, Number>> &v,
385 std::size_t i);
386 };
387
388
389
393 template <>
395 PredicatesTag>
396 {
397 using memory_space = Kokkos::HostSpace;
398
402 static std::size_t
403 size(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect);
404
409 static auto
410 get(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect,
411 std::size_t i);
412 };
413
414
415
419 template <>
421 PredicatesTag>
422 {
423 using memory_space = Kokkos::HostSpace;
424
428 static std::size_t
429 size(const ::ArborXWrappers::PointNearestPredicate &pt_nearest);
430
436 static auto
437 get(const ::ArborXWrappers::PointNearestPredicate &pt_nearest,
438 std::size_t i);
439 };
440
441
442
447 template <>
449 PredicatesTag>
450 {
451 using memory_space = Kokkos::HostSpace;
452
456 static std::size_t
457 size(const ::ArborXWrappers::BoundingBoxIntersectPredicate
458 &bb_intersect);
459
464 static auto
465 get(
466 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect,
467 std::size_t i);
468 };
469
470
471
476 template <>
478 PredicatesTag>
479 {
480 using memory_space = Kokkos::HostSpace;
481
485 static std::size_t
486 size(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest);
487
495 static auto
496 get(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest,
497 std::size_t i);
498 };
499
500
501
505 template <>
507 PredicatesTag>
508 {
509 using memory_space = Kokkos::HostSpace;
510
514 static std::size_t
515 size(const ::ArborXWrappers::SphereIntersectPredicate &sph_intersect);
516
521 static auto
522 get(const ::ArborXWrappers::SphereIntersectPredicate &sph_intersect,
523 std::size_t i);
524 };
525
526
527
531 template <>
533 PredicatesTag>
534 {
535 using memory_space = Kokkos::HostSpace;
536
540 static std::size_t
541 size(const ::ArborXWrappers::SphereNearestPredicate &sph_nearest);
542
548 static auto
549 get(const ::ArborXWrappers::SphereNearestPredicate &sph_nearest,
550 std::size_t i);
551 };
552
553 // ------------------------------- Inline ----------------------------------//
554
555 // The implementation of AccessTraits<..., PredicatesTag> needs to be in the
556 // header file otherwise the return type of auto get() cannot be determined.
557 // We use auto because ArborX does not expose the type of intersects
558
559 inline std::size_t
560 AccessTraits<::ArborXWrappers::PointIntersectPredicate, PredicatesTag>::
561 size(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect)
562 {
563 return pt_intersect.size();
564 }
565
566
567
568 inline auto
569 AccessTraits<::ArborXWrappers::PointIntersectPredicate, PredicatesTag>::
570 get(const ::ArborXWrappers::PointIntersectPredicate &pt_intersect,
571 std::size_t i)
572 {
573 const auto dealii_point = pt_intersect.get(i);
574 return intersects(Point{dealii_point[0], dealii_point[1], dealii_point[2]});
575 }
576
577
578
579 inline std::size_t
580 AccessTraits<::ArborXWrappers::PointNearestPredicate, PredicatesTag>::
581 size(const ::ArborXWrappers::PointNearestPredicate &pt_nearest)
582 {
583 return pt_nearest.size();
584 }
585
586
587
588 inline auto
589 AccessTraits<::ArborXWrappers::PointNearestPredicate, PredicatesTag>::
590 get(const ::ArborXWrappers::PointNearestPredicate &pt_nearest,
591 std::size_t i)
592 {
593 const auto dealii_point = pt_nearest.get(i);
594 return nearest(Point{dealii_point[0], dealii_point[1], dealii_point[2]},
595 pt_nearest.get_n_nearest_neighbors());
596 }
597
598
599
600 inline std::size_t
602 PredicatesTag>::
603 size(
604 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect)
605 {
606 return bb_intersect.size();
607 }
608
609
610
611 inline auto
613 PredicatesTag>::
614 get(
615 const ::ArborXWrappers::BoundingBoxIntersectPredicate &bb_intersect,
616 std::size_t i)
617 {
618 const auto boundary_points = bb_intersect.get(i).get_boundary_points();
619 const ::Point<3, float> min_corner = boundary_points.first;
620 const ::Point<3, float> max_corner = boundary_points.second;
621
622 return intersects(Box{{min_corner[0], min_corner[1], min_corner[2]},
623 {max_corner[0], max_corner[1], max_corner[2]}});
624 }
625
626
627
628 inline std::size_t
630 PredicatesTag>::
631 size(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest)
632 {
633 return bb_nearest.size();
634 }
635
636
637
638 inline auto
640 PredicatesTag>::
641 get(const ::ArborXWrappers::BoundingBoxNearestPredicate &bb_nearest,
642 std::size_t i)
643 {
644 const auto boundary_points = bb_nearest.get(i).get_boundary_points();
645 const ::Point<3, float> min_corner = boundary_points.first;
646 const ::Point<3, float> max_corner = boundary_points.second;
647
648 return nearest(Box{{min_corner[0], min_corner[1], min_corner[2]},
649 {max_corner[0], max_corner[1], max_corner[2]}},
650 bb_nearest.get_n_nearest_neighbors());
651 }
652
653
654
655 inline std::size_t
657 PredicatesTag>::
658 size(const ::ArborXWrappers::SphereIntersectPredicate &sph_intersect)
659 {
660 return sph_intersect.size();
661 }
662
663
664
665 inline auto
667 PredicatesTag>::
668 get(const ::ArborXWrappers::SphereIntersectPredicate &sph_intersect,
669 std::size_t i)
670 {
671 const auto sphere = sph_intersect.get(i);
672 return intersects(
673 Sphere{{sphere.first[0], sphere.first[1], sphere.first[2]},
674 sphere.second});
675 }
676
677
678
679 inline std::size_t
680 AccessTraits<::ArborXWrappers::SphereNearestPredicate, PredicatesTag>::
681 size(const ::ArborXWrappers::SphereNearestPredicate &sph_nearest)
682 {
683 return sph_nearest.size();
684 }
685
686
687
688 inline auto
689 AccessTraits<::ArborXWrappers::SphereNearestPredicate, PredicatesTag>::
690 get(const ::ArborXWrappers::SphereNearestPredicate &sph_nearest,
691 std::size_t i)
692 {
693 const auto sphere = sph_nearest.get(i);
694 return nearest(Sphere{{sphere.first[0], sphere.first[1], sphere.first[2]},
695 sphere.second},
696 sph_nearest.get_n_nearest_neighbors());
697 }
698} // namespace ArborX
699
700#endif
701
702#endif
const ::BoundingBox< 3, float > & get(unsigned int i) const
const ::BoundingBox< 3, float > & get(unsigned int i) const
std::vector<::BoundingBox< 3, float > > bounding_boxes
const ::BoundingBox< 3, float > & get(unsigned int i) const
unsigned int get_n_nearest_neighbors() const
std::vector<::Point< 3, float > > points
Definition: access_traits.h:59
const ::Point< 3, float > & get(unsigned int i) const
const std::pair<::Point< 3, float >, float > & get(unsigned int) const
unsigned int get_n_nearest_neighbors() const
const std::pair<::Point< 3, float >, float > & get(unsigned int) const
std::vector< std::pair<::Point< 3, float >, float > > spheres
std::pair< Point< spacedim, Number >, Point< spacedim, Number > > & get_boundary_points()
Definition: point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
STL namespace.