8#ifndef SVZERODSOLVER_MODEL_MODEL_HPP_
9#define SVZERODSOLVER_MODEL_MODEL_HPP_
23#include "BloodVesselRC.h"
96 const std::vector<int>& block_param_ids,
bool internal =
false);
107 int add_block(
const std::string& block_name,
108 const std::vector<int>& block_param_ids,
109 const std::string_view& name,
bool internal =
false);
117 bool has_block(
const std::string& name)
const;
159 int add_node(
const std::vector<Block*>& inlet_eles,
160 const std::vector<Block*>& outlet_eles,
161 const std::string_view& name);
188 const std::vector<double>& values,
bool periodic =
true);
248 Eigen::Matrix<double, Eigen::Dynamic, 1>& y,
249 Eigen::Matrix<double, Eigen::Dynamic, 1>& dy);
256 void post_solve(Eigen::Matrix<double, Eigen::Dynamic, 1>& y);
263 void accept_timestep(
const Eigen::Matrix<double, Eigen::Dynamic, 1>& y);
369 int parameter_count = 0;
370 std::map<int, double> param_value_cache;
372 std::vector<std::shared_ptr<Block>> blocks;
373 std::vector<BlockType> block_types;
374 std::vector<std::string> block_names;
375 std::map<std::string, int>
378 std::vector<std::shared_ptr<Block>>
381 std::vector<std::shared_ptr<Node>> nodes;
382 std::vector<std::string> node_names;
384 std::vector<Parameter>
395 bool has_windkessel_bc =
false;
396 double largest_windkessel_time_constant = 0.0;
397 double time_step_size = -1.0;
Define the block factory functional.
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:15
model::BloodVessel source file
model::BloodVesselCRL source file
model::BloodVesselJunction source file
model::ChamberElastanceInductor source file
model::ChamberElastanceInductorExponential source file
model::ChamberSphere source file
Left side of ClosedLoopCoronaryBC.
Right side of ClosedLoopCoronaryBC.
model::ClosedLoopHeartPulmonary source file
model::ClosedLoopRCRBC source file
model::DOFHandler source file
model::FlowReferenceBC source file
model::ImpedanceBC source file
model::Junction source file
model::LinearElastanceChamber source file
model::OpenLoopCoronaryBC source file
model::OpenLoopCoronaryVarResBC source file
model::Parameter source file
model::PiecewiseValve source file
model::PressureReferenceBC source file
model::ResistanceBC source file
model::ResistiveJunction source file
model::ValveTanh source file
model::WindkesselBC source file
Base class for 0D model components.
Definition Block.h:77
Degree-of-freedom handler.
Definition DOFHandler.h:21
int add_node(const std::vector< Block * > &inlet_eles, const std::vector< Block * > &outlet_eles, const std::string_view &name)
Add a node to the model.
Definition Model.cpp:124
std::vector< std::vector< double > > get_persistent_states() const
Get persistent state payloads for all blocks (including internal).
Definition Model.cpp:235
void finalize()
Finalize the model after all blocks, nodes and parameters have been added.
Definition Model.cpp:172
void update_parameter_value(int param_id, double param_value)
Update the current value of a parameter in the parameter_values vector. Note that this is different f...
Definition Model.cpp:168
double get_parameter_value(int param_id) const
Get the current value of a parameter.
Definition Model.cpp:164
void update_largest_windkessel_time_constant(double time_constant)
Update model with largest time constant among all Windkessel boundary conditions present in model.
Definition Model.cpp:324
void setup_initial_state_dependent_parameters(State initial_state)
Setup model parameters that depend on the initial state.
Definition Model.cpp:312
void update_time(SparseSystem &system, double time)
Update the time-dependent contributions of all elements in a sparse system.
Definition Model.cpp:203
std::string get_node_name(int node_id) const
Get the name of a node by it's ID.
Definition Model.cpp:136
void update_constant(SparseSystem &system)
Update the constant contributions of all elements in a sparse system.
Definition Model.cpp:197
BlockType get_block_type(const std::string_view &name) const
Get a block type by its name.
Definition Model.cpp:110
double get_largest_windkessel_time_constant()
Get largest Windkessel time constant in model.
Definition Model.cpp:330
void set_persistent_states(const std::vector< std::vector< double > > &states)
Restore persistent states for all blocks.
Definition Model.cpp:246
double get_time_step_size() const
Get model time step size used by blocks with dt-dependent logic.
Definition Model.cpp:269
void update_has_windkessel_bc(bool has_windkessel)
Specify if model has at least one Windkessel boundary condition.
Definition Model.cpp:320
void set_time_step_size(double time_step_size)
Set model time step size used by blocks with dt-dependent logic.
Definition Model.cpp:265
int add_block(Block *block, const std::string_view &name, const std::vector< int > &block_param_ids, bool internal=false)
Add a block to the model (without parameters).
Definition Model.cpp:54
void to_unsteady()
Convert the blocks to an unsteady behavior.
Definition Model.cpp:289
void clear_persistent_states()
Clear persistent state for all blocks.
Definition Model.cpp:259
int add_parameter(double value)
Add a constant model parameter.
Definition Model.cpp:140
double cardiac_cycle_period
Cardiac cycle period.
Definition Model.h:75
Block * get_block(const std::string_view &name) const
Get a block by its name.
Definition Model.cpp:92
void post_solve(Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
Modify the solution after solving it.
Definition Model.cpp:223
TripletsContributions get_num_triplets() const
Get number of triplets all elements.
Definition Model.cpp:302
bool has_block(const std::string &name) const
Check if a block with given name exists.
Definition Model.cpp:84
double time
Current time.
Definition Model.h:76
void to_steady()
Convert the blocks to a steady behavior.
Definition Model.cpp:271
Block * create_block(const std::string &block_name)
Create a new block.
Definition Model.cpp:44
Model()
Construct a new Model object.
Definition Model.cpp:12
void accept_timestep(const Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
Accept one converged time-step for all blocks.
Definition Model.cpp:229
void update_solution(SparseSystem &system, Eigen::Matrix< double, Eigen::Dynamic, 1 > &y, Eigen::Matrix< double, Eigen::Dynamic, 1 > &dy)
Update the solution-dependent contributions of all elements in a sparse system.
Definition Model.cpp:215
std::map< std::string_view, BlockFactoryFunc > block_factory_map
Factory that holds all implemented blocks.
Definition Model.h:59
std::string get_block_name(int block_id) const
Get the name of a block by it's ID.
Definition Model.cpp:120
int get_num_blocks(bool internal=false) const
Get the number of blocks in the model.
Definition Model.cpp:187
Parameter * get_parameter(int param_id)
Get a parameter by its global ID.
Definition Model.cpp:162
bool get_has_windkessel_bc()
Check if model has at least one Windkessel boundary condition.
Definition Model.cpp:328
DOFHandler dofhandler
Degree-of-freedom handler of the model.
Definition Model.h:73
Model Parameter.
Definition Parameter.h:25
Sparse system.
Definition SparseSystem.h:30
State of the system.
Definition State.h:19
The number of triplets that the element contributes to the global system.
Definition Block.h:28