svZeroDSolver
Loading...
Searching...
No Matches
Block Class Reference

Base class for 0D model components. More...

#include <Block.h>

Inheritance diagram for Block:
[legend]

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 > &param_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 > &parameters)
 Setup parameters that depend on the initial state.
 
virtual void update_constant (SparseSystem &system, std::vector< double > &parameters)
 Update the constant contributions of the element in a sparse system.
 
virtual void update_time (SparseSystem &system, std::vector< double > &parameters)
 Update the time-dependent contributions of the element in a sparse system.
 
virtual void update_solution (SparseSystem &system, std::vector< double > &parameters, 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 Modelmodel
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Block() [1/2]

Block::Block ( int id,
Model * model,
BlockType block_type,
BlockClass block_class,
std::vector< std::pair< std::string, InputParameter > > input_params )
inline

Construct a new Block object.

Parameters
idGlobal ID of the block
modelThe model to which the block belongs
block_typeThe specific type of block
block_classThe class the block belongs to (e.g. vessel, junction)
input_paramsThe parameters the block takes from the input file

◆ ~Block()

Block::~Block ( )

Destroy the Block object.

◆ Block() [2/2]

Block::Block ( const Block & )
delete

Copy the Block object.

Member Function Documentation

◆ get_name()

std::string Block::get_name ( )

Get the name of the block.

Returns
std::string Name of the block

◆ get_num_triplets()

TripletsContributions Block::get_num_triplets ( )
virtual

Get number of triplets of element.

Number of triplets that the element contributes to the global system (relevant for sparse memory reservation)

Returns
TripletsContributions Number of triplets of element

◆ post_solve()

void Block::post_solve ( Eigen::Matrix< double, Eigen::Dynamic, 1 > & y)
virtual

Modify the solution after solving it.

Parameters
yCurrent solution

Reimplemented in ClosedLoopHeartPulmonary.

◆ setup_dofs()

void Block::setup_dofs ( DOFHandler & dofhandler)
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.

Parameters
dofhandlerDegree-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.

◆ setup_dofs_()

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.

Parameters
dofhandlerDegree-of-freedom handler to register variables and equations at
num_equationsNumber of equations of the block
internal_var_namesNumber of internal variables of the block

◆ setup_initial_state_dependent_params()

void Block::setup_initial_state_dependent_params ( State initial_state,
std::vector< double > & parameters )
virtual

Setup parameters that depend on the initial state.

Parameters
initial_stateThe initial state of the system
parametersThe parameter values vector (at time 0)

Reimplemented in OpenLoopCoronaryBC.

◆ setup_model_dependent_params()

void Block::setup_model_dependent_params ( )
virtual

Setup parameters that depend on the model.

Reimplemented in ClosedLoopCoronaryBC, ClosedLoopCoronaryLeftBC, and ClosedLoopCoronaryRightBC.

◆ setup_params_()

void Block::setup_params_ ( const std::vector< int > & param_ids)

Setup parameter IDs for the block.

Parameters
param_idsGlobal IDs of the block parameters

◆ update_constant()

void Block::update_constant ( SparseSystem & system,
std::vector< double > & parameters )
virtual

Update the constant contributions of the element in a sparse system.

Parameters
systemSystem to update contributions at
parametersParameters of the model

Reimplemented in BloodVessel, BloodVesselJunction, ChamberElastanceInductor, ClosedLoopCoronaryBC, ClosedLoopHeartPulmonary, ClosedLoopRCRBC, FlowReferenceBC, Junction, OpenLoopCoronaryBC, PressureReferenceBC, ResistanceBC, ResistiveJunction, ValveTanh, and WindkesselBC.

◆ update_gradient()

void Block::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 )
virtual

Set the gradient of the block contributions with respect to the parameters.

Parameters
jacobianJacobian with respect to the parameters
alphaCurrent parameter vector
residualResidual with respect to the parameters
yCurrent solution
dyTime-derivative of the current solution

Reimplemented in BloodVessel, BloodVesselJunction, and Junction.

◆ update_solution()

void Block::update_solution ( SparseSystem & system,
std::vector< double > & parameters,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > & y,
const Eigen::Matrix< double, Eigen::Dynamic, 1 > & dy )
virtual

Update the solution-dependent contributions of the element in a sparse system.

Parameters
systemSystem to update contributions at
parametersParameters of the model
yCurrent solution
dyCurrent derivate of the solution

Reimplemented in BloodVessel, BloodVesselJunction, ClosedLoopCoronaryBC, ClosedLoopHeartPulmonary, and ValveTanh.

◆ update_time()

void Block::update_time ( SparseSystem & system,
std::vector< double > & parameters )
virtual

Update the time-dependent contributions of the element in a sparse system.

Parameters
systemSystem to update contributions at
parametersParameters of the model

Reimplemented in ChamberElastanceInductor, ClosedLoopHeartPulmonary, FlowReferenceBC, OpenLoopCoronaryBC, PressureReferenceBC, ResistanceBC, and WindkesselBC.

◆ update_vessel_type()

void Block::update_vessel_type ( VesselType type)

Update vessel type of the block.

Parameters
typeType of vessel

Member Data Documentation

◆ block_class

const BlockClass Block::block_class

Class of this block.

◆ block_type

const BlockType Block::block_type

Type of this block.

◆ global_eqn_ids

std::vector<int> Block::global_eqn_ids

Global equation indices of the local element contributions.

Equation indices correspond to rows in the global system.

◆ global_param_ids

std::vector<int> Block::global_param_ids

Global IDs for the block parameters.

IDs of the parameters

◆ global_var_ids

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:

\[
[P_{in}^1, Q_{in}^1, \dots, P_{in}^n, Q_{in}^n, P_{out}^1, Q_{out}^1,
\dots, P_{out}^m, Q_{out}^m, V^{1}, \dots, V^{p}] \]

with $P_{in} $, $Q_{in} $, $P_{out} $, $Q_{out} $, and $V
$ 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.

◆ id

const int Block::id

Global ID of the block.

◆ inlet_nodes

std::vector<Node *> Block::inlet_nodes

Inlet nodes.

◆ input_params

const std::vector<std::pair<std::string, InputParameter> > Block::input_params

Map from name to input parameter.

◆ input_params_list

bool Block::input_params_list = false

Are input parameters given as a list?

◆ model

const Model* Block::model

The model to which the block belongs.

◆ num_triplets

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)

◆ outlet_nodes

std::vector<Node *> Block::outlet_nodes

Outlet nodes.

◆ steady

bool Block::steady = false

Toggle steady behavior.

◆ vessel_type

VesselType Block::vessel_type = VesselType::neither

Vessel type of this block.


The documentation for this class was generated from the following files: