16#ifndef IPPL_PARTICLE_ATTRIB_H
17#define IPPL_PARTICLE_ATTRIB_H
23#include "Interpolation/CIC.h"
24#include "Particle/ParticleAttribBase.h"
29 template <
typename T,
class... Properties>
32 ParticleAttrib<T, Properties...>,
33 sizeof(typename detail::ViewType<T, 1, Properties...>::view_type)> {
36 constexpr static unsigned dim = 1;
38 using Base =
typename detail::ParticleAttribBase<>::with_properties<Properties...>;
40 using hash_type =
typename Base::hash_type;
44 using host_mirror_type =
typename view_type::host_mirror_type;
46 using memory_space =
typename view_type::memory_space;
47 using execution_space =
typename view_type::execution_space;
49 using size_type = detail::size_type;
54 void create(size_type,
bool non_destructive =
false)
override;
59 void alloc(size_type)
override;
68 void destroy(
const hash_type& deleteIndex,
const hash_type& keepIndex,
69 size_type invalidCount)
override;
71 void pack(
const hash_type&)
override;
73 void unpack(size_type)
override;
85 size_type size()
const override {
return dview_m.extent(0); }
87 size_type packedSize(
const size_type count)
const override {
88 return count *
sizeof(value_type);
91 void resize(size_type n) { Kokkos::resize(dview_m, n); }
103 void realloc(size_type n) { Kokkos::realloc(dview_m, n); }
106 host_mirror_type hview = Kokkos::create_mirror_view(dview_m);
107 Kokkos::deep_copy(hview, dview_m);
108 for (size_type i = 0; i < *(this->localNum_mp); ++i) {
109 std::cout << hview(i) << std::endl;
113 KOKKOS_INLINE_FUNCTION T& operator()(
const size_t i)
const {
return dview_m(i); }
115 view_type& getView() {
return dview_m; }
117 const view_type& getView()
const {
return dview_m; }
119 host_mirror_type getHostMirror()
const {
return Kokkos::create_mirror(dview_m); }
121 void set_name(
const std::string& name_)
override {
122 size_t len = name_.size();
123 if (len >= detail::ATTRIB_NAME_MAX_LEN) {
124 len = detail::ATTRIB_NAME_MAX_LEN - 1;
126 std::memcpy(this->name_m, name_.c_str(), len);
127 this->name_m[len] =
'\0';
130 std::string get_name()
const override {
return std::string(this->name_m); }
145 template <
typename E,
size_t N>
176 template <
typename Field,
typename P2,
typename policy_type>
178 policy_type iteration_policy, hash_type hash_array = {})
const;
198 template <
typename Field,
typename P2>
200 const bool addToAttribute =
false);
235#include "Particle/ParticleAttrib.hpp"
Definition ParticleAttrib.h:33
void destroy(const hash_type &deleteIndex, const hash_type &keepIndex, size_type invalidCount) override
Definition ParticleAttrib.hpp:46
void internalCopy(const hash_type &indices) override
Copy and create values of given indices.
Definition ParticleAttrib.hpp:262
void scatter(Field &f, const ParticleAttrib< Vector< P2, Field::dim >, Properties... > &pp, policy_type iteration_policy, hash_type hash_array={}) const
Scatter particle attribute data onto a field.
void gather(Field &f, const ParticleAttrib< Vector< P2, Field::dim >, Properties... > &pp, const bool addToAttribute=false)
Gather field data into the particle attribute.
Definition ParticleAttrib.hpp:188
void realloc(size_type n)
Reallocate the underlying view with a new size.
Definition ParticleAttrib.h:103
void applyPermutation(const hash_type &permutation) override
Sort the attribute according to a permutation.
Definition ParticleAttrib.hpp:243
ParticleAttrib< T, Properties... > & operator=(T x)
Definition ParticleAttrib.hpp:98
void serialize(const Kokkos::View< T *, ViewArgs... > &view, size_type nsends)
Definition Archive.hpp:25
void deserialize(Kokkos::View< T *, ViewArgs... > &view, size_type nrecvs)
Definition Archive.hpp:76
Definition ParticleAttribBase.h:30
Definition IpplExpressions.h:26
Definition ViewTypes.h:44