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 
68 void region_mask_onFace(mesh_t meshspec,
69  std::vector<std::string> & tags_data,
71  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
72  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> & line_face,
74  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
75  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> & tri_face,
77  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
78  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> & quad_face,
79  hashmap::unordered_map<std::pair<mesh_int_t,mesh_int_t>, mesh_int_t> & map_vertex_tag_to_dof,
80  hashmap::unordered_map<mesh_int_t, std::pair<mesh_int_t, mesh_int_t>> & map_elem_uniqueFace_to_tags,
81  const hashmap::unordered_set<int> & intra_tags,
83  SF::vector<int> & regionIDs, bool mask_elem, const char* reglist);
84 
85 class IonicsOnFace : public Basic_physic
86 {
87  public:
88  limpet::MULTI_IF* miif = NULL;
89  mesh_t ion_domain;
90 
91  generic_timing_stats comp_stats;
92 
94  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
95  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> line_face;
97  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
98  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> tri_face;
100  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
101  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> quad_face;
102 
104 
105  std::vector<std::string> tags_data;
106 
107  hashmap::unordered_set<int> intra_tags;
109 
110  IonicsOnFace(mesh_t gid) : ion_domain(gid)
111  {
112  switch(ion_domain) {
113  case intra_elec_msh:
114  name = "Myocard IonicsOnFace"; break;
115  default:
116  name = "IonicsOnFace"; break;
117  }
118  }
119 
121  void set_tags_onFace(std::vector<std::string> & tags_data_)
122  {
123  tags_data.assign(tags_data_.begin(),tags_data_.end());
124  }
125 
127  void set_surface_mesh_data( hashmap::unordered_map<SF::tuple<mesh_int_t>,
128  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
129  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> & line_face_,
131  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
132  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> & tri_face_,
134  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
135  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> & quad_face_,
136  hashmap::unordered_map<std::pair<mesh_int_t,mesh_int_t>, mesh_int_t> & map_vertex_tag_to_dof_){
137  line_face = line_face_;
138  tri_face = tri_face_;
139  quad_face = quad_face_;
140  map_vertex_tag_to_dof = map_vertex_tag_to_dof_;
141  }
142 
144  void set_face_region_data(hashmap::unordered_set<int> intra_tags_,
145  hashmap::unordered_map<mesh_int_t, std::pair<mesh_int_t, mesh_int_t>> & map_elem_uniqueFace_to_tags_)
146  {
147  intra_tags = intra_tags_;
148  map_elem_uniqueFace_to_tags = map_elem_uniqueFace_to_tags_;
149  }
151  void initialize();
152 
154  void destroy();
155 
157  void compute_step();
158 
160  void output_step();
161  ~IonicsOnFace() = default;
162 
164  double timer_val(const int timer_id);
166  std::string timer_unit(const int timer_id);
167 
168  private:
186  double setup_MIIF(limpet::node_count_t nnodes, int nreg, IMPregion_EMI* impreg, int* mask,
187  const char *start_fn, int numadjust, IMPVariableAdjustment *adjust,
188  double time_step, bool close);
189 
190 };
191 
200 void compute_IIF_OnFace(limpet::IonIfBase& pIF, limpet::GlobalData_t** impdata, limpet::node_index_t n);
201 
204 struct sv_data_onFace {
205  char* name;
206  char** imps;
207  char** svNames;
208  int* svInds;
209  int* svSizes;
210  int* svOff;
211  FILE_SPEC outf;
212  void** getsv;
213  sf_vec* ordered;
214  char* units;
215  float bogus;
216 };
217 
218 struct gvec_data_OnFace {
219  unsigned int nRegs;
220  bool inclPS;
222  bool rm_dumps;
223 };
224 
226 void init_sv_gvec_onFace(gvec_data_OnFace& GVs, limpet::MULTI_IF* miif, sf_vec & tmpl,
227  igb_output_manager & output_manager);
228 
230 void assemble_sv_gvec_onFace(gvec_data_OnFace & gvecs, limpet::MULTI_IF *miif);
231 }
232 #endif
233 #endif
Define multiple ionic models to be used in different regions.
opencarp::local_index_t 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
opencarp::local_index_t node_count_t
Definition: limpet_types.h:29
opencarp::local_index_t node_index_t
Definition: limpet_types.h:28
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:140
Basic physics types.
Interface to SlimFem.
Simulator-level utility execution control functions.
Electrical stimulation functions.