IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::ParticleAttrib< T, Properties > Class Template Reference
+ Inheritance diagram for ippl::ParticleAttrib< T, Properties >:
+ Collaboration diagram for ippl::ParticleAttrib< T, Properties >:

Public Types

typedef T value_type
 
using Base = typename detail::ParticleAttribBase<>::with_properties< Properties... >
 
using hash_type = typename Base::hash_type
 
using view_type = typename detail::ViewType< T, 1, Properties... >::view_type
 
using host_mirror_type = typename view_type::host_mirror_type
 
using memory_space = typename view_type::memory_space
 
using execution_space = typename view_type::execution_space
 
using size_type = detail::size_type
 

Public Member Functions

void create (size_type, bool non_destructive=false) override
 
void alloc (size_type) override
 
void destroy (const hash_type &deleteIndex, const hash_type &keepIndex, size_type invalidCount) override
 
void pack (const hash_type &) override
 
void unpack (size_type) override
 
void serialize (detail::Archive< memory_space > &ar, size_type nsends) override
 
void deserialize (detail::Archive< memory_space > &ar, size_type nrecvs) override
 
size_type size () const override
 
size_type packedSize (const size_type count) const override
 
void resize (size_type n)
 
void realloc (size_type n)
 Reallocate the underlying view with a new size.
 
void print ()
 
KOKKOS_INLINE_FUNCTION T & operator() (const size_t i) const
 
view_type & getView ()
 
const view_type & getView () const
 
host_mirror_type getHostMirror () const
 
void set_name (const std::string &name_) override
 
std::string get_name () const override
 
ParticleAttrib< T, Properties... > & operator= (T x)
 
template<typename E , size_t N>
ParticleAttrib< T, Properties... > & operator= (detail::Expression< E, N > const &expr)
 
template<typename Field , typename P2 , typename policy_type >
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.
 
template<typename Field , typename P2 >
void gather (Field &f, const ParticleAttrib< Vector< P2, Field::dim >, Properties... > &pp, const bool addToAttribute=false)
 Gather field data into the particle attribute.
 
sum ()
 
max ()
 
min ()
 
prod ()
 
void applyPermutation (const hash_type &permutation) override
 Sort the attribute according to a permutation.
 
void internalCopy (const hash_type &indices) override
 Copy and create values of given indices.
 
template<typename Field , class PT , typename policy_type >
void scatter (Field &f, const ParticleAttrib< Vector< PT, Field::dim >, Properties... > &pp, policy_type iteration_policy, hash_type hash_array) const
 
- Public Member Functions inherited from ippl::detail::Expression< ParticleAttrib< T, Properties... >, sizeof(detail::ViewType< T, 1, Properties... >::view_type)>
KOKKOS_INLINE_FUNCTION auto operator[] (size_t i) const
 

Static Public Attributes

static constexpr unsigned dim = 1
 
- Static Public Attributes inherited from ippl::detail::Expression< ParticleAttrib< T, Properties... >, sizeof(detail::ViewType< T, 1, Properties... >::view_type)>
static constexpr unsigned dim
 

Member Function Documentation

◆ applyPermutation()

template<typename T , class... Properties>
void ippl::ParticleAttrib< T, Properties >::applyPermutation ( const hash_type &  permutation)
override

Sort the attribute according to a permutation.

This function sorts the attribute according to a given permutation such that afterward attr(permutation(i)) = attr(i).

Note
this cannot be done inplace and is not very cache efficient
Parameters
permutationThe permutation to apply

◆ destroy()

template<typename T , class... Properties>
void ippl::ParticleAttrib< T, Properties >::destroy ( const hash_type &  deleteIndex,
const hash_type &  keepIndex,
size_type  invalidCount 
)
override

Particle deletion function. Partition the particles into a valid region and an invalid region.

Parameters
deleteIndexList of indices of invalid particles in the valid region
keepIndexList of indices of valid particles in the invalid region
invalidCountNumber of invalid particles in the valid region

◆ gather()

template<typename T , class... Properties>
template<typename Field , typename P2 >
void ippl::ParticleAttrib< T, Properties >::gather ( Field f,
const ParticleAttrib< Vector< P2, Field::dim >, Properties... > &  pp,
const bool  addToAttribute = false 
)

Gather field data into the particle attribute.

This function gathers data from the given field into the particle attribute by iterating over all particles. Depending on the parameter addToAttribute, the gathered field value is either added to the existing attribute value (using "+=") or used to overwrite the attribute value.

Note
This behavior exists to give the OPAL-X field solver the ablity to gather field data per "energy bin".
Template Parameters
FieldThe type of the field.
P2The particle type for the position attribute.
Parameters
fThe field from which data is gathered.
ppThe ParticleAttrib representing particle positions.
addToAttributeIf true, the gathered value is added to the current attribute value; otherwise, the attribute value is overwritten.

◆ internalCopy()

template<typename T , class... Properties>
void ippl::ParticleAttrib< T, Properties >::internalCopy ( const hash_type &  indices)
override

Copy and create values of given indices.

This functions creates new particles with the values copied from the given indices. The values will be at the highest new indices.

Parameters
indicesThe indices to copy.

◆ operator=() [1/2]

template<typename T , class... Properties>
template<typename E , size_t N>
ParticleAttrib< T, Properties... > & ippl::ParticleAttrib< T, Properties >::operator= ( detail::Expression< E, N > const &  expr)

Assign an arbitrary particle attribute expression

Template Parameters
Eexpression type
Nsize of the expression, this is necessary for running on the device since otherwise it does not allocate enough memory
Parameters
expris the expression

◆ operator=() [2/2]

template<typename T , class... Properties>
ParticleAttrib< T, Properties... > & ippl::ParticleAttrib< T, Properties >::operator= ( x)

Assign the same value to the whole attribute.

◆ realloc()

template<typename T , class... Properties>
void ippl::ParticleAttrib< T, Properties >::realloc ( size_type  n)
inline

Reallocate the underlying view with a new size.

This function reallocates the device view to a new size. Existing data is discarded and should not be relied upon after this call. Note that this function does not apply overallocation. For use from outside, call ParticleAttrib::alloc(size_type) instead.

Parameters
nThe new size to allocate in the internal view.

◆ scatter()

template<typename T , class... Properties>
template<typename Field , typename P2 , typename policy_type >
void ippl::ParticleAttrib< T, Properties >::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.

This function scatters data from this attribute onto the given field, using the given position attribute. The function can be used together with a custom iteration policy to iterate over a specified range and, optionally, an ippl::hash_type array to remap iteration indices.

When a non-empty hash_array is provided, the function:

  • Checks that the iteration policy's range does not exceed the size of hash_array.
  • Maps the current index to the appropriate index using the hash_array.
  • Careful: access pattern optimization might be lost when using hash_array.
Note
This custom iteration functionality is needed to support energy binning in the field solver of OPAL-X, allowing only particles within a specific bin to be scattered.
Template Parameters
FieldThe type of the field.
P2The type for the position attribute.
policy_typeThe type of the Kokkos iteration policy when using hash_array.
Parameters
fThe field onto which the particle data is scattered.
ppThe ParticleAttrib representing particle positions.
iteration_policyA custom Kokkos::range_policy defining the iteration range.
hash_arrayAn optional ippl::hash_type array for index mapping. If empty, no map is used.

The documentation for this class was generated from the following files: