Skip to content

Commit

Permalink
Update code to use tag_t and coordinate_t
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Feb 2, 2024
1 parent 9253614 commit 3030e9a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 52 deletions.
16 changes: 8 additions & 8 deletions src/ArborX_BruteForce.hpp
Expand Up @@ -27,14 +27,14 @@
namespace ArborX
{

template <
typename MemorySpace, typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>::type>>
template <typename MemorySpace,
typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
class BruteForce
{
public:
Expand Down
16 changes: 8 additions & 8 deletions src/ArborX_DistributedTree.hpp
Expand Up @@ -116,14 +116,14 @@ class DistributedTreeBase

// NOTE: query() must be called as collective over all processes in the
// communicator passed to the constructor
template <
typename MemorySpace, typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>::type>>
template <typename MemorySpace,
typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
class DistributedTree
: public DistributedTreeBase<BoundingVolumeHierarchy<
MemorySpace, Value, IndexableGetter, BoundingVolume>>
Expand Down
36 changes: 18 additions & 18 deletions src/ArborX_LinearBVH.hpp
Expand Up @@ -47,14 +47,14 @@ namespace Details
struct HappyTreeFriends;
} // namespace Details

template <
typename MemorySpace, typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>::type>>
template <typename MemorySpace,
typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
class BoundingVolumeHierarchy
{
public:
Expand Down Expand Up @@ -235,14 +235,14 @@ class BoundingVolumeHierarchy<MemorySpace, Details::LegacyDefaultTemplateValue,
}
};

template <
typename MemorySpace, typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>::type>>
template <typename MemorySpace,
typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
using BVH = BoundingVolumeHierarchy<MemorySpace, Value, IndexableGetter,
BoundingVolume>;

Expand Down Expand Up @@ -304,7 +304,7 @@ BoundingVolumeHierarchy<MemorySpace, Value, IndexableGetter, BoundingVolume>::

// determine the bounding box of the scene
ExperimentalHyperGeometry::Box<
DIM, typename GeometryTraits::coordinate_type<BoundingVolume>::type>
DIM, typename GeometryTraits::coordinate_type_t<BoundingVolume>>
bbox{};
Details::TreeConstruction::calculateBoundingBoxOfTheScene(space, indexables,
bbox);
Expand Down Expand Up @@ -389,7 +389,7 @@ void BoundingVolumeHierarchy<
using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>;
ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<bounding_volume_type>,
typename GeometryTraits::coordinate_type<bounding_volume_type>::type>
typename GeometryTraits::coordinate_type_t<bounding_volume_type>>
scene_bounding_box{};
using namespace Details;
expand(scene_bounding_box, bounds());
Expand Down
2 changes: 1 addition & 1 deletion src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp
Expand Up @@ -387,7 +387,7 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space,
using bounding_volume_type = std::decay_t<decltype(tree.bounds())>;
ExperimentalHyperGeometry::Box<
GeometryTraits::dimension_v<bounding_volume_type>,
typename GeometryTraits::coordinate_type<bounding_volume_type>::type>
typename GeometryTraits::coordinate_type_t<bounding_volume_type>>
scene_bounding_box{};
using namespace Details;
expand(scene_bounding_box, tree.bounds());
Expand Down
2 changes: 1 addition & 1 deletion src/details/ArborX_NeighborList.hpp
Expand Up @@ -34,7 +34,7 @@ struct NeighborListPredicateGetter
static_assert(GeometryTraits::is_point<Point>{});

constexpr int dim = GeometryTraits::dimension_v<Point>;
using Coordinate = typename GeometryTraits::coordinate_type<Point>::type;
using Coordinate = typename GeometryTraits::coordinate_type_t<Point>;

auto const &hyper_point = reinterpret_cast<
ExperimentalHyperGeometry::Point<dim, Coordinate> const &>(point);
Expand Down
20 changes: 10 additions & 10 deletions src/geometry/ArborX_DetailsAlgorithms.hpp
Expand Up @@ -61,14 +61,14 @@ template <typename Geometry>
KOKKOS_INLINE_FUNCTION constexpr bool equals(Geometry const &l,
Geometry const &r)
{
return Dispatch::equals<typename GeometryTraits::tag<Geometry>::type,
return Dispatch::equals<typename GeometryTraits::tag_t<Geometry>,
Geometry>::apply(l, r);
}

template <typename Geometry>
KOKKOS_INLINE_FUNCTION constexpr bool isValid(Geometry const &geometry)
{
return Dispatch::isValid<typename GeometryTraits::tag<Geometry>::type,
return Dispatch::isValid<typename GeometryTraits::tag_t<Geometry>,
Geometry>::apply(geometry);
}

Expand All @@ -78,8 +78,8 @@ KOKKOS_INLINE_FUNCTION auto distance(Geometry1 const &geometry1,
{
static_assert(GeometryTraits::dimension_v<Geometry1> ==
GeometryTraits::dimension_v<Geometry2>);
return Dispatch::distance<typename GeometryTraits::tag<Geometry1>::type,
typename GeometryTraits::tag<Geometry2>::type,
return Dispatch::distance<typename GeometryTraits::tag_t<Geometry1>,
typename GeometryTraits::tag_t<Geometry2>,
Geometry1, Geometry2>::apply(geometry1, geometry2);
}

Expand All @@ -89,8 +89,8 @@ KOKKOS_INLINE_FUNCTION void expand(Geometry1 &geometry1,
{
static_assert(GeometryTraits::dimension_v<Geometry1> ==
GeometryTraits::dimension_v<Geometry2>);
Dispatch::expand<typename GeometryTraits::tag<Geometry1>::type,
typename GeometryTraits::tag<Geometry2>::type, Geometry1,
Dispatch::expand<typename GeometryTraits::tag_t<Geometry1>,
typename GeometryTraits::tag_t<Geometry2>, Geometry1,
Geometry2>::apply(geometry1, geometry2);
}

Expand All @@ -100,16 +100,16 @@ KOKKOS_INLINE_FUNCTION constexpr bool intersects(Geometry1 const &geometry1,
{
static_assert(GeometryTraits::dimension_v<Geometry1> ==
GeometryTraits::dimension_v<Geometry2>);
return Dispatch::intersects<typename GeometryTraits::tag<Geometry1>::type,
typename GeometryTraits::tag<Geometry2>::type,
return Dispatch::intersects<typename GeometryTraits::tag_t<Geometry1>,
typename GeometryTraits::tag_t<Geometry2>,
Geometry1, Geometry2>::apply(geometry1,
geometry2);
}

template <typename Geometry>
KOKKOS_INLINE_FUNCTION decltype(auto) returnCentroid(Geometry const &geometry)
{
return Dispatch::centroid<typename GeometryTraits::tag<Geometry>::type,
return Dispatch::centroid<typename GeometryTraits::tag_t<Geometry>,
Geometry>::apply(geometry);
}

Expand Down Expand Up @@ -437,7 +437,7 @@ struct intersects<PointTag, TriangleTag, Point, Triangle>
auto const &b = triangle.b;
auto const &c = triangle.c;

using Float = typename GeometryTraits::coordinate_type<Point>::type;
using Float = typename GeometryTraits::coordinate_type_t<Point>;

// Find coefficients alpha and beta such that
// x = a + alpha * (b - a) + beta * (c - a)
Expand Down
11 changes: 7 additions & 4 deletions src/geometry/ArborX_GeometryTraits.hpp
Expand Up @@ -52,12 +52,16 @@ struct tag
{
using type = not_specialized;
};
template <typename Geometry>
using tag_t = typename tag<Geometry>::type;

template <typename Geometry>
struct coordinate_type
{
using type = not_specialized;
};
template <typename Geometry>
using coordinate_type_t = typename coordinate_type<Geometry>::type;

template <typename Geometry>
using DimensionNotSpecializedArchetypeAlias =
Expand Down Expand Up @@ -111,7 +115,7 @@ void check_valid_geometry_traits(Geometry const &)
GeometryTraits::dimension_v<Geometry> > 0,
"GeometryTraits::dimension<Geometry>::value must be a positive integral");

static_assert(!std::is_same_v<typename tag<Geometry>::type, not_specialized>,
static_assert(!std::is_same_v<tag_t<Geometry>, not_specialized>,
"GeometryTraits::tag<Geometry> must define 'type' member type");
using Tag = typename tag<Geometry>::type;
static_assert(std::is_same<Tag, PointTag>{} || std::is_same<Tag, BoxTag>{} ||
Expand All @@ -121,11 +125,10 @@ void check_valid_geometry_traits(Geometry const &)
"GeometryTraits::tag<Geometry>::type must be PointTag, BoxTag, "
"SphereTag, TriangleTag or KDOPTag");

static_assert(!std::is_same_v<typename coordinate_type<Geometry>::type,
not_specialized>,
static_assert(!std::is_same_v<coordinate_type_t<Geometry>, not_specialized>,
"GeometryTraits::coordinate_type<Geometry> must define 'type' "
"member type");
using Coordinate = typename coordinate_type<Geometry>::type;
using Coordinate = coordinate_type_t<Geometry>;
static_assert(
std::is_arithmetic_v<Coordinate>,
"GeometryTraits::coordinate_type<Geometry> must be an arithmetic type");
Expand Down
Expand Up @@ -98,7 +98,7 @@ CRBF_DEF(Buhmann, 4,
template <typename CRBFunc, typename Point>
KOKKOS_INLINE_FUNCTION constexpr auto
evaluate(Point const &point,
typename GeometryTraits::coordinate_type<Point>::type const radius)
typename GeometryTraits::coordinate_type_t<Point> const radius)
{
static_assert(GeometryTraits::is_point<Point>::value,
"point must be a point");
Expand Down
Expand Up @@ -107,7 +107,7 @@ KOKKOS_FUNCTION auto evaluatePolynomialBasis(Point const &p)
static_assert(GeometryTraits::is_point<Point>::value,
"point must be a point");
static constexpr std::size_t DIM = GeometryTraits::dimension_v<Point>;
using Value = typename GeometryTraits::coordinate_type<Point>::type;
using Value = typename GeometryTraits::coordinate_type_t<Point>;
static_assert(DIM > 0, "Polynomial basis with no dimension is invalid");

Kokkos::Array<Value, polynomialBasisSize<DIM, Degree>()> arr{};
Expand Down

0 comments on commit 3030e9a

Please sign in to comment.