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

Structured-tree impedance boundary condition with periodic memory. More...

#include <ImpedanceBC.h>

Inheritance diagram for ImpedanceBC:
[legend]

Public Member Functions

 ImpedanceBC (int id, Model *model)
 Construct a new ImpedanceBC object.
void setup_dofs (DOFHandler &dofhandler) override
 Set up the algebraic degree of freedom for the impedance BC.
void update_constant (SparseSystem &system, std::vector< double > &parameters) override
 Assemble constant Jacobian contributions.
void update_time (SparseSystem &system, std::vector< double > &parameters) override
 Assemble time-dependent residual contributions.
void accept_timestep (const Eigen::Matrix< double, Eigen::Dynamic, 1 > &y) override
 Commit the accepted outlet flow for the next convolution update.
std::vector< double > get_persistent_state () const override
 Serialize the convolution history needed for restart/coupling.
void set_persistent_state (const std::vector< double > &state) override
 Restore a previously serialized convolution history state.
void configure (const std::vector< double > &z, double pd, const std::string &convolution_mode, int num_kernel_terms, int points_per_cycle)
 Configure the impedance kernel and convolution controls.
Public Member Functions inherited from Block
 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 () const
 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_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_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 > &alpha, std::vector< double > &y, std::vector< double > &dy)
 Set the gradient of the block residual with respect to the parameters.
virtual TripletsContributions get_num_triplets ()
 Get number of triplets of element.
virtual void set_activation_function (std::unique_ptr< ActivationFunction > af)
 Set activation function (for chamber blocks that use one).
virtual void set_material (std::unique_ptr< SphereMaterial > m)
 Set wall material (for ChamberSphere blocks).

Public Attributes

TripletsContributions num_triplets {2, 0, 0}
 Nonzero triplet counts contributed by this block.
Public Attributes inherited from Block
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.

Detailed Description

Structured-tree impedance boundary condition with periodic memory.

Imposes the outlet pressure as a discrete convolution of the impedance kernel with one cardiac cycle of flow history, following the structured-tree outflow condition of [6].

Governing equations

\‍[P_{n+1}=P_d+z_0Q_{n+1}+\sum_{m=1}^{N_k-1}z_mQ_{n+1-m}
\‍]

The $z$ entries are discrete-time convolution weights. The $m=0$ term depends on the current flow, so it enters the system matrix directly; the history terms ( $m\geq 1$) are evaluated from accepted timesteps only, held in a fixed-size ring buffer spanning one cardiac cycle.

The ring buffer is zero-initialized, so the history terms are omitted entirely until one full cycle has been accepted, after which they switch on at full magnitude. This reproduces the reference implementation, which gates the same sum on t > Period, and makes the pressure discontinuous at the start of the second cycle. The first cycle is therefore not a meaningful solution and should be discarded.

Local contributions

\‍[\mathbf{y}^{e}=\left[\begin{array}{ll}P^{e} & Q^{e}\end{array}\right]^{T}
\‍]

\‍[\mathbf{F}^{e}=\left[\begin{array}{cc}
1 & -z_{0}
\end{array}\right]
\‍]

\‍[\mathbf{c}^{e}=\left[\begin{array}{c}
-\left(P_{d}+\sum_{m=1}^{N_k-1}z_mQ_{n+1-m}\right)
\end{array}\right]
\‍]

Parameters

  • z: Time-domain impedance kernel. Its length must equal one cardiac cycle in time steps (see the timing requirements below).
  • Pd: Distal/reference pressure. Optional, defaults to 0.0.
  • convolution_mode: exact (default) or truncated. In truncated mode only the first num_kernel_terms kernel entries are used, which costs $O(N_k)$ per accepted timestep instead of one full cycle.
  • num_kernel_terms: Number of kernel terms. Required when convolution_mode is truncated, ignored otherwise.

Usage in json configuration file

"boundary_conditions": [
    {
        "bc_name": "OUT",
        "bc_type": "IMPEDANCE",
        "bc_values": {
            "Pd": 0.0,
            "z": [ ... ],
            "convolution_mode": "exact",
            "num_kernel_terms": 128
        }
    }
]

Simulation timing requirements

The kernel is discretized at the solver time step, which constrains simulation_parameters:

  • cardiac_period / dt must equal z.size() in all cases.
  • Non-coupled configurations must set number_of_time_pts_per_cardiac_cycle = z.size() + 1.
  • 3D-coupled configurations must keep number_of_time_pts = 2 for the external interface step. If number_of_time_pts_per_cardiac_cycle is omitted, the cycle discretization is inferred from cardiac_period / dt.
  • steady_initial must be set to false. The steady initial condition is solved with a time step of cardiac_period / 10, which does not match the kernel discretization and has no meaningful interpretation for this boundary condition. Since steady_initial defaults to true, it must be set explicitly; otherwise the solver reports an error and exits.

Constructor & Destructor Documentation

◆ ImpedanceBC()

ImpedanceBC::ImpedanceBC ( int id,
Model * model )
inline

Construct a new ImpedanceBC object.

Parameters
idGlobal ID of the block
modelThe model to which the block belongs

Member Function Documentation

◆ accept_timestep()

void ImpedanceBC::accept_timestep ( const Eigen::Matrix< double, Eigen::Dynamic, 1 > & y)
overridevirtual

Commit the accepted outlet flow for the next convolution update.

Parameters
yAccepted global state vector

Reimplemented from Block.

◆ configure()

void ImpedanceBC::configure ( const std::vector< double > & z,
double pd,
const std::string & convolution_mode,
int num_kernel_terms,
int points_per_cycle )

Configure the impedance kernel and convolution controls.

Parameters
zTime-domain impedance kernel
pdDistal/reference pressure
convolution_modeConvolution mode (exact or truncated)
num_kernel_termsNumber of kernel terms for truncated mode
points_per_cycleSample points spanning one cardiac cycle (simulation_parameters.number_of_time_pts_per_cardiac_cycle). Pass 0 to infer the cycle discretization from cardiac_period / dt instead.

◆ get_persistent_state()

std::vector< double > ImpedanceBC::get_persistent_state ( ) const
overridevirtual

Serialize the convolution history needed for restart/coupling.

Returns
Persistent block state

Reimplemented from Block.

◆ set_persistent_state()

void ImpedanceBC::set_persistent_state ( const std::vector< double > & state)
overridevirtual

Restore a previously serialized convolution history state.

Parameters
statePersistent block state

Reimplemented from Block.

◆ setup_dofs()

void ImpedanceBC::setup_dofs ( DOFHandler & dofhandler)
overridevirtual

Set up the algebraic degree of freedom for the impedance BC.

Parameters
dofhandlerGlobal degree-of-freedom handler

Reimplemented from Block.

◆ update_constant()

void ImpedanceBC::update_constant ( SparseSystem & system,
std::vector< double > & parameters )
overridevirtual

Assemble constant Jacobian contributions.

Parameters
systemGlobal sparse system
parametersCurrent parameter values

Reimplemented from Block.

◆ update_time()

void ImpedanceBC::update_time ( SparseSystem & system,
std::vector< double > & parameters )
overridevirtual

Assemble time-dependent residual contributions.

Parameters
systemGlobal sparse system
parametersCurrent parameter values

Reimplemented from Block.

Member Data Documentation

◆ num_triplets

TripletsContributions ImpedanceBC::num_triplets {2, 0, 0}

Nonzero triplet counts contributed by this block.


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