openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
ionics.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: LicenseRef-APL-1.1
3 
12 #ifndef _IONICS_H
13 #define _IONICS_H
14 
15 #include "physics_types.h"
16 #include "sim_utils.h"
17 #include "stimulate.h"
18 #include "IGBheader.h"
19 #include "timers.h"
20 
21 #include "sf_interface.h"
22 #include "MULTI_ION_IF.h"
23 #include "sv_init.h"
24 
25 namespace opencarp {
26 
27 
49 void region_mask(mesh_t meshspec, SF::vector<RegionSpecs> & regspec,
50  SF::vector<int> & regionIDs, bool mask_elem, const char* reglist,
51  FILE_SPEC logger);
52 
65 void override_region_mask(mesh_t meshspec, SF::vector<int> & regionIDs,
66  const std::string & filename, int num_regions);
67 
77 void dump_region_mask(mesh_t meshspec, const SF::vector<int> & regionIDs, const char* reglist);
78 
79 class Ionics : public Basic_physic
80 {
81  public:
84 
86 
87  Ionics(mesh_t gid) : ion_domain(gid)
88  {
89  switch(ion_domain) {
90  case intra_elec_msh:
91  name = "Myocard Ionics"; break;
92  default:
93  name = "Ionics"; break;
94  }
95  }
96 
97  void initialize();
98  void destroy();
99  void compute_step();
100  void output_step();
101  ~Ionics() = default;
102 
104  double timer_val(const int timer_id);
106  std::string timer_unit(const int timer_id);
107 
108  private:
128  double setup_MIIF(limpet::node_count_t nnodes, int nreg, IMPregion* impreg, int* mask,
129  const char *start_fn, int numadjust, IMPVariableAdjustment *adjust,
130  double time_step, bool close);
131 
132 };
133 
143 
147 struct sv_data {
148  char* name;
149  char** imps;
150  char** svNames;
151  int* svInds;
152  int* svSizes;
153  int* svOff;
154  int* plugin_idx;
156  void** getsv;
158  char* units;
159  float bogus;
160 };
161 
162 struct gvec_data {
163  unsigned int nRegs;
164  bool inclPS;
166  bool rm_dumps;
167 };
168 
169 void init_sv_gvec(gvec_data& GVs, limpet::MULTI_IF* miif, sf_vec & tmpl,
170  igb_output_manager & output_manager);
171 void assemble_sv_gvec(gvec_data & gvecs, limpet::MULTI_IF *miif);
172 }
173 #endif
Define multiple ionic models to be used in different regions.
A vector storing arbitrary data.
Definition: SF_vector.h:28
Represents the ionic model and plug-in (IMP) data structure.
Definition: ION_IF.h:168
The abstract physics interface we can use to trigger all physics.
Definition: physics_types.h:44
const char * name
The name of the physic, each physic should have one.
Definition: physics_types.h:47
void output_step()
Definition: ionics.cc:42
Ionics(mesh_t gid)
Definition: ionics.h:87
mesh_t ion_domain
Definition: ionics.h:83
generic_timing_stats comp_stats
Definition: ionics.h:85
limpet::MULTI_IF * miif
Definition: ionics.h:82
void compute_step()
Definition: ionics.cc:20
void initialize()
Definition: ionics.cc:45
void destroy()
Definition: ionics.cc:37
std::string timer_unit(const int timer_id)
figure out units of a signal linked to a given timer
Definition: ionics.cc:543
double timer_val(const int timer_id)
figure out current value of a signal linked to a given timer
Definition: ionics.cc:535
~Ionics()=default
SF_real GlobalData_t
Definition: limpet_types.h:12
opencarp::local_index_t node_count_t
Definition: limpet_types.h:14
opencarp::local_index_t node_index_t
Definition: limpet_types.h:13
void compute_IIF(limpet::IonIfBase &pIF, limpet::GlobalData_t **impdata, limpet::node_index_t n)
Definition: ionics.cc:549
void region_mask(mesh_t meshspec, SF::vector< RegionSpecs > &regspec, SF::vector< int > &regionIDs, bool mask_elem, const char *reglist, FILE_SPEC logger)
classify elements/points as belonging to a region
Definition: ionics.cc:367
void override_region_mask(mesh_t meshspec, SF::vector< int > &regionIDs, const std::string &filename, int num_regions)
directly assign specific points to a region, bypassing region_mask()'s element-tag-derived "highest t...
Definition: ionics.cc:452
void init_sv_gvec(gvec_data &GVs, limpet::MULTI_IF *miif, sf_vec &tmpl, igb_output_manager &output_manager)
Definition: ionics.cc:652
void assemble_sv_gvec(gvec_data &gvecs, limpet::MULTI_IF *miif)
Definition: ionics.cc:723
void dump_region_mask(mesh_t meshspec, const SF::vector< int > &regionIDs, const char *reglist)
dump a nodal region mask as produced by region_mask() to reglist+".dat"
Definition: ionics.cc:513
mesh_t
The enum identifying the different meshes we might want to load.
Definition: sf_interface.h:44
@ intra_elec_msh
Definition: sf_interface.h:45
file_desc * FILE_SPEC
Definition: basics.h:126
Basic physics types.
Interface to SlimFem.
Simulator-level utility execution control functions.
Electrical stimulation functions.
File descriptor struct.
Definition: basics.h:121
for analysis of the #iterations to solve CG
Definition: timers.h:74
SF::vector< sv_data > vecs
store sv dump indices for global vectors
Definition: ionics.h:165
unsigned int nRegs
number of imp regions
Definition: ionics.h:163
bool inclPS
include PS if exists
Definition: ionics.h:164
bool rm_dumps
remove intermediate state variable dump files
Definition: ionics.h:166
float bogus
value indicating sv not in region
Definition: ionics.h:159
void ** getsv
functions to retrieve sv
Definition: ionics.h:156
int * svInds
store sv dump indices for each global vector
Definition: ionics.h:151
char * name
Name of global composite sv vector.
Definition: ionics.h:148
int * plugin_idx
per-region plugin index in the IMP's plugin list, or -1 for the base IMP
Definition: ionics.h:154
int * svOff
sv size in bytes
Definition: ionics.h:153
FILE_SPEC outf
output file
Definition: ionics.h:155
char ** svNames
sv names of components forming global vector
Definition: ionics.h:150
int * svSizes
sv size in bytes
Definition: ionics.h:152
char ** imps
Name of imp to which sv belongs.
Definition: ionics.h:149
char * units
units of sv
Definition: ionics.h:158
sf_vec * ordered
vector in which to place ordered data
Definition: ionics.h:157