8#ifndef SVZERODSOLVER_MODEL_MODEL_HPP_
9#define SVZERODSOLVER_MODEL_MODEL_HPP_
92 const std::vector<int>& block_param_ids,
bool internal =
false);
103 int add_block(
const std::string& block_name,
104 const std::vector<int>& block_param_ids,
105 const std::string_view& name,
bool internal =
false);
113 bool has_block(
const std::string& name)
const;
155 int add_node(
const std::vector<Block*>& inlet_eles,
156 const std::vector<Block*>& outlet_eles,
157 const std::string_view& name);
184 const std::vector<double>& values,
bool periodic =
true);
244 Eigen::Matrix<double, Eigen::Dynamic, 1>& y,
245 Eigen::Matrix<double, Eigen::Dynamic, 1>& dy);
252 void post_solve(Eigen::Matrix<double, Eigen::Dynamic, 1>& y);
325 int parameter_count = 0;
326 std::map<int, double> param_value_cache;
328 std::vector<std::shared_ptr<Block>> blocks;
329 std::vector<BlockType> block_types;
330 std::vector<std::string> block_names;
331 std::map<std::string, int>
334 std::vector<std::shared_ptr<Block>>
337 std::vector<std::shared_ptr<Node>> nodes;
338 std::vector<std::string> node_names;
340 std::vector<Parameter>
351 bool has_windkessel_bc =
false;
352 double largest_windkessel_time_constant = 0.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::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::Junction source file
model::OpenLoopCoronaryBC source file
model::Parameter source file
model::PiecewiseCosineChamber 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:75
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:119
void finalize()
Finalize the model after all blocks, nodes and parameters have been added.
Definition Model.cpp:167
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:163
double get_parameter_value(int param_id) const
Get the current value of a parameter.
Definition Model.cpp:159
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:277
void setup_initial_state_dependent_parameters(State initial_state)
Setup model parameters that depend on the initial state.
Definition Model.cpp:265
void update_time(SparseSystem &system, double time)
Update the time-dependent contributions of all elements in a sparse system.
Definition Model.cpp:198
std::string get_node_name(int node_id) const
Get the name of a node by it's ID.
Definition Model.cpp:131
void update_constant(SparseSystem &system)
Update the constant contributions of all elements in a sparse system.
Definition Model.cpp:192
BlockType get_block_type(const std::string_view &name) const
Get a block type by its name.
Definition Model.cpp:105
double get_largest_windkessel_time_constant()
Get largest Windkessel time constant in model.
Definition Model.cpp:283
void update_has_windkessel_bc(bool has_windkessel)
Specify if model has at least one Windkessel boundary condition.
Definition Model.cpp:273
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:49
void to_unsteady()
Convert the blocks to an unsteady behavior.
Definition Model.cpp:242
int add_parameter(double value)
Add a constant model parameter.
Definition Model.cpp:135
double cardiac_cycle_period
Cardiac cycle period.
Definition Model.h:71
Block * get_block(const std::string_view &name) const
Get a block by its name.
Definition Model.cpp:87
void post_solve(Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
Modify the solution after solving it.
Definition Model.cpp:218
TripletsContributions get_num_triplets() const
Get number of triplets all elements.
Definition Model.cpp:255
bool has_block(const std::string &name) const
Check if a block with given name exists.
Definition Model.cpp:79
double time
Current time.
Definition Model.h:72
void to_steady()
Convert the blocks to a steady behavior.
Definition Model.cpp:224
Block * create_block(const std::string &block_name)
Create a new block.
Definition Model.cpp:39
~Model()
Destroy the Model object.
Definition Model.cpp:37
Model()
Construct a new Model object.
Definition Model.cpp:12
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:210
std::map< std::string_view, BlockFactoryFunc > block_factory_map
Factory that holds all implemented blocks.
Definition Model.h:55
std::string get_block_name(int block_id) const
Get the name of a block by it's ID.
Definition Model.cpp:115
int get_num_blocks(bool internal=false) const
Get the number of blocks in the model.
Definition Model.cpp:182
Parameter * get_parameter(int param_id)
Get a parameter by its global ID.
Definition Model.cpp:157
bool get_has_windkessel_bc()
Check if model has at least one Windkessel boundary condition.
Definition Model.cpp:281
DOFHandler dofhandler
Degree-of-freedom handler of the model.
Definition Model.h:69
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:26