openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
ionicsOnFace.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 #if WITH_EMI_MODEL
28 
29 #ifndef _IONICSONFACE_H
30 #define _IONICSONFACE_H
31 
32 #include "physics_types.h"
33 #include "sim_utils.h"
34 #include "stimulate.h"
35 #include "IGBheader.h"
36 #include "timers.h"
37 
38 #include "sf_interface.h"
39 #include "MULTI_ION_IF.h"
40 #include "sv_init.h"
41 
42 namespace opencarp {
43 
44 
63 void region_mask_onFace(mesh_t meshspec,
64  std::vector<std::string> & tags_data,
66  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
67  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> & line_face,
69  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
70  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> & tri_face,
72  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
73  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> & quad_face,
74  hashmap::unordered_map<std::pair<mesh_int_t,mesh_int_t>, mesh_int_t> & map_vertex_tag_to_dof,
75  hashmap::unordered_map<mesh_int_t, std::pair<mesh_int_t, mesh_int_t>> & map_elem_uniqueFace_to_tags,
77  SF::vector<int> & regionIDs, bool mask_elem, const char* reglist);
78 
79 class IonicsOnFace : public Basic_physic
80 {
81  public:
82  limpet::MULTI_IF* miif = NULL;
83  mesh_t ion_domain;
84 
85  generic_timing_stats comp_stats;
86 
88  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
89  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> line_face;
91  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
92  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> tri_face;
94  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
95  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> quad_face;
96 
98 
99  std::vector<std::string> tags_data;
100 
101  std::set<std::pair<mesh_int_t,mesh_int_t>> membraneFace_default;
102  std::set<std::pair<mesh_int_t,mesh_int_t>> gapjunctionFace_default;
104 
105  IonicsOnFace(mesh_t gid) : ion_domain(gid)
106  {
107  switch(ion_domain) {
108  case intra_elec_msh:
109  name = "Myocard IonicsOnFace"; break;
110  default:
111  name = "IonicsOnFace"; break;
112  }
113  }
114 
115  void set_tags_onFace(std::vector<std::string> & tags_data_)
116  {
117  tags_data.assign(tags_data_.begin(),tags_data_.end());
118  }
119 
120  void set_surface_mesh_data( hashmap::unordered_map<SF::tuple<mesh_int_t>,
121  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
122  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> & line_face_,
124  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
125  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> & tri_face_,
127  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
128  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> & quad_face_,
129  hashmap::unordered_map<std::pair<mesh_int_t,mesh_int_t>, mesh_int_t> & map_vertex_tag_to_dof_){
130  line_face = line_face_;
131  tri_face = tri_face_;
132  quad_face = quad_face_;
133  map_vertex_tag_to_dof = map_vertex_tag_to_dof_;
134  }
135 
136  void set_default_interface_pairs(std::set<std::pair<mesh_int_t,mesh_int_t>> membraneFace_default_,
137  std::set<std::pair<mesh_int_t,mesh_int_t>> gapjunctionFace_default_,
138  hashmap::unordered_map<mesh_int_t, std::pair<mesh_int_t, mesh_int_t>> & map_elem_uniqueFace_to_tags_)
139  {
140 
141  membraneFace_default = membraneFace_default_;
142  gapjunctionFace_default = gapjunctionFace_default_;
143  map_elem_uniqueFace_to_tags = map_elem_uniqueFace_to_tags_;
144  }
145  void initialize();
146  void destroy();
147  void compute_step();
148  void output_step();
149  ~IonicsOnFace() = default;
150 
152  double timer_val(const int timer_id);
154  std::string timer_unit(const int timer_id);
155 
156  private:
176  double setup_MIIF(int nnodes, int nreg, IMPregion_EMI* impreg, int* mask,
177  const char *start_fn, int numadjust, IMPVariableAdjustment *adjust,
178  double time_step, bool close);
179 
180 };
181 
190 void compute_IIF_OnFace(limpet::IonIfBase& pIF, limpet::GlobalData_t** impdata, int n);
191 
195 struct sv_data_onFace {
196  char* name;
197  char** imps;
198  char** svNames;
199  int* svInds;
200  int* svSizes;
201  int* svOff;
202  FILE_SPEC outf;
203  void** getsv;
204  sf_vec* ordered;
205  char* units;
206  float bogus;
207 };
208 
209 struct gvec_data_OnFace {
210  unsigned int nRegs;
211  bool inclPS;
213  bool rm_dumps;
214 };
215 
216 void init_sv_gvec_onFace(gvec_data_OnFace& GVs, limpet::MULTI_IF* miif, sf_vec & tmpl,
217  igb_output_manager & output_manager);
218 void assemble_sv_gvec_onFace(gvec_data_OnFace & gvecs, limpet::MULTI_IF *miif);
219 }
220 #endif
221 #endif
Define multiple ionic models to be used in different regions.
int mesh_int_t
Definition: SF_container.h:46
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
SF_real GlobalData_t
Definition: limpet_types.h:27
std::map< int, std::string > units
Definition: stimulate.cc:41
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
SF::abstract_vector< SF_int, SF_real > sf_vec
Definition: sf_interface.h:50
file_desc * FILE_SPEC
Definition: basics.h:138
Basic physics types.
Interface to SlimFem.
Simulator-level utility execution control functions.
Electrical stimulation functions.