]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Restrict AccessTraits specialization to deal.II types 18564/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 20 Jun 2025 20:54:29 +0000 (16:54 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 20 Jun 2025 20:54:29 +0000 (16:54 -0400)
include/deal.II/arborx/access_traits.h
include/deal.II/base/bounding_box.h
source/arborx/access_traits.cc

index 764d7938132a76d8b5d5430abcfc00901cf40728..9e619554b04e812b29aa22de53ca830f7f82e295 100644 (file)
@@ -749,7 +749,16 @@ namespace ArborX
    * This struct allows ArborX to use std::vector<T> as primitive.
    */
   template <typename T>
-  struct AccessTraits<std::vector<T>>
+  struct AccessTraits<
+    std::vector<T>,
+    std::enable_if_t<
+      std::is_same_v<T, dealii::Point<T::dimension, float>> ||
+      std::is_same_v<T, dealii::Point<T::dimension, double>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, float>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, double>> ||
+      std::is_same_v<T, std::pair<dealii::Point<T::dimension, float>, float>> ||
+      std::is_same_v<T,
+                     std::pair<dealii::Point<T::dimension, double>, double>>>>
   {
     using memory_space = Kokkos::HostSpace;
 
index e5d95e47747774b276a1b439534294c951248294..159bee7b42f7ba2af830d74fe7a617e3f33f9e5c 100644 (file)
@@ -135,6 +135,12 @@ template <int spacedim, typename Number = double>
 class BoundingBox
 {
 public:
+  /**
+   * Provide a way to get the dimension of an object without explicit
+   * knowledge of it's data type.
+   */
+  static constexpr unsigned int dimension = spacedim;
+
   /**
    * Standard constructor. Creates an object that corresponds to an empty box,
    * i.e. a degenerate box with both points being the origin.
index bead71f741b2178192d09c5e08a90806b5ee6567..bb14cd3ec3a2dc83d28970f9395f56bf04ce8029 100644 (file)
@@ -504,7 +504,17 @@ namespace ArborX
 #  else
   template <typename T>
   std::size_t
-  AccessTraits<std::vector<T>>::size(const std::vector<T> &v)
+  AccessTraits<
+    std::vector<T>,
+    std::enable_if_t<
+      std::is_same_v<T, dealii::Point<T::dimension, float>> ||
+      std::is_same_v<T, dealii::Point<T::dimension, double>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, float>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, double>> ||
+      std::is_same_v<T, std::pair<dealii::Point<T::dimension, float>, float>> ||
+      std::is_same_v<T,
+                     std::pair<dealii::Point<T::dimension, double>, double>>>>::
+    size(const std::vector<T> &v)
   {
     return v.size();
   }
@@ -513,7 +523,17 @@ namespace ArborX
 
   template <typename T>
   T
-  AccessTraits<std::vector<T>>::get(const std::vector<T> &v, std::size_t i)
+  AccessTraits<
+    std::vector<T>,
+    std::enable_if_t<
+      std::is_same_v<T, dealii::Point<T::dimension, float>> ||
+      std::is_same_v<T, dealii::Point<T::dimension, double>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, float>> ||
+      std::is_same_v<T, dealii::BoundingBox<T::dimension, double>> ||
+      std::is_same_v<T, std::pair<dealii::Point<T::dimension, float>, float>> ||
+      std::is_same_v<T,
+                     std::pair<dealii::Point<T::dimension, double>, double>>>>::
+    get(const std::vector<T> &v, std::size_t i)
   {
     return v[i];
   }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.