IndexableGetter¶
Defined in header <ArborX_IndexableGetter.hpp>
A spatial index stores values and searches them by the geometry they occupy
in space, called their indexable.
The IndexableGetter template argument of a spatial index (e.g.,
BoundingVolumeHierarchy) is the function object that extracts the
indexable from a value.
An IndexableGetter must
provide a
constoperator()taking in a type that decays to theValueof the spatial index and returning an indexable, i.e., a geometry such as a Point, andbe callable from the device, which means its call operator needs to be marked with the
KOKKOS_FUNCTIONmacro.
When the values are geometries, or wrap a geometry in an
ArborX::PairValueIndex, Experimental::DefaultIndexableGetter
is all that is needed and is the default.
A custom one is required when the geometry is not stored in the value itself.
DefaultIndexableGetter¶
-
struct Experimental::DefaultIndexableGetter¶
The default
IndexableGetter. It uses the value itself as the indexable, or the geometry it wraps if the value is anArborX::PairValueIndex.-
KOKKOS_FUNCTION DefaultIndexableGetter() = default¶
-
template<typename Geometry>
KOKKOS_FUNCTION auto const &operator()(Geometry const &geometry) const¶ - Returns:
geometry.
-
template<typename Geometry, typename Index>
KOKKOS_FUNCTION Geometry const &operator()(PairValueIndex<Geometry, Index> const &pair) const¶ - Returns:
pair.value, the geometry wrapped bypair.
A geometry that is not
const(an rvalue or a non-constlvalue) is returned by value, and so is the geometry of an rvalueArborX::PairValueIndex, instead of a reference.-
KOKKOS_FUNCTION DefaultIndexableGetter() = default¶
Example¶
The values below are the identifiers of the objects, and the geometry of each object lives in a separate view. The default getter cannot be used since an identifier is not a geometry, so we provide one that looks up the point of the object.
template <typename MemorySpace>
struct PointOfObject
{
Kokkos::View<ArborX::Point<3> *, MemorySpace> points;
KOKKOS_FUNCTION ArborX::Point<3> operator()(int id) const
{
return points(id);
}
};
// ids is a Kokkos::View<int *, MemorySpace>
ArborX::BoundingVolumeHierarchy bvh(space, ids,
PointOfObject<MemorySpace>{points});