openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
testfem.cc
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 #include <cstdio>
28 #include <csignal>
29 #include <vector>
30 
31 // we set PrMGLOBAL ONLY ONCE. this will initialize the global variables
32 // in only one compilation unit
33 #define PrMGLOBAL
34 #include "simulator.h"
35 #include "numerics.h"
36 #include "physics.h"
37 #include "fem.h"
38 
39 
40 // globals
41 namespace opencarp {
42 namespace user_globals {
46  std::map<mesh_t, sf_mesh> mesh_reg;
48  std::map<SF::quadruple<int>, SF::index_mapping<int> > map_reg;
50  std::map<physic_t, Basic_physic*> physics_reg;
54  std::map<datavec_t, sf_vec*> datavec_reg;
56  FILE* petsc_error_fd = NULL;
58  bool using_legacy_stimuli = false;
59 } // namespace user_globals
60 } // namespace opencarp
61 
62 using namespace opencarp;
63 
64 #undef __FUNCT__
65 #define __FUNCT__ "main"
66 int main(int argc, char** argv)
67 {
68  char *DBfile = NULL; // could be used to pass in ~/.petscrc
69  char *help_msg = NULL;
70  parse_params_cpy(argc, argv);
71  initialize_PETSc(&argc, argv, DBfile, help_msg);
72 
75 
76  // set up meshes
77  std::map<mesh_t, sf_mesh> & mesh_registry = user_globals::mesh_reg;
78  mesh_registry[reference_msh] = sf_mesh();
79  mesh_registry[reference_msh].comm = PETSC_COMM_WORLD;
80  mesh_registry[extra_elec_msh] = sf_mesh();
81 
82  setup_meshes();
83 
84  MaterialType mtype[2];
85  FILE_SPEC logger = f_open("electrics.log", param_globals::experiment != 4 ? "w" : "r");
86 
89  mtype[Electrics::extra_grid].regionIDs, true, "gregion_e");
90 
91  SF::vector<stimulus> stimuli;
92  elliptic_solver ellip_solver;
93  ellip_solver.init();
94  ellip_solver.rebuild_matrices(mtype, stimuli, logger);
95 
97 }
98 
std::map< physic_t, Basic_physic * > physics_reg
the physics
Definition: main.cc:50
description of materal properties in a mesh
Definition: fem_types.h:110
std::map< mesh_t, sf_mesh > mesh_reg
Registry for the different meshes used in a multi-physics simulation.
Definition: main.cc:46
timer_manager * tm_manager
a manager for the various physics timers
Definition: main.cc:52
void setup_petsc_err_log()
set up error logs for PETSc, so that it doesnt print errors to stderr.
Definition: sim_utils.cc:1240
Top-level header file of numerics module.
void check_and_convert_params()
Here we want to put all parameter checks, conversions and modifications that have been littered throu...
Definition: sim_utils.cc:227
void region_mask(mesh_t meshspec, SF::vector< RegionSpecs > &regspec, SF::vector< int > &regionIDs, bool mask_elem, const char *reglist)
classify elements/points as belonging to a region
Definition: ionics.cc:356
bool using_legacy_stimuli
flag storing whether legacy stimuli are used
Definition: main.cc:58
FILE * petsc_error_fd
file descriptor for petsc error output
Definition: main.cc:56
std::map< SF::quadruple< int >, SF::index_mapping< int > > map_reg
Registriy for the inter domain mappings.
Definition: main.cc:48
void cleanup_and_exit()
Definition: sim_utils.cc:1216
Top-level header of FEM module.
void parse_params_cpy(int argc, char **argv)
Initialize input parameters on a copy of the real command line parameters.
Definition: sim_utils.cc:46
void setup_meshes()
Read in the reference mesh and use its data to populate all meshes registered in the mesh registry...
Definition: sim_utils.cc:986
void set_elec_tissue_properties(MaterialType *mtype, Electrics::grid_t g, FILE_SPEC logger)
Fill the RegionSpec of an electrics grid with the associated inputs from the param parameters...
Definition: electrics.cc:100
Index mapping class. This is a bijective mapping.
Definition: SF_container.h:207
File descriptor struct.
Definition: basics.h:133
Top-level header of physics module.
int main(int argc, char **argv)
Definition: testfem.cc:66
A vector storing arbitrary data.
Definition: SF_vector.h:42
std::map< datavec_t, sf_vec * > datavec_reg
important solution vectors from different physics
Definition: main.cc:54
void rebuild_matrices(MaterialType *mtype, SF::vector< stimulus > &stimuli, FILE_SPEC logger)
Definition: electrics.cc:912
SF::meshdata< mesh_int_t, mesh_real_t > sf_mesh
Definition: sf_interface.h:47
centralize time managment and output triggering
Definition: timer_utils.h:73
SF::scatter_registry scatter_reg
Registry for the different scatter objects.
Definition: main.cc:44
The scatterer registry class.
FILE_SPEC f_open(const char *fname, const char *mode)
Open a FILE_SPEC.
Definition: basics.cc:135