openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
ionics.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
27 #ifndef _IONICS_H
28 #define _IONICS_H
29 
30 #include "physics_types.h"
31 #include "sim_utils.h"
32 #include "stimulate.h"
33 #include "IGBheader.h"
34 #include "timers.h"
35 
36 #include "sf_interface.h"
37 #include "MULTI_ION_IF.h"
38 #include "sv_init.h"
39 
40 namespace opencarp {
41 
42 
60 void region_mask(mesh_t meshspec, SF::vector<RegionSpecs> & regspec,
61  SF::vector<int> & regionIDs, bool mask_elem, const char* reglist,
62  bool warn_on_default_tags = true);
63 
64 class Ionics : public Basic_physic
65 {
66  public:
69 
71 
72  Ionics(mesh_t gid) : ion_domain(gid)
73  {
74  switch(ion_domain) {
75  case intra_elec_msh:
76  name = "Myocard Ionics"; break;
77  default:
78  name = "Ionics"; break;
79  }
80  }
81 
82  void initialize();
83  void destroy();
84  void compute_step();
85  void output_step();
86  ~Ionics() = default;
87 
89  double timer_val(const int timer_id);
91  std::string timer_unit(const int timer_id);
92 
93  private:
113  double setup_MIIF(limpet::node_count_t nnodes, int nreg, IMPregion* impreg, int* mask,
114  const char *start_fn, int numadjust, IMPVariableAdjustment *adjust,
115  double time_step, bool close);
116 
117 };
118 
128 
132 struct sv_data {
133  char* name;
134  char** imps;
135  char** svNames;
136  int* svInds;
137  int* svSizes;
138  int* svOff;
140  void** getsv;
142  char* units;
143  float bogus;
144 };
145 
146 struct gvec_data {
147  unsigned int nRegs;
148  bool inclPS;
151  bool rm_dumps;
152 };
153 
154 void init_sv_gvec(gvec_data& GVs, limpet::MULTI_IF* miif, sf_vec & tmpl,
155  igb_output_manager & output_manager);
156 void assemble_sv_gvec(gvec_data & gvecs, limpet::MULTI_IF *miif);
157 }
158 #endif
Define multiple ionic models to be used in different regions.
A vector storing arbitrary data.
Definition: SF_vector.h:43
Represents the ionic model and plug-in (IMP) data structure.
Definition: ION_IF.h:139
The abstract physics interface we can use to trigger all physics.
Definition: physics_types.h:59
const char * name
The name of the physic, each physic should have one.
Definition: physics_types.h:62
void output_step()
Definition: ionics.cc:57
Ionics(mesh_t gid)
Definition: ionics.h:72
mesh_t ion_domain
Definition: ionics.h:68
generic_timing_stats comp_stats
Definition: ionics.h:70
limpet::MULTI_IF * miif
Definition: ionics.h:67
void compute_step()
Definition: ionics.cc:35
void initialize()
Definition: ionics.cc:60
void destroy()
Definition: ionics.cc:52
std::string timer_unit(const int timer_id)
figure out units of a signal linked to a given timer
Definition: ionics.cc:502
double timer_val(const int timer_id)
figure out current value of a signal linked to a given timer
Definition: ionics.cc:494
~Ionics()=default
SF_real GlobalData_t
Definition: limpet_types.h:27
opencarp::local_index_t node_count_t
Definition: limpet_types.h:29
opencarp::local_index_t node_index_t
Definition: limpet_types.h:28
void compute_IIF(limpet::IonIfBase &pIF, limpet::GlobalData_t **impdata, limpet::node_index_t n)
Definition: ionics.cc:508
void region_mask(mesh_t meshspec, SF::vector< RegionSpecs > &regspec, SF::vector< int > &regionIDs, bool mask_elem, const char *reglist, bool warn_on_default_tags)
classify elements/points as belonging to a region
Definition: ionics.cc:404
void init_sv_gvec(gvec_data &GVs, limpet::MULTI_IF *miif, sf_vec &tmpl, igb_output_manager &output_manager)
Definition: ionics.cc:610
void assemble_sv_gvec(gvec_data &gvecs, limpet::MULTI_IF *miif)
Definition: ionics.cc:681
mesh_t
The enum identifying the different meshes we might want to load.
Definition: sf_interface.h:59
@ intra_elec_msh
Definition: sf_interface.h:60
Basic physics types.
Interface to SlimFem.
Simulator-level utility execution control functions.
Electrical stimulation functions.
File descriptor struct.
Definition: basics.h:135
for analysis of the #iterations to solve CG
Definition: timers.h:69
SF::vector< int > plugin_idx
if we use a plugin, its index in the plugins list of the IMP will be stored here, else -1.
Definition: ionics.h:150
SF::vector< sv_data > vecs
store sv dump indices for global vectors
Definition: ionics.h:149
unsigned int nRegs
number of imp regions
Definition: ionics.h:147
bool inclPS
include PS if exists
Definition: ionics.h:148
bool rm_dumps
remove intermediate state variable dump files
Definition: ionics.h:151
float bogus
value indicating sv not in region
Definition: ionics.h:143
void ** getsv
functions to retrieve sv
Definition: ionics.h:140
int * svInds
store sv dump indices for each global vector
Definition: ionics.h:136
char * name
Name of global composite sv vector.
Definition: ionics.h:133
int * svOff
sv size in bytes
Definition: ionics.h:138
FILE_SPEC outf
output file
Definition: ionics.h:139
char ** svNames
sv names of components forming global vector
Definition: ionics.h:135
int * svSizes
sv size in bytes
Definition: ionics.h:137
char ** imps
Name of imp to which sv belongs.
Definition: ionics.h:134
char * units
units of sv
Definition: ionics.h:142
sf_vec * ordered
vector in which to place ordered data
Definition: ionics.h:141