8#ifndef SVZERODSOLVER_MODEL_BLOCK_HPP_
9#define SVZERODSOLVER_MODEL_BLOCK_HPP_
26struct TripletsContributions {
27 TripletsContributions(){};
43 TripletsContributions
operator+=(
const TripletsContributions &other) {
82 const std::vector<std::pair<std::string, InputParameter>>
101 std::vector<std::pair<std::string, InputParameter>>
input_params)
185 const std::list<std::string> &internal_var_names);
212 State initial_state, std::vector<double> ¶meters);
221 std::vector<double> ¶meters);
230 std::vector<double> ¶meters);
243 const Eigen::Matrix<double, Eigen::Dynamic, 1> &y,
244 const Eigen::Matrix<double, Eigen::Dynamic, 1> &dy);
251 virtual void post_solve(Eigen::Matrix<double, Eigen::Dynamic, 1> &y);
264 Eigen::SparseMatrix<double> &jacobian,
265 Eigen::Matrix<double, Eigen::Dynamic, 1> &residual,
266 Eigen::Matrix<double, Eigen::Dynamic, 1> &alpha, std::vector<double> &y,
267 std::vector<double> &dy);
Specifies the types of blocks and their parameters.
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:15
BlockClass
The classes/categories of blocks supported. Some classes require special handling (e....
Definition BlockType.h:37
VesselType
The types of vessel blocks supported.
Definition BlockType.h:50
model::DOFHandler source file
model::Parameter source file
SparseSystem source file.
bool input_params_list
Are input parameters given as a list?
Definition Block.h:89
void setup_params_(const std::vector< int > ¶m_ids)
Setup parameter IDs for the block.
Definition Block.cpp:14
Block(const Block &)=delete
Copy the Block object.
std::vector< int > global_param_ids
Global IDs for the block parameters.
Definition Block.h:123
~Block()
Destroy the Block object.
Definition Block.cpp:12
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.
Definition Block.h:100
const std::vector< std::pair< std::string, InputParameter > > input_params
Map from name to input parameter.
Definition Block.h:83
std::string get_name()
Get the name of the block.
Definition Block.cpp:8
virtual void setup_initial_state_dependent_params(State initial_state, std::vector< double > ¶meters)
Setup parameters that depend on the initial state.
Definition Block.cpp:48
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.
Definition Block.cpp:57
const BlockClass block_class
Class of this block.
Definition Block.h:80
virtual void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition Block.cpp:44
const int id
Global ID of the block.
Definition Block.h:77
const Model * model
The model to which the block belongs.
Definition Block.h:78
TripletsContributions num_triplets
Number of triplets of element.
Definition Block.h:275
virtual void update_time(SparseSystem &system, std::vector< double > ¶meters)
Update the time-dependent contributions of the element in a sparse system.
Definition Block.cpp:54
std::vector< int > global_eqn_ids
Global equation indices of the local element contributions.
Definition Block.h:149
virtual TripletsContributions get_num_triplets()
Get number of triplets of element.
Definition Block.cpp:72
virtual void update_constant(SparseSystem &system, std::vector< double > ¶meters)
Update the constant contributions of the element in a sparse system.
Definition Block.cpp:51
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.
Definition Block.cpp:64
virtual void setup_model_dependent_params()
Setup parameters that depend on the model.
Definition Block.cpp:46
VesselType vessel_type
Vessel type of this block.
Definition Block.h:81
void update_vessel_type(VesselType type)
Update vessel type of the block.
Definition Block.cpp:10
std::vector< int > global_var_ids
Global variable indices of the local element contributions.
Definition Block.h:142
virtual void post_solve(Eigen::Matrix< double, Eigen::Dynamic, 1 > &y)
Modify the solution after solving it.
Definition Block.cpp:62
std::vector< Node * > outlet_nodes
Outlet nodes.
Definition Block.h:86
bool steady
Toggle steady behavior.
Definition Block.h:88
std::vector< Node * > inlet_nodes
Inlet nodes.
Definition Block.h:85
const BlockType block_type
Type of this block.
Definition Block.h:79
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.
Definition Block.cpp:18
Degree-of-freedom handler.
Definition DOFHandler.h:21
Model of 0D elements.
Definition Model.h:48
Node.
Definition Node.h:26
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
int E
Contributions to E matrix.
Definition Block.h:57
TripletsContributions(int F, int E, int D)
Set the number of triplets that the element contributes to the global system.
Definition Block.h:35
int F
Contributions to F matrix.
Definition Block.h:53
TripletsContributions operator+=(const TripletsContributions &other)
Set the number of triplets that the element contributes to the global system.
Definition Block.h:43
int D
Contributions to dC/dy matrix.
Definition Block.h:61