svZeroDSolver
Loading...
Searching...
No Matches
SimulationParameters.h File Reference

Source file to read simulation configuration. More...

#include <list>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include <string>
#include "Model.h"
#include "State.h"
#include "debug.h"
Include dependency graph for SimulationParameters.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SimulationParameters
 Simulation parameters. More...
 
class  JsonWrapper
 Wrapper class for nlohmann:json with error checking. More...
 

Functions

int generate_block (Model &model, const nlohmann::json &block_params_json, const std::string &block_type, const std::string_view &name, bool internal=false, bool periodic=true)
 Generate a new block and add its parameters to the model.
 
State load_initial_condition (const nlohmann::json &config, Model &model)
 Load initial conditions from a JSON configuration.
 
SimulationParameters load_simulation_params (const nlohmann::json &config)
 Load the simulation parameters from a JSON configuration.
 
void load_simulation_model (const nlohmann::json &config, Model &model)
 Load the 0D block in the model from a configuration.
 
void validate_input (const nlohmann::json &config)
 Check that the JSON configuration has the required inputs.
 
void create_vessels (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component, std::map< int, std::string > &vessel_id_map)
 Handle the creation of vessel blocks and connections with boundary conditions.
 
void create_external_coupling (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component, std::map< int, std::string > &vessel_id_map, std::map< std::string, std::string > &bc_type_map)
 Handle the creation of external coupling blocks and connections with other blocks.
 
void create_boundary_conditions (Model &model, const nlohmann::json &config, const std::string &component, std::map< std::string, std::string > &bc_type_map, std::vector< std::string > &closed_loop_bcs)
 Handle the creation of boundary condition blocks.
 
void create_junctions (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component, std::map< int, std::string > &vessel_id_map)
 Handle the creation of junctions and their connections.
 
void create_closed_loop (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component, std::vector< std::string > &closed_loop_bcs)
 Handle the creation of closed-loop blocks and associated connections.
 
void create_valves (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component)
 Handle the creation of valves and their associated connections.
 
void create_chambers (Model &model, std::vector< std::tuple< std::string, std::string > > &connections, const nlohmann::json &config, const std::string &component)
 Handle the creation of chambers.
 

Detailed Description

Source file to read simulation configuration.

Function Documentation

◆ create_boundary_conditions()

void create_boundary_conditions ( Model & model,
const nlohmann::json & config,
const std::string & component,
std::map< std::string, std::string > & bc_type_map,
std::vector< std::string > & closed_loop_bcs )

Handle the creation of boundary condition blocks.

Parameters
modelThe model the block is associated with
configThe JSON configuration
componentName of the component to retrieve from config
bc_type_mapMap between boundary condition names and their types
closed_loop_bcsList of boundary conditions that should be connected to a closed loop heart block

◆ create_chambers()

void create_chambers ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component )

Handle the creation of chambers.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration containing all the closed loop blocks
componentName of the component to retrieve from config

◆ create_closed_loop()

void create_closed_loop ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component,
std::vector< std::string > & closed_loop_bcs )

Handle the creation of closed-loop blocks and associated connections.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration
componentName of the component to retrieve from config
closed_loop_bcsList of boundary conditions that should be connected to a closed loop heart block

< Flag to check if heart block is present (requires different handling)

◆ create_external_coupling()

void create_external_coupling ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component,
std::map< int, std::string > & vessel_id_map,
std::map< std::string, std::string > & bc_type_map )

Handle the creation of external coupling blocks and connections with other blocks.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration
componentName of the component to retrieve from config
vessel_id_mapMap between vessel names and IDs
bc_type_mapMap between boundary condition names and their types

◆ create_junctions()

void create_junctions ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component,
std::map< int, std::string > & vessel_id_map )

Handle the creation of junctions and their connections.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration
componentName of the component to retrieve from config
vessel_id_mapMap between vessel names and IDs

◆ create_valves()

void create_valves ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component )

Handle the creation of valves and their associated connections.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration
componentName of the component to retrieve from config

◆ create_vessels()

void create_vessels ( Model & model,
std::vector< std::tuple< std::string, std::string > > & connections,
const nlohmann::json & config,
const std::string & component,
std::map< int, std::string > & vessel_id_map )

Handle the creation of vessel blocks and connections with boundary conditions.

Parameters
modelThe model the block is associated with
connectionsVector storing the connections between blocks
configThe JSON configuration
componentName of the component to retrieve from config
vessel_id_mapMap between vessel names and IDs

◆ generate_block()

int generate_block ( Model & model,
const nlohmann::json & block_params_json,
const std::string & block_type,
const std::string_view & name,
bool internal = false,
bool periodic = true )

Generate a new block and add its parameters to the model.

Parameters
modelThe model that the block is added to
block_params_jsonThe JSON configuration containing the block parameter values
block_typeThe type of block
nameThe name of the block
internalIs this an internal block? This is relevant for the calibrator
periodicIs this block periodic with the cardiac cycle? This is relevant for coupling with external solvers
Returns
int The block count

◆ load_initial_condition()

State load_initial_condition ( const nlohmann::json & config,
Model & model )

Load initial conditions from a JSON configuration.

Parameters
configThe JSON configuration
modelThe model
Returns
State Initial configuration for the model

◆ load_simulation_model()

void load_simulation_model ( const nlohmann::json & config,
Model & model )

Load the 0D block in the model from a configuration.

Parameters
configThe json configuration
modelThe 0D model @

◆ load_simulation_params()

SimulationParameters load_simulation_params ( const nlohmann::json & config)

Load the simulation parameters from a JSON configuration.

Parameters
configThe JSON configuration
Returns
SimulationParameters Simulation parameters read from configuration

◆ validate_input()

void validate_input ( const nlohmann::json & config)

Check that the JSON configuration has the required inputs.

Parameters
configThe JSON configuration