openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
opencarp::eikonal_solver Class Reference

#include <electrics_eikonal.h>

Collaboration diagram for opencarp::eikonal_solver:

Classes

struct  diffusion_current
 

Public Types

enum  Idiff_t { FOOT = 0 , GAUSS = 1 }
 

Public Member Functions

 eikonal_solver ()
 
 ~eikonal_solver ()
 
void init ()
 Initialize vectors and variables in the eikonal_solver class. More...
 
bool determine_model_to_run (double &time)
 Determine the next model to run in the alternation between RD and Eikonal. More...
 
void set_stimuli (SF::vector< stimulus > &stimuli)
 Simple setter for stimulus vector. More...
 
void clean_list ()
 Clean the list of nodes by resetting their status and tracking changes based on the time step of the RD model. More...
 
void save_eikonal_state (const char *tsav_ext)
 Save the current state of variables related to the Eikonal simulation to a file to initialize a future simulation. More...
 
void update_repolarization_times (const Ionics &ion)
 Estimates initial repolarization times (T_R) in Step D of DREAM. More...
 
void cycFIM ()
 Implementation of the cyclical fast iterative method used in step A of the DREAM model. More...
 
void FIM ()
 Standard fast iterative method to solve eikonal equation with active list approach. More...
 
void update_repolarization_times_from_rd (sf_vec &Vmv, sf_vec &Vmv_old, double time)
 Updates node repolarization times based on transmembrane voltage crossing. More...
 
void compute_diffusion_current (const double &time, sf_vec &vm)
 Computes the stimulus-driven diffusion current at mesh nodes. More...
 
void init_imp_region_properties ()
 Initializes diffusion current models and CV restitution parameters per mesh node. More...
 

Public Attributes

const double inf = std::numeric_limits<double>::infinity()
 
node_stats nodeData
 
Idiff_t Idiff_tech = FOOT
 
SF::vector< diffusion_currentdiff_cur
 
SF::vector< SF_realT_A
 
SF::vector< SF_realT_R
 
SF::vector< SF_realTA_old
 
SF::vector< SF_realD_I
 
SF::vector< mesh_int_tList
 
SF::vector< mesh_int_tnum_changes
 
SF::vector< mesh_int_tnReadded2List
 
SF::vector< mesh_int_tstim_status
 
SF::vector< mesh_int_tStimulusPoints
 
SF::vector< SF_realStimulusTimes
 
mesh_int_t Index_currStim
 
SF_real actMIN = 0
 
SF_real actMAX = 0
 
mesh_int_t MESH_SIZE
 
bool twoFib
 
size_t num_pts
 
SF::vector< mesh_int_te2n_con
 
SF::vector< mesh_int_telem_start
 
std::vector< mesh_int_tn2n_connect
 
std::vector< mesh_int_tn2n_dsp
 
SF::vector< mesh_int_te2n_cnt
 
SF::vector< mesh_int_tn2e_cnt
 
SF::vector< mesh_int_tn2e_con
 
SF::vector< mesh_int_tn2e_dsp
 
std::vector< SF::dmat< double > > S
 
std::vector< double > CV_L
 
SF::vector< SF_realrho_cvrest
 
SF::vector< SF_realkappa_cvrest
 
SF::vector< SF_realtheta_cvrest
 
SF::vector< SF_realdenom_cvrest
 
sf_vecIdiff = nullptr
 
sf_vecAT = nullptr
 
sf_vecRT = nullptr
 
eikonal_solver_stats stats
 

Detailed Description

Definition at line 82 of file electrics_eikonal.h.

Member Enumeration Documentation

◆ Idiff_t

Enumerator
FOOT 
GAUSS 

Definition at line 93 of file electrics_eikonal.h.

Constructor & Destructor Documentation

◆ eikonal_solver()

opencarp::eikonal_solver::eikonal_solver ( )
inline

Definition at line 85 of file electrics_eikonal.h.

◆ ~eikonal_solver()

opencarp::eikonal_solver::~eikonal_solver ( )
inline

Definition at line 146 of file electrics_eikonal.h.

Member Function Documentation

◆ clean_list()

void opencarp::eikonal_solver::clean_list ( )

Clean the list of nodes by resetting their status and tracking changes based on the time step of the RD model.

This function iterates through a list of nodes and checks if their activation time (T_A[j]) is less than the current time managed by user_globals::tm_manager->time. If so, it performs the following operations:

  • Updates the old activation time (TA_old[j]) with the current activation time (T_A[j]).
  • Resets the status of the node to 0.
  • Resets the change counter of number of times the node reenter the list (num_changes2[j]) to 0.
  • If the node is marked as active in the list (List[j] == 1), it marks it as inactive (List[j] = 0).
Note
The function depends on the existence of the global variables List, T_A, TA_old, Status, and num_changes2. user_globals::tm_manager->time for the current time threshold. It makes sure that activation times behind the time step of the RD model are not considered.

Definition at line 1428 of file electrics_eikonal.cc.

◆ compute_diffusion_current()

void opencarp::eikonal_solver::compute_diffusion_current ( const double &  time,
sf_vec vm 
)

Computes the stimulus-driven diffusion current at mesh nodes.

This function evaluates the time-dependent diffusion (stimulus) current for algebraic nodes in the mesh, based on the activation times and node-specific diffusion current models. The result is stored in Idiff for later use in the parabolic solver.

Parameters
timeCurrent simulation time.
vmVector of nodal transmembrane voltages, used to evaluate voltage-dependent stimulus models.
  • Iterates over all algebraic nodes in the mesh.
  • For each node:
    • Only proceeds if the node is within its stimulus-active window:

      \[ TA \leq time \leq TA + 5 \]

      and List[node] == 0.
    • Computes time since activation:

      \[ dT = time - TA. \]

    • Selects the node-specific diffusion current model:
      • GAUSS: Three Gaussian pulses with parameters $ \alpha_i, \beta_i, \gamma_i $, producing:

        \[ I = \sum_{i=1}^3 \alpha_i \exp\!\Big(-\Big(\frac{dT - \beta_i}{\gamma_i}\Big)^2\Big). \]

      • Default: Exponential form with on/off gating (foot current):

        \[ I = \frac{A_F}{\tau_F} \exp(dT / \tau_F) \cdot e_{\text{on}} \cdot e_{\text{off}}, \]

        where:
        • $ e_{\text{on}} = 1 $ if dT ≥ 0 else 0,
        • $ e_{\text{off}} = 1 $ if vm < V_th else 0.
  • The computed current is written to Idiff at the PETSc local index corresponding to the node.

Notes

  • Execution time is accumulated in stats.slvtime_B.
See also
diff_cur, Idiff, T_A

Definition at line 1532 of file electrics_eikonal.cc.

◆ cycFIM()

void opencarp::eikonal_solver::cycFIM ( )

Implementation of the cyclical fast iterative method used in step A of the DREAM model.

Definition at line 1001 of file electrics_eikonal.cc.

◆ determine_model_to_run()

bool opencarp::eikonal_solver::determine_model_to_run ( double &  time)

Determine the next model to run in the alternation between RD and Eikonal.

This function decides which model to run next based on the DREAM condition. If the output value is true, it will run the RD model; if false, it will run the Eikonal model.

Parameters
timeThe current time step in the RD model used to evaluate the conditions.
Returns
A boolean indicating whether to run the RD model (true) or the Eikonal model (false).

Definition at line 1397 of file electrics_eikonal.cc.

◆ FIM()

void opencarp::eikonal_solver::FIM ( )

Standard fast iterative method to solve eikonal equation with active list approach.

Definition at line 902 of file electrics_eikonal.cc.

◆ init()

void opencarp::eikonal_solver::init ( )

Initialize vectors and variables in the eikonal_solver class.

Definition at line 583 of file electrics_eikonal.cc.

◆ init_imp_region_properties()

void opencarp::eikonal_solver::init_imp_region_properties ( )

Initializes diffusion current models and CV restitution parameters per mesh node.

This function prepares per-node properties required for computing stimulus-driven diffusion currents and conduction velocity restitution effects, based on region-specific parameters defined in param_globals::imp_region.

  • Allocates and resizes per-node storage arrays:
    • diff_cur : diffusion current model parameters
    • rho_cvrest, kappa_cvrest, theta_cvrest, denom_cvrest : restitution parameters
  • Builds a mapping from local nodes to imp regions:
    • If only one imp region exists, all nodes are assigned to region 0.
    • Otherwise, calls region_mask() to resolve region IDs from tags.
  • For each node (in parallel):
    • Reads region-specific stimulus current model:
      • GAUSS model: initializes three Gaussian terms ( $\alpha_i, \beta_i, \gamma_i$).
      • Default model: initializes exponential stimulus parameters ( $A_F, \tau_F, V_{th}$).
    • Reads CV restitution parameters:
      • $\rho, \kappa, \theta$
      • Precomputes $\text{denom} = \log(\rho) / \psi$
  • Logs a warning if an imp region has incomplete subregion IDs.
  • Prints timing information if output_level is enabled.
Note
Each vertex is initialized exactly once in parallel.
See also
compute_diffusion_current, diff_cur, rho_cvrest, kappa_cvrest, theta_cvrest, denom_cvrest

Definition at line 649 of file electrics_eikonal.cc.

◆ save_eikonal_state()

void opencarp::eikonal_solver::save_eikonal_state ( const char *  tsav_ext)

Save the current state of variables related to the Eikonal simulation to a file to initialize a future simulation.

This function saves the current state of variables, including activation times (T_A), repolazitaion times (T_R), old activation times (TA_old), and other required variables

The data is saved in a structured format where each line corresponds to a node: The file is named based on the param_globals::write_statef and tsav_ext parameters.

Parameters
tsav_extExtension to append to the file name.

Definition at line 1578 of file electrics_eikonal.cc.

◆ set_stimuli()

void opencarp::eikonal_solver::set_stimuli ( SF::vector< stimulus > &  stimuli)
inline

Simple setter for stimulus vector.

Definition at line 168 of file electrics_eikonal.h.

◆ update_repolarization_times()

void opencarp::eikonal_solver::update_repolarization_times ( const Ionics ion)

Estimates initial repolarization times (T_R) in Step D of DREAM.

This function performs a short run of the ionic model (not a full RD simulation) to update T_R. It only iterates over nodes that do not have an up to date value of T_R. When detected, the current simulation time is stored in T_R[ind_nodes]. The function resets state variables to their pre-call values.

Parameters
ionThe Ionics object containing information about the ionic model.

Definition at line 1466 of file electrics_eikonal.cc.

◆ update_repolarization_times_from_rd()

void opencarp::eikonal_solver::update_repolarization_times_from_rd ( sf_vec Vmv,
sf_vec Vmv_old,
double  time 
)

Updates node repolarization times based on transmembrane voltage crossing.

This function scans all mesh nodes and records the time at which each node’s transmembrane potential falls below a given threshold, marking the end of its action potential (repolarization). Uses Vm from the parabolic solver.

Parameters
VmvVector of current transmembrane voltages at all nodes.
Vmv_oldVector of transmembrane voltages from the previous timestep.
timeCurrent simulation time, recorded as the repolarization time for nodes that cross the threshold during this step.
  • The threshold value is taken from param_globals::dream.repol_time_thresh.
  • For each node ind_nodes:
    • If Vmv_old[ind_nodes] ≥ threshold and Vmv[ind_nodes] < threshold, the repolarization time T_R[ind_nodes] is set to time.
  • Memory pointers to Vmv and Vmv_old are explicitly managed via ptr() and release_ptr().
See also
T_R

Definition at line 1449 of file electrics_eikonal.cc.

Member Data Documentation

◆ actMAX

SF_real opencarp::eikonal_solver::actMAX = 0

Definition at line 120 of file electrics_eikonal.h.

◆ actMIN

SF_real opencarp::eikonal_solver::actMIN = 0

Definition at line 120 of file electrics_eikonal.h.

◆ AT

sf_vec* opencarp::eikonal_solver::AT = nullptr

Definition at line 140 of file electrics_eikonal.h.

◆ CV_L

std::vector<double> opencarp::eikonal_solver::CV_L

Definition at line 133 of file electrics_eikonal.h.

◆ D_I

SF::vector<SF_real> opencarp::eikonal_solver::D_I

Definition at line 115 of file electrics_eikonal.h.

◆ denom_cvrest

SF::vector<SF_real> opencarp::eikonal_solver::denom_cvrest

Definition at line 136 of file electrics_eikonal.h.

◆ diff_cur

SF::vector<diffusion_current> opencarp::eikonal_solver::diff_cur

Definition at line 114 of file electrics_eikonal.h.

◆ e2n_cnt

SF::vector<mesh_int_t> opencarp::eikonal_solver::e2n_cnt

Definition at line 129 of file electrics_eikonal.h.

◆ e2n_con

SF::vector<mesh_int_t> opencarp::eikonal_solver::e2n_con

Definition at line 126 of file electrics_eikonal.h.

◆ elem_start

SF::vector<mesh_int_t> opencarp::eikonal_solver::elem_start

Definition at line 127 of file electrics_eikonal.h.

◆ Idiff

sf_vec* opencarp::eikonal_solver::Idiff = nullptr

Definition at line 139 of file electrics_eikonal.h.

◆ Idiff_tech

Idiff_t opencarp::eikonal_solver::Idiff_tech = FOOT

Definition at line 95 of file electrics_eikonal.h.

◆ Index_currStim

mesh_int_t opencarp::eikonal_solver::Index_currStim

Definition at line 119 of file electrics_eikonal.h.

◆ inf

const double opencarp::eikonal_solver::inf = std::numeric_limits<double>::infinity()

Definition at line 87 of file electrics_eikonal.h.

◆ kappa_cvrest

SF::vector<SF_real> opencarp::eikonal_solver::kappa_cvrest

Definition at line 136 of file electrics_eikonal.h.

◆ List

SF::vector<mesh_int_t> opencarp::eikonal_solver::List

Definition at line 116 of file electrics_eikonal.h.

◆ MESH_SIZE

mesh_int_t opencarp::eikonal_solver::MESH_SIZE

Definition at line 123 of file electrics_eikonal.h.

◆ n2e_cnt

SF::vector<mesh_int_t> opencarp::eikonal_solver::n2e_cnt

Definition at line 129 of file electrics_eikonal.h.

◆ n2e_con

SF::vector<mesh_int_t> opencarp::eikonal_solver::n2e_con

Definition at line 129 of file electrics_eikonal.h.

◆ n2e_dsp

SF::vector<mesh_int_t> opencarp::eikonal_solver::n2e_dsp

Definition at line 129 of file electrics_eikonal.h.

◆ n2n_connect

std::vector<mesh_int_t> opencarp::eikonal_solver::n2n_connect

Definition at line 128 of file electrics_eikonal.h.

◆ n2n_dsp

std::vector<mesh_int_t> opencarp::eikonal_solver::n2n_dsp

Definition at line 128 of file electrics_eikonal.h.

◆ nodeData

node_stats opencarp::eikonal_solver::nodeData

Definition at line 90 of file electrics_eikonal.h.

◆ nReadded2List

SF::vector<mesh_int_t> opencarp::eikonal_solver::nReadded2List

Definition at line 116 of file electrics_eikonal.h.

◆ num_changes

SF::vector<mesh_int_t> opencarp::eikonal_solver::num_changes

Definition at line 116 of file electrics_eikonal.h.

◆ num_pts

size_t opencarp::eikonal_solver::num_pts

Definition at line 125 of file electrics_eikonal.h.

◆ rho_cvrest

SF::vector<SF_real> opencarp::eikonal_solver::rho_cvrest

Definition at line 136 of file electrics_eikonal.h.

◆ RT

sf_vec* opencarp::eikonal_solver::RT = nullptr

Definition at line 141 of file electrics_eikonal.h.

◆ S

std::vector<SF::dmat<double> > opencarp::eikonal_solver::S

Definition at line 132 of file electrics_eikonal.h.

◆ stats

eikonal_solver_stats opencarp::eikonal_solver::stats

Definition at line 144 of file electrics_eikonal.h.

◆ stim_status

SF::vector<mesh_int_t> opencarp::eikonal_solver::stim_status

Definition at line 116 of file electrics_eikonal.h.

◆ StimulusPoints

SF::vector<mesh_int_t> opencarp::eikonal_solver::StimulusPoints

Definition at line 117 of file electrics_eikonal.h.

◆ StimulusTimes

SF::vector<SF_real> opencarp::eikonal_solver::StimulusTimes

Definition at line 118 of file electrics_eikonal.h.

◆ T_A

SF::vector<SF_real> opencarp::eikonal_solver::T_A

Definition at line 115 of file electrics_eikonal.h.

◆ T_R

SF::vector<SF_real> opencarp::eikonal_solver::T_R

Definition at line 115 of file electrics_eikonal.h.

◆ TA_old

SF::vector<SF_real> opencarp::eikonal_solver::TA_old

Definition at line 115 of file electrics_eikonal.h.

◆ theta_cvrest

SF::vector<SF_real> opencarp::eikonal_solver::theta_cvrest

Definition at line 136 of file electrics_eikonal.h.

◆ twoFib

bool opencarp::eikonal_solver::twoFib

Definition at line 124 of file electrics_eikonal.h.


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