IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::ParticleBase< PLayout, IDProperties > Class Template Reference

#include <ParticleBase.h>

+ Inheritance diagram for ippl::ParticleBase< PLayout, IDProperties >:
+ Collaboration diagram for ippl::ParticleBase< PLayout, IDProperties >:

Public Types

using vector_type = typename PLayout::vector_type
 
using index_type = typename PLayout::index_type
 
using particle_position_type = typename PLayout::particle_position_type
 
using particle_index_type = ParticleAttrib< index_type, IDProperties... >
 
using Layout_t = PLayout
 
template<typename... Properties>
using attribute_type = typename detail::ParticleAttribBase< Properties... >
 
template<typename MemorySpace >
using container_type = std::vector< attribute_type< MemorySpace > * >
 
using attribute_container_type = typename detail::ContainerForAllSpaces< container_type >::type
 
using bc_container_type = typename PLayout::bc_container_type
 
using hash_container_type = typename detail::ContainerForAllSpaces< detail::hash_type >::type
 
using size_type = detail::size_type
 

Public Member Functions

 ParticleBase ()
 
 ParticleBase (Layout_t &layout)
 
void initialize (Layout_t &layout)
 
size_type getLocalNum () const
 
void setLocalNum (size_type size)
 
size_type getTotalNum () const
 
Layout_t & getLayout ()
 
const Layout_t & getLayout () const
 
void setParticleBC (const bc_container_type &bcs)
 
void setParticleBC (BC bc)
 
template<typename MemorySpace >
void addAttribute (detail::ParticleAttribBase< MemorySpace > &pa)
 
template<typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
attribute_type< MemorySpace > * getAttribute (size_t i)
 
template<typename MemorySpace = void, typename Functor >
void forAllAttributes (Functor &&f) const
 
template<typename MemorySpace = void, typename Functor >
void forAllAttributes (Functor &&f)
 
unsigned getAttributeNum () const
 
void create (size_type nLocal, bool non_destructive=false)
 
void alloc (size_type nLocal)
 
void createWithID (index_type id)
 
void globalCreate (size_type nTotal)
 
template<typename... Properties>
void destroy (const Kokkos::View< bool *, Properties... > &invalid, const size_type destroyNum)
 
void update ()
 
template<typename... Properties>
void internalDestroy (const Kokkos::View< bool *, Properties... > &invalid, const size_type destroyNum)
 
template<typename HashType >
void sendToRank (int rank, int tag, std::vector< MPI_Request > &requests, const HashType &hash)
 
void recvFromRank (int rank, int tag, size_type nRecvs)
 
template<typename Archive >
void serialize (Archive &ar, size_type nsends)
 
template<typename Archive >
void deserialize (Archive &ar, size_type nrecvs)
 
template<typename MemorySpace >
size_type packedSize (const size_type count) const
 
template<typename MemorySpace >
detail::size_type packedSize (const size_type count) const
 

Public Attributes

particle_position_type R
 view of particle positions
 
particle_index_type ID
 view of particle IDs
 

Protected Member Functions

void pack (const hash_container_type &hash)
 
void unpack (size_type nrecvs)
 

Detailed Description

template<class PLayout, typename... IDProperties>
class ippl::ParticleBase< PLayout, IDProperties >
Template Parameters
PLayoutthe particle layout implementing an algorithm to distribute the particles among MPI ranks
IDPropertiesthe view properties for particle IDs (if any of the provided types is ippl::DisableParticleIDs, then particle IDs will be disabled for the bunch)

Constructor & Destructor Documentation

◆ ParticleBase() [1/2]

template<class PLayout , typename... IP>
ippl::ParticleBase< PLayout, IP >::ParticleBase ( )

If this constructor is used, the user must call 'initialize' with a layout object in order to use this.

◆ ParticleBase() [2/2]

template<class PLayout , typename... IP>
ippl::ParticleBase< PLayout, IP >::ParticleBase ( Layout_t &  layout)

Ctor called when layout is provided with std::shared_ptr. It calls the default ctor which then calls the private ctor. The layout instance is moved to this class, hence, the argument is null afterwards, i.e., layout == nullptr.

Parameters
layoutto be moved.

Member Function Documentation

◆ addAttribute()

template<class PLayout , typename... IP>
template<typename MemorySpace >
void ippl::ParticleBase< PLayout, IP >::addAttribute ( detail::ParticleAttribBase< MemorySpace > &  pa)

Add particle attribute

Parameters
paattribute to be added to ParticleBase

◆ alloc()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::alloc ( size_type  nLocal)

Pre-allocate capacity for nLocal particles on every attribute, without touching the logical particle count or assigning IDs. Caller is responsible for filling the entries. Overallocation is additionally applied.

Parameters
nLocalcapacity (in particles) to allocate per attribute.

◆ create()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::create ( size_type  nLocal,
bool  non_destructive = false 
)

Create nLocal rank local particles. This is a collective call, i.e. all MPI ranks must call this.

Parameters
nLocalnumber of local particles to be created (delta, not total).
non_destructiveif true, preserve existing particle data when the underlying views must grow (uses Kokkos::resize). Default false keeps the destructive-on-grow behavior.

◆ createWithID()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::createWithID ( index_type  id)

Create a new particle with a given ID. This is a collective call. If a process passes a negative number, it does not create a particle.

Parameters
idparticle identity number

◆ deserialize()

template<class PLayout , typename... IP>
template<typename Archive >
void ippl::ParticleBase< PLayout, IP >::deserialize ( Archive &  ar,
size_type  nrecvs 
)

Deserialize to do MPI calls.

Parameters
ararchive
nrecvsnumber of particles to deserialize

◆ destroy()

template<class PLayout , typename... IP>
template<typename... Properties>
void ippl::ParticleBase< PLayout, IP >::destroy ( const Kokkos::View< bool *, Properties... > &  invalid,
const size_type  destroyNum 
)

Particle deletion Function. Partition the particles into a valid region and an invalid region, effectively deleting the invalid particles. This is a collective call.

Parameters
invalidView marking which indices are invalid
destroyNumTotal number of invalid particles

◆ forAllAttributes()

template<class PLayout , typename... IDProperties>
template<typename MemorySpace = void, typename Functor >
void ippl::ParticleBase< PLayout, IDProperties >::forAllAttributes ( Functor &&  f) const
inline

Calls a given function for all attributes in the bunch

Template Parameters
MemorySpacethe memory space of the attributes to visit (void to visit all of them)
Functorthe functor type
Parameters
fa functor taking a single ParticleAttrib<MemorySpace>

◆ getAttribute()

template<class PLayout , typename... IDProperties>
template<typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
attribute_type< MemorySpace > * ippl::ParticleBase< PLayout, IDProperties >::getAttribute ( size_t  i)
inline

Get particle attribute

Parameters
iattribute number in container
Returns
a pointer to the attribute

◆ getAttributeNum()

template<class PLayout , typename... IDProperties>
unsigned ippl::ParticleBase< PLayout, IDProperties >::getAttributeNum ( ) const
inline
Returns
the number of attributes

◆ getLayout() [1/2]

template<class PLayout , typename... IDProperties>
Layout_t & ippl::ParticleBase< PLayout, IDProperties >::getLayout ( )
inline
Returns
particle layout

◆ getLayout() [2/2]

template<class PLayout , typename... IDProperties>
const Layout_t & ippl::ParticleBase< PLayout, IDProperties >::getLayout ( ) const
inline
Returns
particle layout

◆ getLocalNum()

template<class PLayout , typename... IDProperties>
size_type ippl::ParticleBase< PLayout, IDProperties >::getLocalNum ( ) const
inline
Returns
processor local number of particles

◆ getTotalNum()

template<class PLayout , typename... IDProperties>
size_type ippl::ParticleBase< PLayout, IDProperties >::getTotalNum ( ) const
inline
Returns
total number of particles (across all processes)

◆ globalCreate()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::globalCreate ( size_type  nTotal)

Create nTotal particles globally, equally distributed among all processors. This is a collective call.

Parameters
nTotalnumber of total particles to be created

◆ initialize()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::initialize ( Layout_t &  layout)

Initialize the particle layout. Needs to be called when the ParticleBase instance is constructed with the default ctor.

◆ pack()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::pack ( const hash_container_type &  hash)
protected

Fill attributes of buffer.

Parameters
hashfunction to access index.

◆ packedSize()

template<class PLayout , typename... IDProperties>
template<typename MemorySpace >
size_type ippl::ParticleBase< PLayout, IDProperties >::packedSize ( const size_type  count) const

Determine the total space necessary to store a certain number of particles

Template Parameters
MemorySpaceonly consider attributes stored in this memory space
Parameters
countparticle number
Returns
Total size of a buffer packed with the given number of particles

◆ recvFromRank()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::recvFromRank ( int  rank,
int  tag,
size_type  nRecvs 
)

Receives particles from another rank

Parameters
rankthe source rank
tagthe MPI tag
nRecvsthe number of particles to receive

◆ sendToRank()

template<class PLayout , typename... IP>
template<typename HashType >
void ippl::ParticleBase< PLayout, IP >::sendToRank ( int  rank,
int  tag,
std::vector< MPI_Request > &  requests,
const HashType &  hash 
)

Sends particles to another rank

Template Parameters
HashTypethe hash view type
Parameters
rankthe destination rank
tagthe MPI tag
requestsdestination vector in which to store the MPI requests for polling purposes
hasha hash view indicating which particles need to be sent to which rank

◆ serialize()

template<class PLayout , typename... IP>
template<typename Archive >
void ippl::ParticleBase< PLayout, IP >::serialize ( Archive &  ar,
size_type  nsends 
)

Serialize to do MPI calls.

Parameters
ararchive
nsendsnumber of particles to serialize

◆ setParticleBC() [1/2]

template<class PLayout , typename... IDProperties>
void ippl::ParticleBase< PLayout, IDProperties >::setParticleBC ( BC  bc)
inline

Set all boundary conditions to this BC

Parameters
bcthe boundary conditions

◆ setParticleBC() [2/2]

template<class PLayout , typename... IDProperties>
void ippl::ParticleBase< PLayout, IDProperties >::setParticleBC ( const bc_container_type &  bcs)
inline

Set all boundary conditions

Parameters
bcsthe boundary conditions

◆ unpack()

template<class PLayout , typename... IP>
void ippl::ParticleBase< PLayout, IP >::unpack ( size_type  nrecvs)
protected

Fill my attributes.

Parameters
nrecvsnumber of particles to unpack

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