Skip to content

Commit

Permalink
Modernize space filling curve checks
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Dec 28, 2023
1 parent fffb2e0 commit c64e572
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/ArborX_LinearBVH.hpp
Expand Up @@ -307,9 +307,8 @@ BoundingVolumeHierarchy<MemorySpace, Value, IndexableGetter, BoundingVolume>::
Kokkos::Profiling::pushRegion("ArborX::BVH::BVH::compute_linear_ordering");

// Map indexables from multidimensional domain to one-dimensional interval
using LinearOrderingValueType = Kokkos::detected_t<
Details::SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, decltype(bbox), indexable_type>;
using LinearOrderingValueType =
std::invoke_result_t<SpaceFillingCurve, decltype(bbox), indexable_type>;
Kokkos::View<LinearOrderingValueType *, MemorySpace> linear_ordering_indices(
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
"ArborX::BVH::BVH::linear_ordering"),
Expand Down
3 changes: 1 addition & 2 deletions src/details/ArborX_DetailsBatchedQueries.hpp
Expand Up @@ -57,8 +57,7 @@ struct BatchedQueries
using Point =
std::decay_t<decltype(returnCentroid(getGeometry(predicates(0))))>;
using LinearOrderingValueType =
Kokkos::detected_t<SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, Box, Point>;
std::invoke_result_t<SpaceFillingCurve, Box, Point>;
Kokkos::View<LinearOrderingValueType *, DeviceType> linear_ordering_indices(
Kokkos::view_alloc(space, Kokkos::WithoutInitializing,
"ArborX::BVH::query::linear_ordering"),
Expand Down
26 changes: 9 additions & 17 deletions src/details/ArborX_SpaceFillingCurves.hpp
Expand Up @@ -20,6 +20,8 @@
#include <Kokkos_DetectionIdiom.hpp>
#include <Kokkos_Macros.hpp>

#include <type_traits>

namespace ArborX
{
namespace Experimental
Expand Down Expand Up @@ -74,32 +76,22 @@ struct Morton64
namespace Details
{

template <class SpaceFillingCurve, class Box, class Geometry>
using SpaceFillingCurveProjectionArchetypeExpression =
std::invoke_result_t<SpaceFillingCurve, Box, Geometry>;

template <int DIM, class SpaceFillingCurve>
void check_valid_space_filling_curve(SpaceFillingCurve const &)
{
using Point = ExperimentalHyperGeometry::Point<DIM>;
using Box = ExperimentalHyperGeometry::Box<DIM>;

static_assert(
Kokkos::is_detected<SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, Box, Point>::value);
static_assert(
Kokkos::is_detected<SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, Box, Box>::value);
static_assert(std::is_invocable_v<SpaceFillingCurve const &, Box, Point>);
static_assert(std::is_invocable_v<SpaceFillingCurve const &, Box, Box>);

using OrderValueType =
Kokkos::detected_t<SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, Box, Point>;
std::invoke_result_t<SpaceFillingCurve const &, Box, Point>;
static_assert(std::is_same<OrderValueType, unsigned int>::value ||
std::is_same<OrderValueType, unsigned long long>::value);
static_assert(
std::is_same<
OrderValueType,
Kokkos::detected_t<SpaceFillingCurveProjectionArchetypeExpression,
SpaceFillingCurve, Box, Box>>::value);
static_assert(std::is_same_v<
OrderValueType,
std::invoke_result_t<SpaceFillingCurve const &, Box, Box>>);
}

} // namespace Details
Expand Down

0 comments on commit c64e572

Please sign in to comment.