1 #ifndef AMREX_PARTICLEARRAY_H_
2 #define AMREX_PARTICLEARRAY_H_
3 #include <AMReX_Config.H>
11 #include <type_traits>
28 template <
template <
typename...>
class ContainerType,
29 typename ParticleType,
33 template <
typename ParticleType, DataLayout DataLayoutTag>
36 template <
typename ParticleType, DataLayout DataLayoutTag>
56 ref_wrapper& operator= (T&& a_other) { this->
get()=std::move(a_other);
return *
this; }
62 operator T& () const noexcept {
return *
_ptr; }
75 template <
template <
typename...>
class ContainerType,
76 template<
typename...>
class ParticleType,
86 return raw_type(
static_cast<ParticleType<Types...
>*>(a_container.data()));
91 a_container.resize(a_size);
94 template <
typename ValueType>
97 a_container.push_back(std::forward<ValueType>(a_value));
102 return a_container.size();
109 template <
template<
typename...>
class ParticleType,
typename... Types>
118 return value_type(*
static_cast<ParticleType<Types...
>*>(&a_ptr[a_index]));
128 template <
template <
typename...>
class ContainerType,
129 template<
typename...>
class ParticleType,
138 return get_raw_data_impl(a_container, std::make_index_sequence<
sizeof...(Types)>());
143 resize_impl(a_container, a_size, std::make_index_sequence<
sizeof...(Types)>());
146 template <
typename ValueType>
149 push_back_impl(a_container, std::forward<ValueType>(a_value),
150 std::make_index_sequence<
sizeof...(Types)>());
155 return std::get<0>(a_container).size();
160 template <std::size_t... Is>
162 std::index_sequence<Is...>)
164 return raw_type{
static_cast<Types*
>(&std::get<Is>(a_container)[0])... };
167 template <std::size_t... Is>
169 std::index_sequence<Is...>)
171 using expander =
int[];
172 (void) expander{ 0, (std::get<Is>(a_container).resize(a_size), 0)... };
175 template <
typename ValueType, std::size_t... Is>
177 std::index_sequence<Is...>)
179 using expander =
int[];
180 (void) expander{ 0, (std::get<Is>(a_container).push_back(
181 std::get<Is>(a_value)), 0)... };
188 template <
template<
typename...>
class ParticleType,
typename... Types>
196 return get_impl(a_tuple, a_index, std::make_index_sequence<
sizeof...(Types)>());
201 template <std::size_t... Is>
204 std::index_sequence<Is...>)
213 template <
template <
typename ValueType>
class ContainerType,
214 typename ParticleType,
229 template <
typename ValueType>
232 policy_type::push_back(
m_data, std::forward<ValueType>(val));
253 template <
typename ParticleType, DataLayout DataLayoutTag>
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
Definition: AMReX_Tuple.H:93
Definition: AMReX_ParticleArray.H:43
AMREX_GPU_HOST_DEVICE T & get() const noexcept
Definition: AMReX_ParticleArray.H:65
AMREX_GPU_HOST_DEVICE ref_wrapper & operator=(T &&a_other)
Definition: AMReX_ParticleArray.H:56
ref_wrapper(ref_wrapper &&) noexcept=default
ref_wrapper(const ref_wrapper &) noexcept=default
T type
Definition: AMReX_ParticleArray.H:45
T * _ptr
Definition: AMReX_ParticleArray.H:68
AMREX_GPU_HOST_DEVICE ref_wrapper(T &ref) noexcept
Definition: AMReX_ParticleArray.H:48
AMREX_GPU_HOST_DEVICE Long size(T const &b) noexcept
integer version
Definition: AMReX_GpuRange.H:26
constexpr AMREX_GPU_HOST_DEVICE GpuTupleElement< I, GpuTuple< Ts... > >::type & get_impl(detail::gpu_tuple_element< I, typename GpuTupleElement< I, GpuTuple< Ts... > >::type > &te) noexcept
Definition: AMReX_Tuple.H:147
Definition: AMReX_Amr.cpp:49
constexpr AMREX_GPU_HOST_DEVICE GpuTupleElement< I, GpuTuple< Ts... > >::type & get(GpuTuple< Ts... > &tup) noexcept
Definition: AMReX_Tuple.H:179
DataLayout
Definition: AMReX_ParticleArray.H:20
ParticleType< Types... > * raw_type
Definition: AMReX_ParticleArray.H:112
ParticleType< Types... > & value_type
Definition: AMReX_ParticleArray.H:113
static constexpr AMREX_GPU_HOST_DEVICE value_type get(raw_type a_ptr, std::size_t a_index)
Definition: AMReX_ParticleArray.H:116
static constexpr AMREX_GPU_HOST_DEVICE value_type get(raw_type const &a_tuple, std::size_t a_index)
Definition: AMReX_ParticleArray.H:194
static constexpr AMREX_GPU_HOST_DEVICE auto get_impl(raw_type const &a_tuple, std::size_t a_index, std::index_sequence< Is... >)
Definition: AMReX_ParticleArray.H:203
ParticleType< ref_wrapper< Types >... > value_type
Definition: AMReX_ParticleArray.H:191
Definition: AMReX_ParticleArray.H:34
static constexpr void resize(container_type &a_container, std::size_t a_size)
Definition: AMReX_ParticleArray.H:89
static constexpr raw_type get_raw_data(container_type &a_container)
Definition: AMReX_ParticleArray.H:84
static constexpr void push_back(container_type &a_container, ValueType &&a_value)
Definition: AMReX_ParticleArray.H:95
ContainerType< ParticleType< Types... > > container_type
Definition: AMReX_ParticleArray.H:80
ParticleType< Types... > * raw_type
Definition: AMReX_ParticleArray.H:81
static constexpr std::size_t size(container_type &a_container)
Definition: AMReX_ParticleArray.H:100
ParticleType< Types... > & value_type
Definition: AMReX_ParticleArray.H:82
static constexpr void push_back(container_type &a_container, ValueType &&a_value)
Definition: AMReX_ParticleArray.H:147
static constexpr raw_type get_raw_data(container_type &a_container)
Definition: AMReX_ParticleArray.H:136
static constexpr auto get_raw_data_impl(container_type &a_container, std::index_sequence< Is... >)
Definition: AMReX_ParticleArray.H:161
ParticleType< ref_wrapper< Types >... > value_type
Definition: AMReX_ParticleArray.H:134
static constexpr std::size_t size(container_type &a_container)
Definition: AMReX_ParticleArray.H:153
std::tuple< ContainerType< Types >... > container_type
Definition: AMReX_ParticleArray.H:132
static constexpr void resize(container_type &a_container, std::size_t a_size)
Definition: AMReX_ParticleArray.H:141
static constexpr void resize_impl(container_type &a_container, std::size_t a_size, std::index_sequence< Is... >)
Definition: AMReX_ParticleArray.H:168
static constexpr void push_back_impl(container_type &a_container, ValueType const &a_value, std::index_sequence< Is... >)
Definition: AMReX_ParticleArray.H:176
Definition: AMReX_ParticleArray.H:31
Definition: AMReX_ParticleArray.H:255
typename policy_type::raw_type raw_type
Definition: AMReX_ParticleArray.H:262
std::size_t m_size
Definition: AMReX_ParticleArray.H:277
AMREX_GPU_HOST_DEVICE std::size_t size() const
Definition: AMReX_ParticleArray.H:274
AMREX_GPU_HOST_DEVICE value_type operator[](std::size_t a_index) const
Definition: AMReX_ParticleArray.H:271
typename policy_type::value_type value_type
Definition: AMReX_ParticleArray.H:261
raw_type m_data
Definition: AMReX_ParticleArray.H:278
ParticleArrayAccessor(std::size_t a_size, raw_type a_data)
Definition: AMReX_ParticleArray.H:266
static constexpr auto data_layout
Definition: AMReX_ParticleArray.H:264
Definition: AMReX_ParticleArray.H:217
void resize(size_t a_size)
Definition: AMReX_ParticleArray.H:237
container_type m_data
Definition: AMReX_ParticleArray.H:246
std::size_t size()
Definition: AMReX_ParticleArray.H:235
typename policy_type::container_type container_type
Definition: AMReX_ParticleArray.H:221
static constexpr auto data_layout
Definition: AMReX_ParticleArray.H:223
accessor_type get_particle_data()
Definition: AMReX_ParticleArray.H:239
ParticleArray(size_t a_size)
Definition: AMReX_ParticleArray.H:227
ParticleArray()
Definition: AMReX_ParticleArray.H:225
ParticleArrayAccessor< ParticleType, DataLayoutTag > accessor_type
Definition: AMReX_ParticleArray.H:219
typename policy_type::value_type value_type
Definition: AMReX_ParticleArray.H:220
void push_back(ValueType &&val)
Definition: AMReX_ParticleArray.H:230