svZeroDSolver
|
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"
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. | |
Source file to read simulation configuration.
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.
model | The model the block is associated with |
config | The JSON configuration |
component | Name of the component to retrieve from config |
bc_type_map | Map between boundary condition names and their types |
closed_loop_bcs | List of boundary conditions that should be connected to a closed loop heart block |
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration containing all the closed loop blocks |
component | Name of the component to retrieve from config |
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration |
component | Name of the component to retrieve from config |
closed_loop_bcs | List of boundary conditions that should be connected to a closed loop heart block |
< Flag to check if heart block is present (requires different handling)
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration |
component | Name of the component to retrieve from config |
vessel_id_map | Map between vessel names and IDs |
bc_type_map | Map between boundary condition names and their types |
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration |
component | Name of the component to retrieve from config |
vessel_id_map | Map between vessel names and IDs |
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration |
component | Name of the component to retrieve from config |
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.
model | The model the block is associated with |
connections | Vector storing the connections between blocks |
config | The JSON configuration |
component | Name of the component to retrieve from config |
vessel_id_map | Map between vessel names and IDs |
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.
model | The model that the block is added to |
block_params_json | The JSON configuration containing the block parameter values |
block_type | The type of block |
name | The name of the block |
internal | Is this an internal block? This is relevant for the calibrator |
periodic | Is this block periodic with the cardiac cycle? This is relevant for coupling with external solvers |
Load initial conditions from a JSON configuration.
config | The JSON configuration |
model | The model |
void load_simulation_model | ( | const nlohmann::json & | config, |
Model & | model ) |
Load the 0D block in the model from a configuration.
config | The json configuration |
model | The 0D model @ |
SimulationParameters load_simulation_params | ( | const nlohmann::json & | config | ) |
Load the simulation parameters from a JSON configuration.
config | The JSON configuration |
void validate_input | ( | const nlohmann::json & | config | ) |
Check that the JSON configuration has the required inputs.
config | The JSON configuration |