8#ifndef SVZERODSOLVER_MODEL_MODEL_HPP_
9#define SVZERODSOLVER_MODEL_MODEL_HPP_
88 const std::vector<int> &block_param_ids,
bool internal =
false);
99 int add_block(
const std::string &block_name,
100 const std::vector<int> &block_param_ids,
101 const std::string_view &name,
bool internal =
false);
109 bool has_block(
const std::string &name)
const;
151 int add_node(
const std::vector<Block *> &inlet_eles,
152 const std::vector<Block *> &outlet_eles,
153 const std::string_view &name);
180 const std::vector<double> &values,
bool periodic =
true);
240 Eigen::Matrix<double, Eigen::Dynamic, 1> &y,
241 Eigen::Matrix<double, Eigen::Dynamic, 1> &dy);
248 void post_solve(Eigen::Matrix<double, Eigen::Dynamic, 1> &y);
321 int parameter_count = 0;
322 std::map<int, double> param_value_cache;
324 std::vector<std::shared_ptr<Block>> blocks;
325 std::vector<BlockType> block_types;
326 std::vector<std::string> block_names;
327 std::map<std::string, int>
330 std::vector<std::shared_ptr<Block>>
333 std::vector<std::shared_ptr<Node>> nodes;
334 std::vector<std::string> node_names;
336 std::vector<Parameter>
347 bool has_windkessel_bc =
false;
348 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::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: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:115
void finalize()
Finalize the model after all blocks, nodes and parameters have been added.
Definition Model.cpp:163
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:159
double get_parameter_value(int param_id) const
Get the current value of a parameter.
Definition Model.cpp:155
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:127
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:101
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:45
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:131
double cardiac_cycle_period
Cardiac cycle period.
Definition Model.h:67
Block * get_block(const std::string_view &name) const
Get a block by its name.
Definition Model.cpp:83
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:75
double time
Current time.
Definition Model.h:68
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:35
~Model()
Destroy the Model object.
Definition Model.cpp:33
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:51
std::string get_block_name(int block_id) const
Get the name of a block by it's ID.
Definition Model.cpp:111
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:153
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:65
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