BioCMAMC-ST
Core::GlobalInitialiser Class Reference

A class responsible for initializing various components of a simulation framework. More...

#include <global_initaliser.hpp>

Collaboration diagram for Core::GlobalInitialiser:
[legend]

Public Types

template<typename T >
using OptionalPtr = std::optional<std::unique_ptr<T>>
 Type alias for an optional unique pointer.
 

Public Member Functions

 GlobalInitialiser (const ExecInfo &_info, UserControlParameters _user_params)
 Constructs a GlobalInitialiser instance.
 
OptionalPtr< CmaRead::FlowIterator > init_flow_iterator ()
 Initializes a flow iterator.
 
std::optional< bool > init_state (std::unique_ptr< CmaRead::FlowIterator > &flow_handle)
 Initializes the simulation state.
 
OptionalPtr< CmaUtils::FlowMapTransitionnerinit_transitionner (std::unique_ptr< CmaRead::FlowIterator > &&flow_handle)
 Initializes a transitioner with the provided flow iterator.
 
OptionalPtr< CmaUtils::FlowMapTransitionnerinit_transitionner ()
 Initializes a transitioner without parameters.
 
OptionalPtr< Simulation::SimulationUnitinit_simulation (std::optional< Core::ScalarFactory::ScalarVariant > variant=std::nullopt)
 Initializes a simulation unit.
 
OptionalPtr< Simulation::SimulationUnitinit_simulation (std::unique_ptr< MC::MonteCarloUnit > _unit, const Simulation::ScalarInitializer &scalar_init)
 Initializes a simulation unit with specified parameters.
 
std::optional< Simulation::ScalarInitializerinit_scalar ()
 Initializes a scalar component of the simulation.
 
std::optional< Simulation::ScalarInitializerinit_scalar (Core::ScalarFactory::ScalarVariant &&variant)
 
void init_feed (std::optional< Simulation::Feed::SimulationFeed > feed=std::nullopt)
 Initializes a simulation feed.
 
OptionalPtr< MC::MonteCarloUnitinit_monte_carlo ()
 Initializes a Monte Carlo unit.
 
bool check_init_terminate () const
 Checks if all initialization steps have been validated.
 
SimulationParameters get_parameters () const
 
void set_initial_number_particle (uint64_t np) noexcept
 

Private Types

enum class  InitStep : std::size_t {
  FlowIterator = 0 , Transitioner , InitState , Scalar ,
  Feed , MC , SimulationUnit , Count
}
 Enum to define initialization steps. More...
 

Private Member Functions

template<typename... Args>
bool check_steps (InitStep step, Args... args) const
 Checks the validity of specified initialization steps.
 
template<typename... Args>
void validate_step (InitStep step, Args... args)
 Validates the specified initialization step and any additional steps.
 
CmtCommons::cma_exported_paths_t get_path_files (const std::string &cma_case_path)
 Retrieves path files based on the provided case path.
 
std::optional< bool > host_init_state (std::unique_ptr< CmaRead::FlowIterator > &flow_handle)
 Host speciffic state init.
 
void mpi_broadcast ()
 Performs MPI broadcast for synchronization.
 

Private Attributes

std::array< bool, static_cast< size_t >(InitStep::Count)> validated_steps {}
 Array to track validated initialization steps.
 
ExecInfo info
 
SimulationParameters params
 
UserControlParameters user_params
 
uint64_t particle_per_process
 
std::vector< double > liquid_volume
 
std::vector< double > gas_volume
 
CmaRead::Neighbors::Neighbors_const_view_t liquid_neighbors
 
double t_per_flowmap {}
 
std::vector< size_t > worker_neighbor_data
 
bool f_init_gas_flow
 
std::optional< Simulation::Feed::SimulationFeedfeed
 
bool is_host
 Flag indicating if this instance is the host.
 

Detailed Description

A class responsible for initializing various components of a simulation framework.

Member Typedef Documentation

◆ OptionalPtr

template<typename T >
using Core::GlobalInitialiser::OptionalPtr = std::optional<std::unique_ptr<T>>

Type alias for an optional unique pointer.

This template alias provides a way to represent an optional ownership of a unique pointer of type T.

Member Enumeration Documentation

◆ InitStep

enum class Core::GlobalInitialiser::InitStep : std::size_t
strongprivate

Enum to define initialization steps.

Each member represents a distinct step in the initialization process, except for the last member, Count, which signifies the total number of initialization steps.

Note
This enum class leverages a C++ feature where if the first member is initialized to 0, the subsequent members are automatically assigned incrementing integer values. Thus, the Count member effectively represents the total number of steps (n), minus one for zero-based indexing.
Enumerator
FlowIterator 

Step for initializing the flow iterator.

Transitioner 

Step for initializing the transitioner.

InitState 

Step for initializing the simulation state.

Scalar 

Step for initializing scalar values.

Feed 

Step for initializing the simulation feed.

MC 

Step for initializing the Monte Carlo unit.

SimulationUnit 

Step for initializing the simulation unit.

Count 

Total number of steps in the initialization sequence.

Constructor & Destructor Documentation

◆ GlobalInitialiser()

Core::GlobalInitialiser::GlobalInitialiser ( const ExecInfo & _info,
UserControlParameters _user_params )

Constructs a GlobalInitialiser instance.

Parameters
_infoExecution information containing context for the simulation.
_paramsSimulation parameters that configure the simulation behavior.
Here is the call graph for this function:

Member Function Documentation

◆ check_init_terminate()

bool Core::GlobalInitialiser::check_init_terminate ( ) const
nodiscard

Checks if all initialization steps have been validated.

Returns
A boolean indicating whether initialization can be terminated.
Here is the caller graph for this function:

◆ check_steps()

template<typename... Args>
bool Core::GlobalInitialiser::check_steps ( InitStep step,
Args... args ) const
inlinenodiscardprivate

Checks the validity of specified initialization steps.

Parameters
stepThe current initialization step to check.
argsAdditional steps to check.
Returns
A boolean indicating whether all specified steps are validated.
Here is the caller graph for this function:

◆ get_parameters()

SimulationParameters Core::GlobalInitialiser::get_parameters ( ) const
nodiscard
Here is the caller graph for this function:

◆ get_path_files()

CmtCommons::cma_exported_paths_t Core::GlobalInitialiser::get_path_files ( const std::string & cma_case_path)
private

Retrieves path files based on the provided case path.

Parameters
cma_case_pathThe path for the CMA case.
Returns
A structure containing exported paths.
Here is the caller graph for this function:

◆ host_init_state()

std::optional< bool > Core::GlobalInitialiser::host_init_state ( std::unique_ptr< CmaRead::FlowIterator > & flow_handle)
private

Host speciffic state init.

Here is the caller graph for this function:

◆ init_feed()

void Core::GlobalInitialiser::init_feed ( std::optional< Simulation::Feed::SimulationFeed > feed = std::nullopt)

Initializes a simulation feed.

Returns
An optional simulation feed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_flow_iterator()

OptionalPtr< CmaRead::FlowIterator > Core::GlobalInitialiser::init_flow_iterator ( )

Initializes a flow iterator.

Returns
An optional unique pointer to the initialized flow iterator.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_monte_carlo()

OptionalPtr< MC::MonteCarloUnit > Core::GlobalInitialiser::init_monte_carlo ( )

Initializes a Monte Carlo unit.

Returns
An optional unique pointer to the initialized Monte Carlo unit.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_scalar() [1/2]

std::optional< Simulation::ScalarInitializer > Core::GlobalInitialiser::init_scalar ( )

Initializes a scalar component of the simulation.

Returns
An optional scalar initializer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_scalar() [2/2]

std::optional< Simulation::ScalarInitializer > Core::GlobalInitialiser::init_scalar ( Core::ScalarFactory::ScalarVariant && variant)
Here is the call graph for this function:

◆ init_simulation() [1/2]

OptionalPtr< Simulation::SimulationUnit > Core::GlobalInitialiser::init_simulation ( std::optional< Core::ScalarFactory::ScalarVariant > variant = std::nullopt)

Initializes a simulation unit.

Returns
An optional unique pointer to the initialized simulation unit.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_simulation() [2/2]

OptionalPtr< Simulation::SimulationUnit > Core::GlobalInitialiser::init_simulation ( std::unique_ptr< MC::MonteCarloUnit > _unit,
const Simulation::ScalarInitializer & scalar_init )

Initializes a simulation unit with specified parameters.

Parameters
_unitA unique pointer to the Monte Carlo unit initialized.
scalar_initA scalar initializer for the simulation.
_feedAn optional simulation feed for initialization.
Returns
An optional unique pointer to the initialized simulation unit.
Here is the call graph for this function:

◆ init_state()

std::optional< bool > Core::GlobalInitialiser::init_state ( std::unique_ptr< CmaRead::FlowIterator > & flow_handle)

Initializes the simulation state.

Parameters
flow_handleA unique pointer to the flow iterator used for state initialization.
Returns
An optional boolean indicating success or failure of the initialization.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_transitionner() [1/2]

OptionalPtr< CmaUtils::FlowMapTransitionner > Core::GlobalInitialiser::init_transitionner ( )

Initializes a transitioner without parameters.

Returns
An optional unique pointer to the initialized flow map transitioner.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_transitionner() [2/2]

OptionalPtr< CmaUtils::FlowMapTransitionner > Core::GlobalInitialiser::init_transitionner ( std::unique_ptr< CmaRead::FlowIterator > && flow_handle)

Initializes a transitioner with the provided flow iterator.

Parameters
flow_handleA unique pointer to the flow iterator.
Returns
An optional unique pointer to the initialized flow map transitioner.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_broadcast()

void Core::GlobalInitialiser::mpi_broadcast ( )
private

Performs MPI broadcast for synchronization.

Note
: this function compiles and doesn't throw error even if no_mpi is not defined Method for handling MPI broadcast communication.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_initial_number_particle()

void Core::GlobalInitialiser::set_initial_number_particle ( uint64_t np)
noexcept

◆ validate_step()

template<typename... Args>
void Core::GlobalInitialiser::validate_step ( InitStep step,
Args... args )
inlineprivate

Validates the specified initialization step and any additional steps.

Parameters
stepThe current initialization step to validate.
argsAdditional steps to validate.
Here is the caller graph for this function:

Member Data Documentation

◆ f_init_gas_flow

bool Core::GlobalInitialiser::f_init_gas_flow
private

◆ feed

std::optional<Simulation::Feed::SimulationFeed> Core::GlobalInitialiser::feed
private

◆ gas_volume

std::vector<double> Core::GlobalInitialiser::gas_volume
private

◆ info

ExecInfo Core::GlobalInitialiser::info
private

◆ is_host

bool Core::GlobalInitialiser::is_host
private

Flag indicating if this instance is the host.

◆ liquid_neighbors

CmaRead::Neighbors::Neighbors_const_view_t Core::GlobalInitialiser::liquid_neighbors
private

◆ liquid_volume

std::vector<double> Core::GlobalInitialiser::liquid_volume
private

◆ params

SimulationParameters Core::GlobalInitialiser::params
private

◆ particle_per_process

uint64_t Core::GlobalInitialiser::particle_per_process
private

◆ t_per_flowmap

double Core::GlobalInitialiser::t_per_flowmap {}
private

◆ user_params

UserControlParameters Core::GlobalInitialiser::user_params
private

◆ validated_steps

std::array<bool, static_cast<size_t>(InitStep::Count)> Core::GlobalInitialiser::validated_steps {}
private

Array to track validated initialization steps.

◆ worker_neighbor_data

std::vector<size_t> Core::GlobalInitialiser::worker_neighbor_data
private

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