16#ifndef CABANA_PARTICLELIST_HPP
17#define CABANA_PARTICLELIST_HPP
33template <
class... FieldTags>
42template <
class... FieldTags>
56 KOKKOS_FORCEINLINE_FUNCTION
63 KOKKOS_FORCEINLINE_FUNCTION
67 KOKKOS_FORCEINLINE_FUNCTION
76template <
int VectorLength,
class... FieldTags>
90 KOKKOS_FORCEINLINE_FUNCTION
98 KOKKOS_FORCEINLINE_FUNCTION
102 KOKKOS_FORCEINLINE_FUNCTION
106 KOKKOS_FORCEINLINE_FUNCTION
120template <
class FieldTag,
class... FieldTags,
class... IndexTypes>
121KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
122 sizeof...( IndexTypes ) == FieldTag::rank,
124 template member_const_reference_type<
126get( const
Particle<FieldTags...>& particle, FieldTag, IndexTypes... indices )
129 particle.tuple(), indices... );
133template <
class FieldTag,
class... FieldTags,
class... IndexTypes>
134KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
135 sizeof...( IndexTypes ) == FieldTag::rank,
136 typename Particle<FieldTags...>::tuple_type::template member_reference_type<
137 TypeIndexer<FieldTag, FieldTags...>::index>>::type
141 particle.
tuple(), indices... );
146template <
class FieldTag,
class... FieldTags,
class... IndexTypes,
148KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
149 sizeof...( IndexTypes ) == FieldTag::rank,
151 template member_const_reference_type<
152 TypeIndexer<FieldTag, FieldTags...>::index>>::type
154 IndexTypes... indices )
157 particle.soa(), particle.vectorIndex(), indices... );
161template <
class FieldTag,
class... FieldTags,
class... IndexTypes,
163KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
164 sizeof...( IndexTypes ) == FieldTag::rank,
165 typename ParticleView<VectorLength, FieldTags...>::soa_type::
166 template member_reference_type<
167 TypeIndexer<FieldTag, FieldTags...>::index>>::type
169 IndexTypes... indices )
177template <
class MemorySpace,
int VectorLength,
class... FieldTags>
195 template <std::
size_t M>
196 using slice_type =
typename aosoa_type::template member_slice_type<M>;
216 KOKKOS_INLINE_FUNCTION std::size_t
size()
const {
return _aosoa.size(); }
226 template <
class IndexType>
233 template <
class ParticleType,
class IndexType>
237 _aosoa.setTuple( p, particle.tuple() );
241 template <
class IndexType>
253 template <
class FieldTag>
258 _aosoa, FieldTag::label() );
271template <
class MemorySpace,
int VectorLength,
class... FieldTags>
274 :
public std::true_type
290template <
class MemorySpace,
int VectorLength,
class... FieldTags>
294 return ParticleList<MemorySpace, VectorLength, FieldTags...>( label );
301template <
class MemorySpace,
class... FieldTags>
308 typename MemorySpace::execution_space>::vector_length,
309 FieldTags...>( label );
Array-of-Struct-of-Arrays particle data structure.
Particle field types and common field examples.
AoSoA tuple member types.
Struct-of-Arrays for building AoSoA.
Tuple of single particle information to build AoSoA.
Array-of-Struct-of-Arrays.
Definition Cabana_AoSoA.hpp:121
Tuple< member_types > tuple_type
Definition Cabana_AoSoA.hpp:176
static constexpr int vector_length
Definition Cabana_AoSoA.hpp:152
static KOKKOS_FORCEINLINE_FUNCTION constexpr std::size_t a(const std::size_t i)
Given a tuple index get the AoSoA array index.
Definition Cabana_Index.hpp:77
static KOKKOS_FORCEINLINE_FUNCTION constexpr std::size_t s(const std::size_t i)
Given a tuple index get the AoSoA struct index.
Definition Cabana_Index.hpp:62
List of particle fields stored in AoSoA.
Definition Cabana_ParticleList.hpp:179
ParticleList(const std::string &label)
Default constructor.
Definition Cabana_ParticleList.hpp:204
Particle< FieldTags... > particle_type
Single particle type.
Definition Cabana_ParticleList.hpp:198
typename aosoa_type::template member_slice_type< M > slice_type
Single field slice type.
Definition Cabana_ParticleList.hpp:196
aosoa_type _aosoa
Definition Cabana_ParticleList.hpp:263
ParticleList(const aosoa_type &aosoa)
Constructor from existing AoSoA.
Definition Cabana_ParticleList.hpp:210
KOKKOS_INLINE_FUNCTION const aosoa_type & aosoa() const
Get the AoSoA (const).
Definition Cabana_ParticleList.hpp:223
const std::string & label() const
Definition Cabana_ParticleList.hpp:250
KOKKOS_INLINE_FUNCTION auto getParticle(IndexType p) const
Get a single particle.
Definition Cabana_ParticleList.hpp:227
aosoa_type & aosoa()
Definition Cabana_ParticleList.hpp:221
KOKKOS_INLINE_FUNCTION auto getParticleView(IndexType p) const
Set a single particle with the struct+array indexing.
Definition Cabana_ParticleList.hpp:242
void resize(const std::size_t n)
Update the number of particles in the list.
Definition Cabana_ParticleList.hpp:218
ParticleTraits< FieldTags... > traits
AoSoA member field types.
Definition Cabana_ParticleList.hpp:184
typename aosoa_type::tuple_type tuple_type
Particle tuple type.
Definition Cabana_ParticleList.hpp:190
ParticleView< aosoa_type::vector_length, FieldTags... > particle_view_type
Single SoA type.
Definition Cabana_ParticleList.hpp:200
KOKKOS_INLINE_FUNCTION void setParticle(ParticleType particle, IndexType p) const
Set a single particle.
Definition Cabana_ParticleList.hpp:234
MemorySpace memory_space
Kokkos memory space.
Definition Cabana_ParticleList.hpp:182
typename traits::member_types member_types
AoSoA member types.
Definition Cabana_ParticleList.hpp:186
slice_type< TypeIndexer< FieldTag, FieldTags... >::index > slice(FieldTag) const
Get a slice of a given field.
Definition Cabana_ParticleList.hpp:255
Cabana::AoSoA< member_types, memory_space, VectorLength > aosoa_type
AoSoA type.
Definition Cabana_ParticleList.hpp:188
KOKKOS_INLINE_FUNCTION std::size_t size() const
Get the number of particles in the list.
Definition Cabana_ParticleList.hpp:216
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
auto createParticleList(const std::string &label, ParticleTraits< FieldTags... >)
ParticleList creation function.
Definition Cabana_ParticleList.hpp:291
AoSoA_t::template member_slice_type< M > slice(const AoSoA_t &aosoa, const std::string &slice_label="")
Create a slice from an AoSoA.
Definition Cabana_AoSoA.hpp:77
KOKKOS_FORCEINLINE_FUNCTION std::enable_if< is_parameter_pack< ParameterPack_t >::value, typenameParameterPack_t::templatevalue_type< N > & >::type get(ParameterPack_t &pp)
Get an element from a parameter pack.
Definition Cabana_ParameterPack.hpp:129
General sequence of types for SoA and AoSoA member data.
Definition Cabana_MemberTypes.hpp:28
Extract AoSoA particle fields for ParticleList.
Definition Cabana_ParticleList.hpp:35
Cabana::MemberTypes< typename FieldTags::data_type... > member_types
AoSoA particle fields.
Definition Cabana_ParticleList.hpp:37
Single SoA particle view. Wraps a view of the SoA the particle resides in.
Definition Cabana_ParticleList.hpp:78
KOKKOS_FORCEINLINE_FUNCTION const soa_type & soa() const
Get the underlying SoA (const).
Definition Cabana_ParticleList.hpp:103
int _vector_index
Definition Cabana_ParticleList.hpp:113
ParticleTraits< FieldTags... > traits
Particle AoSoA member types.
Definition Cabana_ParticleList.hpp:80
KOKKOS_FORCEINLINE_FUNCTION int vectorIndex() const
Get the vector index of the particle in the SoA.
Definition Cabana_ParticleList.hpp:107
KOKKOS_FORCEINLINE_FUNCTION ParticleView(soa_type &soa, const int vector_index)
Tuple wrapper constructor.
Definition Cabana_ParticleList.hpp:91
static constexpr int vector_length
Definition Cabana_ParticleList.hpp:84
Cabana::SoA< typename traits::member_types, VectorLength > soa_type
Particle SoA type.
Definition Cabana_ParticleList.hpp:82
KOKKOS_FORCEINLINE_FUNCTION soa_type & soa()
Definition Cabana_ParticleList.hpp:99
ParticleView()=default
Default constructor.
soa_type & _soa
Definition Cabana_ParticleList.hpp:110
Single particle copy. Wraps a tuple copy of a particle.
Definition Cabana_ParticleList.hpp:44
KOKKOS_FORCEINLINE_FUNCTION const tuple_type & tuple() const
Get the underlying tuple (const).
Definition Cabana_ParticleList.hpp:68
KOKKOS_FORCEINLINE_FUNCTION Particle(const tuple_type &tuple)
Tuple wrapper constructor.
Definition Cabana_ParticleList.hpp:57
static constexpr int vector_length
Definition Cabana_ParticleList.hpp:50
Particle()=default
Default constructor.
Cabana::Tuple< typename traits::member_types > tuple_type
Particle tuple type.
Definition Cabana_ParticleList.hpp:48
tuple_type _tuple
Definition Cabana_ParticleList.hpp:71
ParticleTraits< FieldTags... > traits
Particle AoSoA member types.
Definition Cabana_ParticleList.hpp:46
KOKKOS_FORCEINLINE_FUNCTION tuple_type & tuple()
Definition Cabana_ParticleList.hpp:64
Definition Cabana_SoA.hpp:32
Definition Cabana_Tuple.hpp:32
Get the index of a field type within a particle type list.
Definition Cabana_Fields.hpp:122
Definition Cabana_ParticleList.hpp:268
ParticleList static type checker.
Definition Cabana_ParticleList.hpp:282