Line data Source code
1 : //
2 : // Class ParticleAttribBase
3 : // Base class for all particle attribute classes.
4 : //
5 : // This class is used as the generic base class for all (templated) classes
6 : // which represent a single attribute of a Particle. An attribute class
7 : // contains a Kokkos::View of data for N particles, and methods to operate with
8 : // this data.
9 : //
10 : // This base class provides virtual methods used to create and destroy
11 : // elements of the attribute array.
12 : //
13 :
14 : #ifndef IPPL_PARTICLE_ATTRIB_BASE_H
15 : #define IPPL_PARTICLE_ATTRIB_BASE_H
16 :
17 : #include "Types/IpplTypes.h"
18 : #include "Types/ViewTypes.h"
19 :
20 : #include "Communicate/Archive.h"
21 :
22 : namespace ippl {
23 : namespace detail {
24 : template <typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
25 : class ParticleAttribBase {
26 : template <class... Properties>
27 : struct WithMemSpace {
28 : using memory_space = typename Kokkos::View<char*, Properties...>::memory_space;
29 : using type = ParticleAttribBase<memory_space>;
30 : };
31 :
32 : public:
33 : using hash_type = ippl::detail::hash_type<MemorySpace>;
34 : using memory_space = MemorySpace;
35 : using execution_space = typename memory_space::execution_space;
36 :
37 : template <typename... Properties>
38 : using with_properties = typename WithMemSpace<Properties...>::type;
39 :
40 : virtual void create(size_type) = 0;
41 :
42 : virtual void destroy(const hash_type&, const hash_type&, size_type) = 0;
43 : virtual size_type packedSize(const size_type) const = 0;
44 :
45 : virtual void pack(const hash_type&) = 0;
46 :
47 : virtual void unpack(size_type) = 0;
48 :
49 : virtual void serialize(Archive<memory_space>& ar, size_type nsends) = 0;
50 :
51 : virtual void deserialize(Archive<memory_space>& ar, size_type nrecvs) = 0;
52 :
53 : virtual size_type size() const = 0;
54 :
55 864 : virtual ~ParticleAttribBase() = default;
56 :
57 336 : void setParticleCount(size_type& num) { localNum_mp = # }
58 228 : size_type getParticleCount() const { return *localNum_mp; }
59 :
60 : protected:
61 : const size_type* localNum_mp;
62 : };
63 : } // namespace detail
64 : } // namespace ippl
65 :
66 : #endif
|