IPPL (Independent Parallel Particle Layer)
IPPL
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
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)
 ~ParticleBase ()
void initialize (Layout_t &layout)
size_type getLocalNum () const
void setLocalNum (size_type size)
size_type getTotalNum () const
Layout_tgetLayout ()
const Layout_tgetLayout () 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)
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)

Private Attributes

Layout_tlayout_m
 particle layout
size_type localNum_m
 processor local number of particles
size_type totalNum_m
 total number of particles (across all processes)
attribute_container_type attributes_m
 all attributes
index_type nextID_m
 next unique particle ID
index_type numNodes_m
 number of MPI ranks
hash_container_type deleteIndex_m
 buffers for particle partitioning
hash_container_type keepIndex_m

Static Private Attributes

static constexpr bool EnableIDs = sizeof...(IDProperties) > 0

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)

Definition at line 87 of file ParticleBase.h.

Member Typedef Documentation

◆ attribute_container_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::attribute_container_type
Initial value:

Definition at line 104 of file ParticleBase.h.

◆ attribute_type

template<class PLayout, typename... IDProperties>
template<typename... Properties>
using ippl::ParticleBase< PLayout, IDProperties >::attribute_type = typename detail::ParticleAttribBase<Properties...>

Definition at line 99 of file ParticleBase.h.

◆ bc_container_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::bc_container_type = typename PLayout::bc_container_type

Definition at line 107 of file ParticleBase.h.

◆ container_type

template<class PLayout, typename... IDProperties>
template<typename MemorySpace>
using ippl::ParticleBase< PLayout, IDProperties >::container_type = std::vector<attribute_type<MemorySpace>*>

Definition at line 102 of file ParticleBase.h.

◆ hash_container_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::hash_container_type = typename detail::ContainerForAllSpaces<detail::hash_type>::type

Definition at line 109 of file ParticleBase.h.

◆ index_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::index_type = typename PLayout::index_type

Definition at line 92 of file ParticleBase.h.

◆ Layout_t

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::Layout_t = PLayout

Definition at line 96 of file ParticleBase.h.

◆ particle_index_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::particle_index_type = ParticleAttrib<index_type, IDProperties...>

Definition at line 94 of file ParticleBase.h.

◆ particle_position_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::particle_position_type = typename PLayout::particle_position_type

Definition at line 93 of file ParticleBase.h.

◆ size_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::size_type = detail::size_type

Definition at line 111 of file ParticleBase.h.

◆ vector_type

template<class PLayout, typename... IDProperties>
using ippl::ParticleBase< PLayout, IDProperties >::vector_type = typename PLayout::vector_type

Definition at line 91 of file ParticleBase.h.

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.

Definition at line 55 of file ParticleBase.hpp.

References addAttribute(), ippl::Comm, EnableIDs, ID, layout_m, localNum_m, nextID_m, numNodes_m, R, and totalNum_m.

Referenced by ParticleBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Definition at line 70 of file ParticleBase.hpp.

References initialize(), and ParticleBase().

Here is the call graph for this function:

◆ ~ParticleBase()

template<class PLayout, typename... IDProperties>
ippl::ParticleBase< PLayout, IDProperties >::~ParticleBase ( )
inline

Definition at line 143 of file ParticleBase.h.

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

Definition at line 77 of file ParticleBase.hpp.

References attributes_m, ippl::get(), localNum_m, and ippl::detail::ParticleAttribBase< MemorySpace >::setParticleCount().

Referenced by ParticleBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create()

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

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

Parameters
nLocalnumber of local particles to be created

Definition at line 91 of file ParticleBase.hpp.

References ippl::Comm, EnableIDs, forAllAttributes(), ID, layout_m, localNum_m, nextID_m, numNodes_m, PAssert, and totalNum_m.

Here is the call graph for this function:

◆ 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

Definition at line 121 of file ParticleBase.hpp.

References layout_m, and PAssert.

◆ 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

Definition at line 319 of file ParticleBase.hpp.

◆ 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

Definition at line 156 of file ParticleBase.hpp.

References ippl::Comm, internalDestroy(), localNum_m, and totalNum_m.

Here is the call graph for this function:

◆ forAllAttributes() [1/2]

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

Definition at line 223 of file ParticleBase.h.

◆ forAllAttributes() [2/2]

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>

Definition at line 211 of file ParticleBase.h.

Referenced by create(), and serialize().

Here is the caller graph for this function:

◆ 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

Definition at line 199 of file ParticleBase.h.

◆ getAttributeNum()

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

Definition at line 240 of file ParticleBase.h.

◆ getLayout() [1/2]

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

Definition at line 167 of file ParticleBase.h.

◆ getLayout() [2/2]

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

Definition at line 172 of file ParticleBase.h.

◆ getLocalNum()

template<class PLayout, typename... IDProperties>
size_type ippl::ParticleBase< PLayout, IDProperties >::getLocalNum ( ) const
inline

◆ getTotalNum()

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

Definition at line 162 of file ParticleBase.h.

◆ 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

Definition at line 138 of file ParticleBase.hpp.

References ippl::Comm, layout_m, numNodes_m, and PAssert.

◆ 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.

Definition at line 83 of file ParticleBase.hpp.

References layout_m.

Referenced by ParticleBase().

Here is the caller graph for this function:

◆ internalDestroy()

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

Definition at line 165 of file ParticleBase.hpp.

References deleteIndex_m, keepIndex_m, localNum_m, PAssert, and ippl::detail::runForAllSpaces().

Referenced by destroy(), and ippl::ParticleSpatialOverlapLayout< T, Dim, Mesh, PositionProperties >::particleExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack()

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

Fill attributes of buffer.

Parameters
bufferto send
hashfunction to access index.

Definition at line 337 of file ParticleBase.hpp.

References attributes_m, ippl::get(), and ippl::detail::runForAllSpaces().

Here is the call graph for this function:

◆ packedSize() [1/2]

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

Referenced by recvFromRank().

Here is the caller graph for this function:

◆ packedSize() [2/2]

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

Definition at line 328 of file ParticleBase.hpp.

◆ 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
recvNumthe number of messages already received (to distinguish the buffers)
nRecvsthe number of particles to receive

Definition at line 293 of file ParticleBase.hpp.

References ippl::Comm, packedSize(), and ippl::detail::runForAllSpaces().

Referenced by ippl::ParticleSpatialOverlapLayout< T, Dim, Mesh, PositionProperties >::particleExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
sendNumthe number of messages already sent (to distinguish the buffers)
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

Definition at line 269 of file ParticleBase.hpp.

References attributes_m, and ippl::get().

Referenced by ippl::ParticleSpatialOverlapLayout< T, Dim, Mesh, PositionProperties >::particleExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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

Definition at line 310 of file ParticleBase.hpp.

References forAllAttributes().

Here is the call graph for this function:

◆ setLocalNum()

template<class PLayout, typename... IDProperties>
void ippl::ParticleBase< PLayout, IDProperties >::setLocalNum ( size_type size)
inline

Definition at line 157 of file ParticleBase.h.

Referenced by ippl::ParticleSpatialOverlapLayout< T, Dim, Mesh, PositionProperties >::buildCells(), and ippl::detail::copyAttributes().

Here is the caller graph for this function:

◆ 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

Definition at line 184 of file ParticleBase.h.

◆ 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
bcthe boundary conditions

Definition at line 178 of file ParticleBase.h.

◆ unpack()

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

Fill my attributes.

Parameters
bufferreceived

Definition at line 347 of file ParticleBase.hpp.

References attributes_m, ippl::get(), and ippl::detail::runForAllSpaces().

Here is the call graph for this function:

◆ update()

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

Definition at line 280 of file ParticleBase.h.

Member Data Documentation

◆ attributes_m

template<class PLayout, typename... IDProperties>
attribute_container_type ippl::ParticleBase< PLayout, IDProperties >::attributes_m
private

all attributes

Definition at line 365 of file ParticleBase.h.

Referenced by addAttribute(), pack(), sendToRank(), and unpack().

◆ deleteIndex_m

template<class PLayout, typename... IDProperties>
hash_container_type ippl::ParticleBase< PLayout, IDProperties >::deleteIndex_m
private

buffers for particle partitioning

Definition at line 374 of file ParticleBase.h.

Referenced by internalDestroy().

◆ EnableIDs

template<class PLayout, typename... IDProperties>
bool ippl::ParticleBase< PLayout, IDProperties >::EnableIDs = sizeof...(IDProperties) > 0
staticconstexprprivate

Definition at line 88 of file ParticleBase.h.

Referenced by create(), and ParticleBase().

◆ ID

template<class PLayout, typename... IDProperties>
particle_index_type ippl::ParticleBase< PLayout, IDProperties >::ID

view of particle IDs

Definition at line 118 of file ParticleBase.h.

Referenced by create(), and ParticleBase().

◆ keepIndex_m

template<class PLayout, typename... IDProperties>
hash_container_type ippl::ParticleBase< PLayout, IDProperties >::keepIndex_m
private

Definition at line 375 of file ParticleBase.h.

Referenced by internalDestroy().

◆ layout_m

template<class PLayout, typename... IDProperties>
Layout_t* ippl::ParticleBase< PLayout, IDProperties >::layout_m
private

particle layout

Definition at line 356 of file ParticleBase.h.

Referenced by create(), createWithID(), globalCreate(), initialize(), and ParticleBase().

◆ localNum_m

template<class PLayout, typename... IDProperties>
size_type ippl::ParticleBase< PLayout, IDProperties >::localNum_m
private

processor local number of particles

Definition at line 359 of file ParticleBase.h.

Referenced by addAttribute(), create(), destroy(), internalDestroy(), and ParticleBase().

◆ nextID_m

template<class PLayout, typename... IDProperties>
index_type ippl::ParticleBase< PLayout, IDProperties >::nextID_m
private

next unique particle ID

Definition at line 368 of file ParticleBase.h.

Referenced by create(), and ParticleBase().

◆ numNodes_m

template<class PLayout, typename... IDProperties>
index_type ippl::ParticleBase< PLayout, IDProperties >::numNodes_m
private

number of MPI ranks

Definition at line 371 of file ParticleBase.h.

Referenced by create(), globalCreate(), and ParticleBase().

◆ R

◆ totalNum_m

template<class PLayout, typename... IDProperties>
size_type ippl::ParticleBase< PLayout, IDProperties >::totalNum_m
private

total number of particles (across all processes)

Definition at line 362 of file ParticleBase.h.

Referenced by create(), destroy(), and ParticleBase().


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