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,
76  const hashmap::unordered_set<int> & intra_tags,
78  SF::vector<int> & regionIDs, bool mask_elem, const char* reglist);
79 
80 class IonicsOnFace : public Basic_physic
81 {
82  public:
83  limpet::MULTI_IF* miif = NULL;
84  mesh_t ion_domain;
85 
86  generic_timing_stats comp_stats;
87 
89  std::pair<SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>,
90  SF::emi_face<mesh_int_t,SF::tuple<mesh_int_t>>>> line_face;
92  std::pair<SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>,
93  SF::emi_face<mesh_int_t,SF::triple<mesh_int_t>>>> tri_face;
95  std::pair<SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>,
96  SF::emi_face<mesh_int_t,SF::quadruple<mesh_int_t>>>> quad_face;
97 
99 
100  std::vector<std::string> tags_data;
101 
102  hashmap::unordered_set<int> intra_tags;
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_face_region_data(hashmap::unordered_set<int> intra_tags_,
137  hashmap::unordered_map<mesh_int_t, std::pair<mesh_int_t, mesh_int_t>> & map_elem_uniqueFace_to_tags_)
138  {
139  intra_tags = intra_tags_;
140  map_elem_uniqueFace_to_tags = map_elem_uniqueFace_to_tags_;
141  }
142  void initialize();
143  void destroy();
144  void compute_step();
145  void output_step();
146  ~IonicsOnFace() = default;
147 
149  double timer_val(const int timer_id);
151  std::string timer_unit(const int timer_id);
152 
153  private:
173  double setup_MIIF(int nnodes, int nreg, IMPregion_EMI* impreg, int* mask,
174  const char *start_fn, int numadjust, IMPVariableAdjustment *adjust,
175  double time_step, bool close);
176 
177 };
178 
187 void compute_IIF_OnFace(limpet::IonIfBase& pIF, limpet::GlobalData_t** impdata, int n);
188 
192 struct sv_data_onFace {
193  char* name;
194  char** imps;
195  char** svNames;
196  int* svInds;
197  int* svSizes;
198  int* svOff;
199  FILE_SPEC outf;
200  void** getsv;
201  sf_vec* ordered;
202  char* units;
203  float bogus;
204 };
205 
206 struct gvec_data_OnFace {
207  unsigned int nRegs;
208  bool inclPS;
210  bool rm_dumps;
211 };
212 
213 void init_sv_gvec_onFace(gvec_data_OnFace& GVs, limpet::MULTI_IF* miif, sf_vec & tmpl,
214  igb_output_manager & output_manager);
215 void assemble_sv_gvec_onFace(gvec_data_OnFace & gvecs, limpet::MULTI_IF *miif);
216 }
217 #endif
218 #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.