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

Model of 0D elements. More...

#include <Model.h>

Public Member Functions

 Model ()
 Construct a new Model object.
 
 ~Model ()
 Destroy the Model object.
 
Blockcreate_block (const std::string &block_name)
 Create a new block.
 
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)
 
int add_block (const std::string &block_name, const std::vector< int > &block_param_ids, const std::string_view &name, bool internal=false)
 Add a block to the model (with parameters)
 
bool has_block (const std::string &name) const
 Check if a block with given name exists.
 
Blockget_block (const std::string_view &name) const
 Get a block by its name.
 
Blockget_block (int block_id) const
 Get a block by its global ID.
 
BlockType get_block_type (const std::string_view &name) const
 Get a block type by its name.
 
std::string get_block_name (int block_id) const
 Get the name of a block by it's ID.
 
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.
 
std::string get_node_name (int node_id) const
 Get the name of a node by it's ID.
 
int add_parameter (double value)
 Add a constant model parameter.
 
int add_parameter (const std::vector< double > &times, const std::vector< double > &values, bool periodic=true)
 Add a time-dependent model parameter.
 
Parameterget_parameter (int param_id)
 Get a parameter by its global ID.
 
double get_parameter_value (int param_id) const
 Get the current value of a parameter.
 
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 from updating the value within each parameter object, which is done in Parameter::update()
 
void finalize ()
 Finalize the model after all blocks, nodes and parameters have been added.
 
void update_constant (SparseSystem &system)
 Update the constant contributions of all elements in a sparse system.
 
void update_time (SparseSystem &system, double time)
 Update the time-dependent contributions of all elements in a sparse system.
 
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.
 
void post_solve (Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
 Modify the solution after solving it.
 
void to_steady ()
 Convert the blocks to a steady behavior.
 
void to_unsteady ()
 Convert the blocks to an unsteady behavior.
 
TripletsContributions get_num_triplets () const
 Get number of triplets all elements.
 
int get_num_blocks (bool internal=false) const
 Get the number of blocks in the model.
 
void update_has_windkessel_bc (bool has_windkessel)
 Specify if model has at least one Windkessel boundary condition.
 
void update_largest_windkessel_time_constant (double time_constant)
 Update model with largest time constant among all Windkessel boundary conditions present in model.
 
bool get_has_windkessel_bc ()
 Check if model has at least one Windkessel boundary condition.
 
double get_largest_windkessel_time_constant ()
 Get largest Windkessel time constant in model.
 
void setup_initial_state_dependent_parameters (State initial_state)
 Setup model parameters that depend on the initial state.
 

Public Attributes

std::map< std::string_view, BlockFactoryFuncblock_factory_map
 Factory that holds all implemented blocks.
 
DOFHandler dofhandler
 Degree-of-freedom handler of the model.
 
double cardiac_cycle_period = -1.0
 Cardiac cycle period.
 
double time = 0.0
 Current time.
 

Detailed Description

Model of 0D elements.

This class represents a full 0D model. It contains attributes and methods to store and modify 0D elements.

Constructor & Destructor Documentation

◆ Model()

Model::Model ( )

Construct a new Model object.

◆ ~Model()

Model::~Model ( )

Destroy the Model object.

Member Function Documentation

◆ add_block() [1/2]

int Model::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)

Parameters
blockThe block to add
nameThe name of the block
block_param_idsGlobal IDs of the parameters of the block
internalToggle whether block is internal
Returns
int Global ID of the block

◆ add_block() [2/2]

int Model::add_block ( const std::string & block_name,
const std::vector< int > & block_param_ids,
const std::string_view & name,
bool internal = false )

Add a block to the model (with parameters)

Parameters
block_nameType of the block
block_param_idsGlobal IDs of the parameters of the block
nameThe name of the block
internalToggle whether block is internal
Returns
int Global ID of the block

◆ add_node()

int Model::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.

Parameters
inlet_elesInlet blocks of the node
outlet_elesOutlet blocks of the node
nameName of node
Returns
int Global ID of the node

◆ add_parameter() [1/2]

int Model::add_parameter ( const std::vector< double > & times,
const std::vector< double > & values,
bool periodic = true )

Add a time-dependent model parameter.

Parameters
timesTimes corresponding to the parameter values
valuesValues of the parameter
periodicToggle whether parameter is periodic
Returns
int Global ID of the parameter

◆ add_parameter() [2/2]

int Model::add_parameter ( double value)

Add a constant model parameter.

Parameters
valueValue of the parameter
Returns
int Global ID of the parameter

◆ create_block()

Block * Model::create_block ( const std::string & block_name)

Create a new block.

Parameters
block_nameThe block name (defined in block_factory_map)
Returns
int Global ID of the block

◆ finalize()

void Model::finalize ( )

Finalize the model after all blocks, nodes and parameters have been added.

◆ get_block() [1/2]

Block * Model::get_block ( const std::string_view & name) const

Get a block by its name.

Parameters
nameName of the Block
Returns
Block* The block

◆ get_block() [2/2]

Block * Model::get_block ( int block_id) const

Get a block by its global ID.

Parameters
block_idGlobal ID of the Block
Returns
Block* The block

◆ get_block_name()

std::string Model::get_block_name ( int block_id) const

Get the name of a block by it's ID.

Parameters
block_idGlobal ID of the block
Returns
std::string Name of the block

◆ get_block_type()

BlockType Model::get_block_type ( const std::string_view & name) const

Get a block type by its name.

Parameters
nameThe name of the block
Returns
BlockType The block type

◆ get_has_windkessel_bc()

bool Model::get_has_windkessel_bc ( )

Check if model has at least one Windkessel boundary condition.

Returns
bool True if model has at least one Windkessel boundary condition

◆ get_largest_windkessel_time_constant()

double Model::get_largest_windkessel_time_constant ( )

Get largest Windkessel time constant in model.

Returns
double Largest Windkessel time constant of model

◆ get_node_name()

std::string Model::get_node_name ( int node_id) const

Get the name of a node by it's ID.

Parameters
node_idGlobal ID of the node
Returns
std::string Name of the node

◆ get_num_blocks()

int Model::get_num_blocks ( bool internal = false) const

Get the number of blocks in the model.

Parameters
internalToggle whether to return internal/hidden blocks
Returns
int Number of blocks

◆ get_num_triplets()

TripletsContributions Model::get_num_triplets ( ) const

Get number of triplets all elements.

Get the number of triplets the elements contribute to the global system (relevant for sparse memory reservation)

Returns
Number of triplets that are used in each system matrix

◆ get_parameter()

Parameter * Model::get_parameter ( int param_id)

Get a parameter by its global ID.

Parameters
param_idGlobal ID of the parameter
Returns
Parameter* The parameter

◆ get_parameter_value()

double Model::get_parameter_value ( int param_id) const

Get the current value of a parameter.

Parameters
param_idGlobal ID of the parameter
Returns
T Current value of the parameter

◆ has_block()

bool Model::has_block ( const std::string & name) const

Check if a block with given name exists.

Parameters
nameName of the Block
Returns
bool whether block exists

◆ post_solve()

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

Modify the solution after solving it.

Parameters
yCurrent solution

◆ setup_initial_state_dependent_parameters()

void Model::setup_initial_state_dependent_parameters ( State initial_state)

Setup model parameters that depend on the initial state.

Parameters
initial_stateThe initial state vector

◆ to_steady()

void Model::to_steady ( )

Convert the blocks to a steady behavior.

◆ to_unsteady()

void Model::to_unsteady ( )

Convert the blocks to an unsteady behavior.

◆ update_constant()

void Model::update_constant ( SparseSystem & system)

Update the constant contributions of all elements in a sparse system.

Parameters
systemSystem to update contributions at

◆ update_has_windkessel_bc()

void Model::update_has_windkessel_bc ( bool has_windkessel)

Specify if model has at least one Windkessel boundary condition.

Parameters
has_windkesselToggle if model has at least one Windkessel boundary condition

◆ update_largest_windkessel_time_constant()

void Model::update_largest_windkessel_time_constant ( double time_constant)

Update model with largest time constant among all Windkessel boundary conditions present in model.

Parameters
time_constantLargest Windkessel time constant

◆ update_parameter_value()

void Model::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 from updating the value within each parameter object, which is done in Parameter::update()

Parameters
param_idGlobal ID of the parameter
param_valueThe new parameter value

◆ update_solution()

void Model::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.

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

◆ update_time()

void Model::update_time ( SparseSystem & system,
double time )

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

Parameters
systemSystem to update contributions at
timeCurrent time

Member Data Documentation

◆ block_factory_map

std::map<std::string_view, BlockFactoryFunc> Model::block_factory_map

Factory that holds all implemented blocks.

◆ cardiac_cycle_period

double Model::cardiac_cycle_period = -1.0

Cardiac cycle period.

◆ dofhandler

DOFHandler Model::dofhandler

Degree-of-freedom handler of the model.

◆ time

double Model::time = 0.0

Current time.


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