]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce to_arborx_point function
authorBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 19 Jun 2025 19:59:32 +0000 (15:59 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 19 Jun 2025 19:59:32 +0000 (15:59 -0400)
include/deal.II/arborx/access_traits.h

index 9ba7212d3aa3a8ce19a55e1297a9ff1c1e313aa5..3f5410e61d7047e18437c2f7c0a728eff50227e9 100644 (file)
@@ -312,23 +312,32 @@ namespace ArborXWrappers
     {
       template <int dim, typename Number>
       ArborX::Point<dim, Number>
-      operator()(const ArborX::PairValueIndex<dealii::Point<dim, Number>,
-                                              unsigned int> &pair) const
+      to_arborx_point(const dealii::Point<dim, Number> &p) const
       {
         if constexpr (dim == 1)
           {
-            return {pair.value[0]};
+            return {p[0]};
           }
+
         if constexpr (dim == 2)
           {
-            return {pair.value[0], pair.value[1]};
+            return {p[0], p[1]};
           }
+
         if constexpr (dim == 3)
           {
-            return {pair.value[0], pair.value[1], pair.value[2]};
+            return {p[0], p[1], p[2]};
           }
       }
 
+      template <int dim, typename Number>
+      ArborX::Point<dim, Number>
+      operator()(const ArborX::PairValueIndex<dealii::Point<dim, Number>,
+                                              unsigned int> &pair) const
+      {
+        return to_arborx_point(pair.value);
+      }
+
 
 
       template <int dim, typename Number>
@@ -339,20 +348,7 @@ namespace ArborXWrappers
         const auto boundary_points = pair.value.get_boundary_points();
         const dealii::Point<dim, Number> min_corner = boundary_points.first;
         const dealii::Point<dim, Number> max_corner = boundary_points.second;
-        if constexpr (dim == 1)
-          {
-            return {{min_corner[0]}, {max_corner[0]}};
-          }
-        if constexpr (dim == 2)
-          {
-            return {{min_corner[0], min_corner[1]},
-                    {max_corner[0], max_corner[1]}};
-          }
-        if constexpr (dim == 3)
-          {
-            return {{min_corner[0], min_corner[1], min_corner[2]},
-                    {max_corner[0], max_corner[1], max_corner[2]}};
-          }
+        return {to_arborx_point(min_corner), to_arborx_point(max_corner)};
       }
 
 
@@ -363,22 +359,7 @@ namespace ArborXWrappers
                  std::pair<dealii::Point<dim, Number>, Number>,
                  unsigned int> &pair) const
       {
-        if constexpr (dim == 1)
-          {
-            return {{pair.value.first[0]}, pair.value.second};
-          }
-        if constexpr (dim == 2)
-          {
-            return {{pair.value.first[0], pair.value.first[1]},
-                    pair.value.second};
-          }
-        if constexpr (dim == 3)
-          {
-            return {{pair.value.first[0],
-                     pair.value.first[1],
-                     pair.value.first[2]},
-                    pair.value.second};
-          }
+        return {to_arborx_point(pair.value.first), pair.value.second};
       }
     };
 

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.