BioCMAMC-ST
Api::SimulationInstance Class Reference

Represents an instance of a simulation with customizable parameters and behaviors. More...

#include <api.hpp>

Collaboration diagram for Api::SimulationInstance:
[legend]

Public Member Functions

 SimulationInstance (const SimulationInstance &)=delete
 Deleted copy constructor to prevent copying.
 SimulationInstance (SimulationInstance &&)=default
 Defaulted move constructor for efficient resource transfer.
SimulationInstanceoperator= (const SimulationInstance &)=delete
 Deleted copy assignment operator to prevent copying.
SimulationInstanceoperator= (SimulationInstance &&)=default
 Defaulted move assignment operator for efficient resource transfer.
 SimulationInstance ()=delete
 Default constructor.
 ~SimulationInstance ()
 Default destructor.
ApiResult apply (bool to_load) noexcept
 Apply the simulation configuration and prepare for execution.
ApiResult apply () noexcept
 Apply the simulation configuration and prepare for execution.
ApiResult apply_load () noexcept
 Load ad apply the simulation configuration and prepare for execution based on file.
ApiResult register_parameters (Core::UserControlParameters &&params) noexcept
 Register user control parameters for the simulation.
bool register_result_path (std::string_view path)
 Register a result output path.
ApiResult register_initial_condition (Core::ScalarFactory::ScalarVariant &&type)
ApiResult register_initialiser_file_path (std::string_view path)
bool register_cma_path (std::string_view path, bool recursive=false)
 Register a path for CMA data.
bool register_serde (std::string_view path)
 Register a serialization/deserialization (serde) path.
ApiResult register_model_name (std::string_view path)
 Register the model name for the simulation.
ApiResult set_feed (Simulation::Feed::FeedDescriptor feed_variant, Phase phase=Phase::Liquid)
ApiResult set_feed_constant (double _flow, double _concentration, std::size_t _species, std::size_t _position, bool gas=false, bool fed_batch=false)
ApiResult set_feed_constant_different_output (double _flow, double _concentration, std::size_t _species, std::size_t input_position, std::size_t output_position, bool gas=false)
ApiResult register_scalar_initiazer (Core::ScalarFactory::ScalarVariant &&var)
 Configure feed constants for the simulation.
int get_id () const
 Retrieve the simulation instance's unique identifier.
const ExecInfoget_exec_info () const
ApiResult exec () noexcept
 Execute the simulation.
void set_logger (std::shared_ptr< IO::Logger > _logger)
auto & get_logger () const

Static Public Member Functions

static std::optional< std::unique_ptr< SimulationInstance > > init (int argc, char **argv, std::optional< std::size_t > run_id=std::nullopt) noexcept
 Initialize a simulation instance.

Private Member Functions

 SimulationInstance (int argc, char **argv, std::optional< std::size_t > run_id)
 simulation instance constructor

Private Attributes

int id {}
 The unique identifier to connect with c api.
std::shared_ptr< IO::Loggerlogger
std::optional< Core::ScalarFactory::ScalarVariantscalar_initializer_variant = std::nullopt
Core::CaseData _data
 Case data for the simulation.
Core::UserControlParameters params
 User-defined control parameters.
bool loaded = false
 Flag indicating if the instance is loaded.
bool applied = false
 Flag indicating if the configuration is applied.
bool registered = false
 Flag indicating if resources are registered.
std::optional< Simulation::Feed::SimulationFeedfeed
 Optional feed configuration.
std::optional< Simulation::MassTransfer::Type::MtrTypeVariantmtr_type

Detailed Description

Represents an instance of a simulation with customizable parameters and behaviors.

The SimulationInstance class is designed to encapsulate the configuration, execution, and management of a simulation process. It supports initialization for single-threaded or multi-threaded (optionally MPI-enabled) scenarios, parameter registration, and execution control.

The class is non-copyable but movable to ensure unique ownership and efficient resource management. Note: Define this struct as struct and not class to be coherent with the C opaque type defined as typedef struct This change absolutely nothing to the code behaviour it's just a name

Constructor & Destructor Documentation

◆ SimulationInstance() [1/4]

Api::SimulationInstance::SimulationInstance ( const SimulationInstance & )
delete

Deleted copy constructor to prevent copying.

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

◆ SimulationInstance() [2/4]

Api::SimulationInstance::SimulationInstance ( SimulationInstance && )
default

Defaulted move constructor for efficient resource transfer.

Here is the call graph for this function:

◆ SimulationInstance() [3/4]

Api::SimulationInstance::SimulationInstance ( )
delete

Default constructor.

Here is the call graph for this function:

◆ ~SimulationInstance()

Api::SimulationInstance::~SimulationInstance ( )

Default destructor.

◆ SimulationInstance() [4/4]

Api::SimulationInstance::SimulationInstance ( int argc,
char ** argv,
std::optional< std::size_t > run_id )
private

simulation instance constructor

Parameters
argcNumber of runtime argument.
argvTuntime arguments.
idA unique identifier for the simulation instance (optional).
Here is the call graph for this function:

Member Function Documentation

◆ apply() [1/2]

ApiResult Api::SimulationInstance::apply ( )
noexcept

Apply the simulation configuration and prepare for execution.

Returns
An ApiResult indicating the success or failure of the operation.
Here is the call graph for this function:

◆ apply() [2/2]

ApiResult Api::SimulationInstance::apply ( bool to_load)
noexcept

Apply the simulation configuration and prepare for execution.

Parameters
to_loadFlag indicating whether the configuration should be loaded.
Returns
An ApiResult indicating the success or failure of the operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_load()

ApiResult Api::SimulationInstance::apply_load ( )
noexcept

Load ad apply the simulation configuration and prepare for execution based on file.

Returns
An ApiResult indicating the success or failure of the operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exec()

ApiResult Api::SimulationInstance::exec ( )
noexcept

Execute the simulation.

Returns
An ApiResult indicating the success or failure of the operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_exec_info()

const ExecInfo & Api::SimulationInstance::get_exec_info ( ) const
nodiscard
Here is the caller graph for this function:

◆ get_id()

int Api::SimulationInstance::get_id ( ) const
nodiscard

Retrieve the simulation instance's unique identifier.

Returns
The ID of the simulation instance.
Here is the caller graph for this function:

◆ get_logger()

auto & Api::SimulationInstance::get_logger ( ) const
inlinenodiscard

◆ init()

std::optional< std::unique_ptr< SimulationInstance > > Api::SimulationInstance::init ( int argc,
char ** argv,
std::optional< std::size_t > run_id = std::nullopt )
staticnoexcept

Initialize a simulation instance.

Parameters
argcNumber of runtime argument.
argvTuntime arguments.
idA unique identifier for the simulation instance (optional).
Returns
An optional containing a unique pointer to the instance if successful, or std::nullopt if initialization failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

SimulationInstance & Api::SimulationInstance::operator= ( const SimulationInstance & )
delete

Deleted copy assignment operator to prevent copying.

Here is the call graph for this function:

◆ operator=() [2/2]

SimulationInstance & Api::SimulationInstance::operator= ( SimulationInstance && )
default

Defaulted move assignment operator for efficient resource transfer.

Here is the call graph for this function:

◆ register_cma_path()

bool Api::SimulationInstance::register_cma_path ( std::string_view path,
bool recursive = false )

Register a path for CMA data.

Parameters
pathThe file system path for CMA data.
recursiveFlag indicating if recursive registration is required.
Returns
True if the path was successfully registered; false otherwise.
Here is the caller graph for this function:

◆ register_initial_condition()

ApiResult Api::SimulationInstance::register_initial_condition ( Core::ScalarFactory::ScalarVariant && type)
Here is the caller graph for this function:

◆ register_initialiser_file_path()

ApiResult Api::SimulationInstance::register_initialiser_file_path ( std::string_view path)
Here is the caller graph for this function:

◆ register_model_name()

ApiResult Api::SimulationInstance::register_model_name ( std::string_view path)

Register the model name for the simulation.

Parameters
pathThe model name or path.
Returns
An ApiResult indicating the success or failure of the operation.
Here is the caller graph for this function:

◆ register_parameters()

ApiResult Api::SimulationInstance::register_parameters ( Core::UserControlParameters && params)
noexcept

Register user control parameters for the simulation.

Parameters
paramsA rvalue reference to a UserControlParameters object.
Returns
An ApiResult indicating the success or failure of the operation.
Here is the caller graph for this function:

◆ register_result_path()

bool Api::SimulationInstance::register_result_path ( std::string_view path)

Register a result output path.

Parameters
pathThe file system path to store simulation results.
Returns
True if the path was successfully registered; false otherwise.
Here is the caller graph for this function:

◆ register_scalar_initiazer()

ApiResult Api::SimulationInstance::register_scalar_initiazer ( Core::ScalarFactory::ScalarVariant && var)

Configure feed constants for the simulation.

Parameters
_flowA constant flow value.
concentrationsA span of concentrations values.
_positionA span of position indices.
_speciesA span of species indices.
gasFlag indicating whether the feed is gas-phase.
Returns
True if the feed was successfully configured; false otherwise.
Here is the caller graph for this function:

◆ register_serde()

bool Api::SimulationInstance::register_serde ( std::string_view path)

Register a serialization/deserialization (serde) path.

Parameters
pathThe file system path for serde operations.
Returns
True if the path was successfully registered; false otherwise.
Here is the caller graph for this function:

◆ set_feed()

ApiResult Api::SimulationInstance::set_feed ( Simulation::Feed::FeedDescriptor feed_variant,
Phase phase = Phase::Liquid )
Here is the caller graph for this function:

◆ set_feed_constant()

ApiResult Api::SimulationInstance::set_feed_constant ( double _flow,
double _concentration,
std::size_t _species,
std::size_t _position,
bool gas = false,
bool fed_batch = false )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_feed_constant_different_output()

ApiResult Api::SimulationInstance::set_feed_constant_different_output ( double _flow,
double _concentration,
std::size_t _species,
std::size_t input_position,
std::size_t output_position,
bool gas = false )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_logger()

void Api::SimulationInstance::set_logger ( std::shared_ptr< IO::Logger > _logger)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _data

Core::CaseData Api::SimulationInstance::_data
private

Case data for the simulation.

◆ applied

bool Api::SimulationInstance::applied = false
private

Flag indicating if the configuration is applied.

◆ feed

std::optional<Simulation::Feed::SimulationFeed> Api::SimulationInstance::feed
private
Initial value:
=
std::nullopt

Optional feed configuration.

◆ id

int Api::SimulationInstance::id {}
private

The unique identifier to connect with c api.

◆ loaded

bool Api::SimulationInstance::loaded = false
private

Flag indicating if the instance is loaded.

◆ logger

std::shared_ptr<IO::Logger> Api::SimulationInstance::logger
private

◆ mtr_type

std::optional<Simulation::MassTransfer::Type::MtrTypeVariant> Api::SimulationInstance::mtr_type
private
Initial value:
=
std::nullopt

◆ params

Core::UserControlParameters Api::SimulationInstance::params
private

User-defined control parameters.

◆ registered

bool Api::SimulationInstance::registered = false
private

Flag indicating if resources are registered.

◆ scalar_initializer_variant

std::optional<Core::ScalarFactory::ScalarVariant> Api::SimulationInstance::scalar_initializer_variant = std::nullopt
private

The documentation for this class was generated from the following files:
  • apps/api/public/api/api.hpp
  • apps/api/src/api.cpp