svZeroDSolver
|
Base class for 0D model components. More...
#include <Block.h>
Public Member Functions | |
Block (int id, Model *model, BlockType block_type, BlockClass block_class, std::vector< std::pair< std::string, InputParameter > > input_params) | |
Construct a new Block object. | |
~Block () | |
Destroy the Block object. | |
Block (const Block &)=delete | |
Copy the Block object. | |
std::string | get_name () |
Get the name of the block. | |
void | update_vessel_type (VesselType type) |
Update vessel type of the block. | |
void | setup_params_ (const std::vector< int > ¶m_ids) |
Setup parameter IDs for the block. | |
void | setup_dofs_ (DOFHandler &dofhandler, int num_equations, const std::list< std::string > &internal_var_names) |
Set up the degrees of freedom (DOF) of the block. | |
virtual void | setup_dofs (DOFHandler &dofhandler) |
Set up the degrees of freedom (DOF) of the block. | |
virtual void | setup_model_dependent_params () |
Setup parameters that depend on the model. | |
virtual void | setup_initial_state_dependent_params (State initial_state, std::vector< double > ¶meters) |
Setup parameters that depend on the initial state. | |
virtual void | update_constant (SparseSystem &system, std::vector< double > ¶meters) |
Update the constant contributions of the element in a sparse system. | |
virtual void | update_time (SparseSystem &system, std::vector< double > ¶meters) |
Update the time-dependent contributions of the element in a sparse system. | |
virtual void | update_solution (SparseSystem &system, std::vector< double > ¶meters, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &y, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &dy) |
Update the solution-dependent contributions of the element in a sparse system. | |
virtual void | post_solve (Eigen::Matrix< double, Eigen::Dynamic, 1 > &y) |
Modify the solution after solving it. | |
virtual void | update_gradient (Eigen::SparseMatrix< double > &jacobian, Eigen::Matrix< double, Eigen::Dynamic, 1 > &residual, Eigen::Matrix< double, Eigen::Dynamic, 1 > &alpha, std::vector< double > &y, std::vector< double > &dy) |
Set the gradient of the block contributions with respect to the parameters. | |
virtual TripletsContributions | get_num_triplets () |
Get number of triplets of element. | |
Public Attributes | |
const int | id |
Global ID of the block. | |
const Model * | model |
The model to which the block belongs. | |
const BlockType | block_type |
Type of this block. | |
const BlockClass | block_class |
Class of this block. | |
VesselType | vessel_type = VesselType::neither |
Vessel type of this block. | |
const std::vector< std::pair< std::string, InputParameter > > | input_params |
Map from name to input parameter. | |
std::vector< Node * > | inlet_nodes |
Inlet nodes. | |
std::vector< Node * > | outlet_nodes |
Outlet nodes. | |
bool | steady = false |
Toggle steady behavior. | |
bool | input_params_list = false |
Are input parameters given as a list? | |
std::vector< int > | global_param_ids |
Global IDs for the block parameters. | |
std::vector< int > | global_var_ids |
Global variable indices of the local element contributions. | |
std::vector< int > | global_eqn_ids |
Global equation indices of the local element contributions. | |
TripletsContributions | num_triplets |
Number of triplets of element. | |
Base class for 0D model components.
A Block is the base class of 0D model elements. It is the place where the contribution of an element to the global system is controlled. It defines all relevant attributes and methods of an element and a few common helpers for setting it up.
|
inline |
Construct a new Block object.
id | Global ID of the block |
model | The model to which the block belongs |
block_type | The specific type of block |
block_class | The class the block belongs to (e.g. vessel, junction) |
input_params | The parameters the block takes from the input file |
Block::~Block | ( | ) |
Destroy the Block object.
std::string Block::get_name | ( | ) |
Get the name of the block.
|
virtual |
Get number of triplets of element.
Number of triplets that the element contributes to the global system (relevant for sparse memory reservation)
|
virtual |
Modify the solution after solving it.
y | Current solution |
Reimplemented in ClosedLoopHeartPulmonary.
|
virtual |
Set up the degrees of freedom (DOF) of the block.
Set global_var_ids and global_eqn_ids of the element based on the number of equations and the number of internal variables of the element.
dofhandler | Degree-of-freedom handler to register variables and equations at |
Reimplemented in BloodVessel, BloodVesselJunction, ChamberElastanceInductor, ClosedLoopCoronaryBC, ClosedLoopHeartPulmonary, ClosedLoopRCRBC, FlowReferenceBC, Junction, OpenLoopCoronaryBC, PressureReferenceBC, ResistanceBC, ResistiveJunction, ValveTanh, and WindkesselBC.
void Block::setup_dofs_ | ( | DOFHandler & | dofhandler, |
int | num_equations, | ||
const std::list< std::string > & | internal_var_names ) |
Set up the degrees of freedom (DOF) of the block.
Set global_var_ids and global_eqn_ids of the element based on the number of equations and the number of internal variables of the element.
dofhandler | Degree-of-freedom handler to register variables and equations at |
num_equations | Number of equations of the block |
internal_var_names | Number of internal variables of the block |
|
virtual |
Setup parameters that depend on the initial state.
initial_state | The initial state of the system |
parameters | The parameter values vector (at time 0) |
Reimplemented in OpenLoopCoronaryBC.
|
virtual |
Setup parameters that depend on the model.
Reimplemented in ClosedLoopCoronaryBC, ClosedLoopCoronaryLeftBC, and ClosedLoopCoronaryRightBC.
void Block::setup_params_ | ( | const std::vector< int > & | param_ids | ) |
Setup parameter IDs for the block.
param_ids | Global IDs of the block parameters |
|
virtual |
Update the constant contributions of the element in a sparse system.
system | System to update contributions at |
parameters | Parameters of the model |
Reimplemented in BloodVessel, BloodVesselJunction, ChamberElastanceInductor, ClosedLoopCoronaryBC, ClosedLoopHeartPulmonary, ClosedLoopRCRBC, FlowReferenceBC, Junction, OpenLoopCoronaryBC, PressureReferenceBC, ResistanceBC, ResistiveJunction, ValveTanh, and WindkesselBC.
|
virtual |
Set the gradient of the block contributions with respect to the parameters.
jacobian | Jacobian with respect to the parameters |
alpha | Current parameter vector |
residual | Residual with respect to the parameters |
y | Current solution |
dy | Time-derivative of the current solution |
Reimplemented in BloodVessel, BloodVesselJunction, and Junction.
|
virtual |
Update the solution-dependent contributions of the element in a sparse system.
system | System to update contributions at |
parameters | Parameters of the model |
y | Current solution |
dy | Current derivate of the solution |
Reimplemented in BloodVessel, BloodVesselJunction, ClosedLoopCoronaryBC, ClosedLoopHeartPulmonary, and ValveTanh.
|
virtual |
Update the time-dependent contributions of the element in a sparse system.
system | System to update contributions at |
parameters | Parameters of the model |
Reimplemented in ChamberElastanceInductor, ClosedLoopHeartPulmonary, FlowReferenceBC, OpenLoopCoronaryBC, PressureReferenceBC, ResistanceBC, and WindkesselBC.
void Block::update_vessel_type | ( | VesselType | type | ) |
Update vessel type of the block.
type | Type of vessel |
const BlockClass Block::block_class |
Class of this block.
const BlockType Block::block_type |
Type of this block.
std::vector<int> Block::global_eqn_ids |
Global equation indices of the local element contributions.
Equation indices correspond to rows in the global system.
std::vector<int> Block::global_param_ids |
Global IDs for the block parameters.
IDs of the parameters
std::vector<int> Block::global_var_ids |
Global variable indices of the local element contributions.
Determines where the local element contributions are written to in the global system during assembly. The order of indices is:
with , , , , and denoting inlet pressure, inlet flow, outlet pressure, outlet flow and an internal variable of the element, respectively.
Variable indices correspond to columns in the global system.
const int Block::id |
Global ID of the block.
std::vector<Node *> Block::inlet_nodes |
Inlet nodes.
const std::vector<std::pair<std::string, InputParameter> > Block::input_params |
Map from name to input parameter.
bool Block::input_params_list = false |
Are input parameters given as a list?
const Model* Block::model |
The model to which the block belongs.
TripletsContributions Block::num_triplets |
Number of triplets of element.
Number of triplets that the element contributes to the global system (relevant for sparse memory reservation)
std::vector<Node *> Block::outlet_nodes |
Outlet nodes.
bool Block::steady = false |
Toggle steady behavior.
VesselType Block::vessel_type = VesselType::neither |
Vessel type of this block.