51#ifndef IPPL_PARTICLE_BASE_H
52#define IPPL_PARTICLE_BASE_H
58#include "Types/IpplTypes.h"
60#include "Utility/TypeUtils.h"
62#include "Particle/ParticleLayout.h"
86 template <
class PLayout,
typename... IDProperties>
88 constexpr static bool EnableIDs =
sizeof...(IDProperties) > 0;
91 using vector_type =
typename PLayout::vector_type;
92 using index_type =
typename PLayout::index_type;
93 using particle_position_type =
typename PLayout::particle_position_type;
96 using Layout_t = PLayout;
98 template <
typename... Properties>
101 template <
typename MemorySpace>
102 using container_type = std::vector<attribute_type<MemorySpace>*>;
104 using attribute_container_type =
105 typename detail::ContainerForAllSpaces<container_type>::type;
107 using bc_container_type =
typename PLayout::bc_container_type;
109 using hash_container_type =
typename detail::ContainerForAllSpaces<detail::hash_type>::type;
111 using size_type = detail::size_type;
115 particle_position_type
R;
157 void setLocalNum(size_type size) { localNum_m = size; }
178 void setParticleBC(
const bc_container_type& bcs) { layout_m->setParticleBC(bcs); }
190 template <
typename MemorySpace>
198 template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
200 return attributes_m.template get<MemorySpace>()[i];
210 template <
typename MemorySpace =
void,
typename Functor>
212 if constexpr (std::is_void_v<MemorySpace>) {
213 attributes_m.forAll(f);
215 for (
auto& attribute : attributes_m.template get<MemorySpace>()) {
222 template <
typename MemorySpace =
void,
typename Functor>
224 if constexpr (std::is_void_v<MemorySpace>) {
225 attributes_m.forAll([&]<
typename Attributes>(Attributes& atts) {
226 for (
auto& attribute : atts) {
231 for (
auto& attribute : attributes_m.template
get<MemorySpace>()) {
242 detail::runForAllSpaces([&]<
typename MemorySpace>() {
243 total += attributes_m.template get<MemorySpace>().size();
257 void create(size_type nLocal,
bool non_destructive =
false);
266 void alloc(size_type nLocal);
289 template <
typename... Properties>
290 void destroy(
const Kokkos::View<bool*, Properties...>& invalid,
const size_type destroyNum);
293 void update() { layout_m->update(*
this); }
302 template <
typename... Properties>
303 void internalDestroy(
const Kokkos::View<bool*, Properties...>& invalid,
304 const size_type destroyNum);
315 template <
typename HashType>
316 void sendToRank(
int rank,
int tag, std::vector<MPI_Request>& requests,
317 const HashType& hash);
332 template <
typename Archive>
333 void serialize(Archive& ar, size_type nsends);
340 template <
typename Archive>
349 template <
typename MemorySpace>
357 void pack(
const hash_container_type& hash);
363 void unpack(size_type nrecvs);
371 size_type localNum_m;
374 size_type totalNum_m;
377 attribute_container_type attributes_m;
383 index_type numNodes_m;
386 hash_container_type deleteIndex_m;
387 hash_container_type keepIndex_m;
391#include "Particle/ParticleBase.hpp"
Definition ParticleBase.h:73
Definition ParticleBase.h:87
void setParticleBC(const bc_container_type &bcs)
Definition ParticleBase.h:178
void addAttribute(detail::ParticleAttribBase< MemorySpace > &pa)
Definition ParticleBase.hpp:77
void pack(const hash_container_type &hash)
Definition ParticleBase.hpp:351
const Layout_t & getLayout() const
Definition ParticleBase.h:172
void serialize(Archive &ar, size_type nsends)
Definition ParticleBase.hpp:324
void setParticleBC(BC bc)
Definition ParticleBase.h:184
size_type getTotalNum() const
Definition ParticleBase.h:162
void globalCreate(size_type nTotal)
Definition ParticleBase.hpp:152
void forAllAttributes(Functor &&f) const
Definition ParticleBase.h:211
void initialize(Layout_t &layout)
Definition ParticleBase.hpp:83
Layout_t & getLayout()
Definition ParticleBase.h:167
void unpack(size_type nrecvs)
Definition ParticleBase.hpp:361
void create(size_type nLocal, bool non_destructive=false)
Definition ParticleBase.hpp:91
void destroy(const Kokkos::View< bool *, Properties... > &invalid, const size_type destroyNum)
Definition ParticleBase.hpp:170
size_type packedSize(const size_type count) const
unsigned getAttributeNum() const
Definition ParticleBase.h:240
void recvFromRank(int rank, int tag, size_type nRecvs)
Definition ParticleBase.hpp:307
void alloc(size_type nLocal)
Definition ParticleBase.hpp:126
void createWithID(index_type id)
Definition ParticleBase.hpp:135
attribute_type< MemorySpace > * getAttribute(size_t i)
Definition ParticleBase.h:199
void sendToRank(int rank, int tag, std::vector< MPI_Request > &requests, const HashType &hash)
Definition ParticleBase.hpp:283
ParticleBase()
Definition ParticleBase.hpp:55
particle_position_type R
view of particle positions
Definition ParticleBase.h:115
particle_index_type ID
view of particle IDs
Definition ParticleBase.h:118
void deserialize(Archive &ar, size_type nrecvs)
Definition ParticleBase.hpp:333
size_type getLocalNum() const
Definition ParticleBase.h:155
Definition ParticleAttribBase.h:30
KOKKOS_INLINE_FUNCTION auto & get(Tuple< Ts... > &t)
Accessor function to get an element mutable reference at a specific index from a Tuple.
Definition Tuple.h:314