-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathArborX_IndexableGetter.hpp
94 lines (75 loc) · 2.5 KB
/
ArborX_IndexableGetter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/****************************************************************************
* Copyright (c) 2025, ArborX authors *
* All rights reserved. *
* *
* This file is part of the ArborX library. ArborX is *
* distributed under a BSD 3-clause license. For the licensing terms see *
* the LICENSE file in the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/
#ifndef ARBORX_INDEXABLE_GETTER_HPP
#define ARBORX_INDEXABLE_GETTER_HPP
#include <ArborX_GeometryTraits.hpp>
#include <detail/ArborX_AccessTraits.hpp>
#include <detail/ArborX_PairValueIndex.hpp>
namespace ArborX
{
namespace Experimental
{
struct DefaultIndexableGetter
{
KOKKOS_DEFAULTED_FUNCTION
DefaultIndexableGetter() = default;
template <typename Geometry>
KOKKOS_FUNCTION auto const &operator()(Geometry const &geometry) const
{
return geometry;
}
template <typename Geometry,
typename Enable = std::enable_if_t<
!Details::is_pair_value_index_v<std::decay_t<Geometry>>>>
KOKKOS_FUNCTION auto operator()(Geometry &&geometry) const
{
return geometry;
}
template <typename Geometry, typename Index>
KOKKOS_FUNCTION Geometry const &
operator()(PairValueIndex<Geometry, Index> const &pair) const
{
return pair.value;
}
template <typename Geometry, typename Index>
KOKKOS_FUNCTION Geometry
operator()(PairValueIndex<Geometry, Index> &&pair) const
{
return pair.value;
}
};
} // namespace Experimental
namespace Details
{
template <typename Values, typename IndexableGetter>
struct Indexables
{
Values _values;
IndexableGetter _indexable_getter;
using memory_space = typename Values::memory_space;
KOKKOS_FUNCTION decltype(auto) operator()(int i) const
{
return _indexable_getter(_values(i));
}
KOKKOS_FUNCTION auto size() const { return _values.size(); }
};
#ifdef KOKKOS_ENABLE_CXX17
template <typename Values, typename IndexableGetter>
#if KOKKOS_VERSION >= 40400
KOKKOS_DEDUCTION_GUIDE
#else
KOKKOS_FUNCTION
#endif
Indexables(Values, IndexableGetter) -> Indexables<Values, IndexableGetter>;
#endif
} // namespace Details
} // namespace ArborX
#endif