From 6c8e7aedc20118a5900a980538fb4afc73dbcc86 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Fri, 20 Jun 2025 16:54:29 -0400 Subject: [PATCH] Restrict AccessTraits specialization to deal.II types --- include/deal.II/arborx/access_traits.h | 11 ++++++++++- include/deal.II/base/bounding_box.h | 6 ++++++ source/arborx/access_traits.cc | 24 ++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/deal.II/arborx/access_traits.h b/include/deal.II/arborx/access_traits.h index 764d793813..9e619554b0 100644 --- a/include/deal.II/arborx/access_traits.h +++ b/include/deal.II/arborx/access_traits.h @@ -749,7 +749,16 @@ namespace ArborX * This struct allows ArborX to use std::vector as primitive. */ template - struct AccessTraits> + struct AccessTraits< + std::vector, + std::enable_if_t< + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v, float>> || + std::is_same_v, double>>>> { using memory_space = Kokkos::HostSpace; diff --git a/include/deal.II/base/bounding_box.h b/include/deal.II/base/bounding_box.h index e5d95e4774..159bee7b42 100644 --- a/include/deal.II/base/bounding_box.h +++ b/include/deal.II/base/bounding_box.h @@ -135,6 +135,12 @@ template 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. diff --git a/source/arborx/access_traits.cc b/source/arborx/access_traits.cc index bead71f741..bb14cd3ec3 100644 --- a/source/arborx/access_traits.cc +++ b/source/arborx/access_traits.cc @@ -504,7 +504,17 @@ namespace ArborX # else template std::size_t - AccessTraits>::size(const std::vector &v) + AccessTraits< + std::vector, + std::enable_if_t< + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v, float>> || + std::is_same_v, double>>>>:: + size(const std::vector &v) { return v.size(); } @@ -513,7 +523,17 @@ namespace ArborX template T - AccessTraits>::get(const std::vector &v, std::size_t i) + AccessTraits< + std::vector, + std::enable_if_t< + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v> || + std::is_same_v, float>> || + std::is_same_v, double>>>>:: + get(const std::vector &v, std::size_t i) { return v[i]; } -- 2.39.5