35#ifndef SVZERODSOLVER_MODEL_MODEL_HPP_
36#define SVZERODSOLVER_MODEL_MODEL_HPP_
115 const std::vector<int> &block_param_ids,
bool internal =
false);
126 int add_block(
const std::string &block_name,
127 const std::vector<int> &block_param_ids,
128 const std::string_view &name,
bool internal =
false);
136 bool has_block(
const std::string &name)
const;
178 int add_node(
const std::vector<Block *> &inlet_eles,
179 const std::vector<Block *> &outlet_eles,
180 const std::string_view &name);
207 const std::vector<double> &values,
bool periodic =
true);
267 Eigen::Matrix<double, Eigen::Dynamic, 1> &y,
268 Eigen::Matrix<double, Eigen::Dynamic, 1> &dy);
275 void post_solve(Eigen::Matrix<double, Eigen::Dynamic, 1> &y);
348 int parameter_count = 0;
349 std::map<int, double> param_value_cache;
351 std::vector<std::shared_ptr<Block>> blocks;
352 std::vector<BlockType> block_types;
353 std::vector<std::string> block_names;
354 std::map<std::string, int>
357 std::vector<std::shared_ptr<Block>>
360 std::vector<std::shared_ptr<Node>> nodes;
361 std::vector<std::string> node_names;
363 std::vector<Parameter>
374 bool has_windkessel_bc =
false;
375 double largest_windkessel_time_constant = 0.0;
Define the block factory functional.
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:42
model::BloodVessel source file
model::BloodVesselJunction source file
model::ChamberElastanceInductor 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::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:101
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
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:143
void finalize()
Finalize the model after all blocks, nodes and parameters have been added.
Definition Model.cpp:191
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:187
double get_parameter_value(int param_id) const
Get the current value of a parameter.
Definition Model.cpp:183
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:305
void setup_initial_state_dependent_parameters(State initial_state)
Setup model parameters that depend on the initial state.
Definition Model.cpp:293
void update_time(SparseSystem &system, double time)
Update the time-dependent contributions of all elements in a sparse system.
Definition Model.cpp:226
std::string get_node_name(int node_id) const
Get the name of a node by it's ID.
Definition Model.cpp:155
void update_constant(SparseSystem &system)
Update the constant contributions of all elements in a sparse system.
Definition Model.cpp:220
BlockType get_block_type(const std::string_view &name) const
Get a block type by its name.
Definition Model.cpp:129
double get_largest_windkessel_time_constant()
Get largest Windkessel time constant in model.
Definition Model.cpp:311
void update_has_windkessel_bc(bool has_windkessel)
Specify if model has at least one Windkessel boundary condition.
Definition Model.cpp:301
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:73
void to_unsteady()
Convert the blocks to an unsteady behavior.
Definition Model.cpp:270
int add_parameter(double value)
Add a constant model parameter.
Definition Model.cpp:159
double cardiac_cycle_period
Cardiac cycle period.
Definition Model.h:94
Block * get_block(const std::string_view &name) const
Get a block by its name.
Definition Model.cpp:111
void post_solve(Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
Modify the solution after solving it.
Definition Model.cpp:246
TripletsContributions get_num_triplets() const
Get number of triplets all elements.
Definition Model.cpp:283
bool has_block(const std::string &name) const
Check if a block with given name exists.
Definition Model.cpp:103
double time
Current time.
Definition Model.h:95
void to_steady()
Convert the blocks to a steady behavior.
Definition Model.cpp:252
Block * create_block(const std::string &block_name)
Create a new block.
Definition Model.cpp:63
~Model()
Destroy the Model object.
Definition Model.cpp:61
Model()
Construct a new Model object.
Definition Model.cpp:40
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:238
std::map< std::string_view, BlockFactoryFunc > block_factory_map
Factory that holds all implemented blocks.
Definition Model.h:78
std::string get_block_name(int block_id) const
Get the name of a block by it's ID.
Definition Model.cpp:139
int get_num_blocks(bool internal=false) const
Get the number of blocks in the model.
Definition Model.cpp:210
Parameter * get_parameter(int param_id)
Get a parameter by its global ID.
Definition Model.cpp:181
bool get_has_windkessel_bc()
Check if model has at least one Windkessel boundary condition.
Definition Model.cpp:309
DOFHandler dofhandler
Degree-of-freedom handler of the model.
Definition Model.h:92
Model Parameter.
Definition Parameter.h:52
Sparse system.
Definition SparseSystem.h:57
State of the system.
Definition State.h:46
The number of triplets that the element contributes to the global system.
Definition Block.h:52