BioCMAMC-ST
MC::ParticlesContainer< Model > Class Template Reference

Main owning object for Monte-Carlo particles. More...

#include <particles_container.hpp>

Collaboration diagram for MC::ParticlesContainer< Model >:
[legend]

Public Types

using UsedModel = Model

Public Member Functions

 ParticlesContainer (RuntimeParameters rt_param, std::size_t n_particle, std::size_t _n_samples)
 Alias for the model used by the container.
 ParticlesContainer ()
 ParticlesContainer (const ParticlesContainer &)=default
 Default copy and move constructors and assignment operators.
 ParticlesContainer (ParticlesContainer &&)=default
ParticlesContaineroperator= (const ParticlesContainer &)=default
ParticlesContaineroperator= (ParticlesContainer &&)=default
 ~ParticlesContainer ()=default
 Default destructor.
KOKKOS_INLINE_FUNCTION auto sample (const std::size_t idx, const std::size_t i_sample) const
KOKKOS_INLINE_FUNCTION auto samples ()
template<typename CviewType>
KOKKOS_INLINE_FUNCTION void get_contributions (const std::size_t idx, const CviewType &contributions) const
 Get the contribution if particle at index idx.
KOKKOS_INLINE_FUNCTION bool handle_division (const MC::pool_type &random_pool, std::size_t idx1) const
 Attempts to spawn a new particle by performing division on the specified particle.
KOKKOS_INLINE_FUNCTION double get_weight (std::size_t idx) const
 Return the particle weight.
void force_remove_dead ()
 Clean all the non-idle particle even if number smaller than threshold.
void merge_buffer ()
 Insert particle buffer into the main container.
template<class Archive>
void save (Archive &ar) const
 Save data into ar for serialization.
template<class Archive>
void load (Archive &ar)
 Load data from ar for deserialization.
double get_allocation_factor () const noexcept
 Get the allocation factor.
void change_nsample (const std::size_t new_n_sample)
std::size_t capacity () const noexcept
 Returns the total number of elements the container can hold without reallocating.
std::size_t get_inactive () const noexcept
 Returns the total number of non-idlde particle.
void update_and_remove_inactive (std::size_t out, std::size_t dead)
 Update the number of non-idle particle and remove if total number exceeds threshold May call : remove_inactive_particles.
KOKKOS_INLINE_FUNCTION std::size_t n_particles () const
 Gets the number of particles in the container.
void change_runtime (RuntimeParameters &&parameters) noexcept
void _sort (size_t n_c)
void remove_inactive_particles (std::size_t to_remove)
 Removes inactive particles from the container.
auto get_buffer_index () const

Public Attributes

Model::SelfParticle model
MC::ParticlePositions position
MC::ParticleStatus status
ParticleWeigths weights
ParticleAges ages
ParticleSamples random

Private Member Functions

void __allocate_buffer__ ()
void _resize (std::size_t new_size, bool force=false)

Private Attributes

Model::SelfParticle buffer_model
ParticlePositions buffer_position
Kokkos::View< uint64_t, Kokkos::SharedSpace > buffer_index
std::size_t n_allocated_elements
uint64_t n_used_elements
std::size_t inactive_counter
std::size_t n_samples
RuntimeParameters rt_params
int begin
int end

Detailed Description

template<ModelType Model>
class MC::ParticlesContainer< Model >

Main owning object for Monte-Carlo particles.

This class is responsible for managing and owning containers related to particles, providing access to them for processing in a Monte-Carlo simulation. It uses a templated model to define the behavior and properties of the particles.

Template Parameters
ModelThe particle model type used for defining the behavior and properties of the particles.

Member Typedef Documentation

◆ UsedModel

template<ModelType Model>
using MC::ParticlesContainer< Model >::UsedModel = Model

Constructor & Destructor Documentation

◆ ParticlesContainer() [1/4]

template<ModelType M>
MC::ParticlesContainer< M >::ParticlesContainer ( RuntimeParameters rt_param,
std::size_t n_particle,
std::size_t _n_samples )
explicit

Alias for the model used by the container.

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

◆ ParticlesContainer() [2/4]

template<ModelType M>
MC::ParticlesContainer< M >::ParticlesContainer ( )
Here is the call graph for this function:

◆ ParticlesContainer() [3/4]

template<ModelType Model>
MC::ParticlesContainer< Model >::ParticlesContainer ( const ParticlesContainer< Model > & )
default

Default copy and move constructors and assignment operators.

Here is the call graph for this function:

◆ ParticlesContainer() [4/4]

template<ModelType Model>
MC::ParticlesContainer< Model >::ParticlesContainer ( ParticlesContainer< Model > && )
default
Here is the call graph for this function:

◆ ~ParticlesContainer()

template<ModelType Model>
MC::ParticlesContainer< Model >::~ParticlesContainer ( )
default

Default destructor.

Member Function Documentation

◆ __allocate_buffer__()

template<ModelType Model>
void MC::ParticlesContainer< Model >::__allocate_buffer__ ( )
private
Here is the caller graph for this function:

◆ _resize()

template<ModelType Model>
void MC::ParticlesContainer< Model >::_resize ( std::size_t new_size,
bool force = false )
private
Here is the caller graph for this function:

◆ _sort()

template<ModelType Model>
void MC::ParticlesContainer< M >::_sort ( size_t n_c)

◆ capacity()

template<ModelType Model>
std::size_t MC::ParticlesContainer< Model >::capacity ( ) const
nodiscardnoexcept

Returns the total number of elements the container can hold without reallocating.

◆ change_nsample()

template<ModelType Model>
void MC::ParticlesContainer< Model >::change_nsample ( const std::size_t new_n_sample)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ change_runtime()

template<ModelType M>
void MC::ParticlesContainer< M >::change_runtime ( RuntimeParameters && parameters)
noexcept

◆ force_remove_dead()

template<ModelType Model>
void MC::ParticlesContainer< Model >::force_remove_dead ( )

Clean all the non-idle particle even if number smaller than threshold.

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

◆ get_allocation_factor()

template<ModelType Model>
double MC::ParticlesContainer< Model >::get_allocation_factor ( ) const
nodiscardnoexcept

Get the allocation factor.

◆ get_buffer_index()

template<ModelType Model>
auto MC::ParticlesContainer< Model >::get_buffer_index ( ) const
nodiscard

◆ get_contributions()

template<ModelType Model>
template<typename CviewType>
KOKKOS_INLINE_FUNCTION void MC::ParticlesContainer< Model >::get_contributions ( const std::size_t idx,
const CviewType & contributions ) const
inline

Get the contribution if particle at index idx.

Template Parameters
CviewTypeview type fo contribution
Here is the call graph for this function:

◆ get_inactive()

template<ModelType Model>
std::size_t MC::ParticlesContainer< Model >::get_inactive ( ) const
nodiscardnoexcept

Returns the total number of non-idlde particle.

◆ get_weight()

template<ModelType M>
KOKKOS_INLINE_FUNCTION double MC::ParticlesContainer< M >::get_weight ( std::size_t idx) const
nodiscard

Return the particle weight.

Here is the caller graph for this function:

◆ handle_division()

template<ModelType Model>
KOKKOS_INLINE_FUNCTION bool MC::ParticlesContainer< Model >::handle_division ( const MC::pool_type & random_pool,
std::size_t idx1 ) const
nodiscard

Attempts to spawn a new particle by performing division on the specified particle.

Executes container and buffer manipulations to spawn a new particle and invokes Model::division. The operation may fail if conditions for division are not met (e.g., insufficient space or invalid state).

Parameters
random_poolThe random number generator pool for stochastic operations.
idx1The index of the particle to undergo division.
Returns
true if the spawn was successful, false otherwise.

◆ load()

template<ModelType Model>
template<class Archive>
void MC::ParticlesContainer< Model >::load ( Archive & ar)

Load data from ar for deserialization.

Here is the call graph for this function:

◆ merge_buffer()

template<ModelType Model>
void MC::ParticlesContainer< Model >::merge_buffer ( )

Insert particle buffer into the main container.

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

◆ n_particles()

template<ModelType Model>
KOKKOS_INLINE_FUNCTION std::size_t MC::ParticlesContainer< Model >::n_particles ( ) const
nodiscard

Gets the number of particles in the container.

Returns
The number of particles currently in the to_process container.
Here is the caller graph for this function:

◆ operator=() [1/2]

template<ModelType Model>
ParticlesContainer & MC::ParticlesContainer< Model >::operator= ( const ParticlesContainer< Model > & )
default
Here is the call graph for this function:

◆ operator=() [2/2]

template<ModelType Model>
ParticlesContainer & MC::ParticlesContainer< Model >::operator= ( ParticlesContainer< Model > && )
default
Here is the call graph for this function:

◆ remove_inactive_particles()

template<ModelType M>
void MC::ParticlesContainer< M >::remove_inactive_particles ( std::size_t to_remove)

Removes inactive particles from the container.

This function handles the removal of inactive particles based on the specified count. Depending on the number of particles to remove, it may:

  • Shrink the container (i.e reallocate memory if necessary),
  • Do nothing if no removal is required,
  • Throw an error if to_remove is invalid (e.g., out of bounds or incoherent),
  • Move an active particle to the position of the removed inactive particle to reduce fragmentation.
    Note
    : inactive_counter is updated at after remove
    Parameters
    to_removeThe number of inactive particles to remove.
    Exceptions
    std::runtime_errorIf to_remove is incoherent or exceeds valid bounds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sample()

template<ModelType Model>
KOKKOS_INLINE_FUNCTION auto MC::ParticlesContainer< Model >::sample ( const std::size_t idx,
const std::size_t i_sample ) const
inline

◆ samples()

template<ModelType Model>
KOKKOS_INLINE_FUNCTION auto MC::ParticlesContainer< Model >::samples ( )
inline

◆ save()

template<ModelType Model>
template<class Archive>
void MC::ParticlesContainer< Model >::save ( Archive & ar) const

Save data into ar for serialization.

◆ update_and_remove_inactive()

template<ModelType Model>
void MC::ParticlesContainer< Model >::update_and_remove_inactive ( std::size_t out,
std::size_t dead )

Update the number of non-idle particle and remove if total number exceeds threshold May call : remove_inactive_particles.

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

Member Data Documentation

◆ ages

template<ModelType Model>
ParticleAges MC::ParticlesContainer< Model >::ages

◆ begin

template<ModelType Model>
int MC::ParticlesContainer< Model >::begin
private

◆ buffer_index

template<ModelType Model>
Kokkos::View<uint64_t, Kokkos::SharedSpace> MC::ParticlesContainer< Model >::buffer_index
private

◆ buffer_model

template<ModelType Model>
Model::SelfParticle MC::ParticlesContainer< Model >::buffer_model
private

◆ buffer_position

template<ModelType Model>
ParticlePositions MC::ParticlesContainer< Model >::buffer_position
private

◆ end

template<ModelType Model>
int MC::ParticlesContainer< Model >::end
private

◆ inactive_counter

template<ModelType Model>
std::size_t MC::ParticlesContainer< Model >::inactive_counter
private

◆ model

template<ModelType Model>
Model::SelfParticle MC::ParticlesContainer< Model >::model

◆ n_allocated_elements

template<ModelType Model>
std::size_t MC::ParticlesContainer< Model >::n_allocated_elements
private

◆ n_samples

template<ModelType Model>
std::size_t MC::ParticlesContainer< Model >::n_samples
private

◆ n_used_elements

template<ModelType Model>
uint64_t MC::ParticlesContainer< Model >::n_used_elements
private

◆ position

template<ModelType Model>
MC::ParticlePositions MC::ParticlesContainer< Model >::position

◆ random

template<ModelType Model>
ParticleSamples MC::ParticlesContainer< Model >::random

◆ rt_params

template<ModelType Model>
RuntimeParameters MC::ParticlesContainer< Model >::rt_params
private

◆ status

template<ModelType Model>
MC::ParticleStatus MC::ParticlesContainer< Model >::status

◆ weights

template<ModelType Model>
ParticleWeigths MC::ParticlesContainer< Model >::weights

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