openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
testfem.cc
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: LicenseRef-APL-1.1
3 
12 #include <cstdio>
13 #include <csignal>
14 #include <vector>
15 
16 // we set PrMGLOBAL ONLY ONCE. this will initialize the global variables
17 // in only one compilation unit
18 #define PrMGLOBAL
19 #include "simulator.h"
20 #include "numerics.h"
21 #include "physics.h"
22 #include "fem.h"
23 
24 
25 // globals
26 namespace opencarp {
27 namespace user_globals {
31  std::map<mesh_t, sf_mesh> mesh_reg;
33  std::map<SF::quadruple<int>, SF::index_mapping<mesh_int_t> > map_reg;
35  std::map<physic_t, Basic_physic*> physics_reg;
39  std::map<datavec_t, sf_vec*> datavec_reg;
41  FILE* petsc_error_fd = NULL;
43  bool using_legacy_stimuli = false;
44 } // namespace user_globals
45 } // namespace opencarp
46 
47 using namespace opencarp;
48 
49 #undef __FUNCT__
50 #define __FUNCT__ "main"
51 int main(int argc, char** argv)
52 {
53  char *DBfile = NULL; // could be used to pass in ~/.petscrc
54  char *help_msg = NULL;
55  parse_params_cpy(argc, argv);
56  initialize_PETSc(&argc, argv, DBfile, help_msg);
57 
60 
61  // set up meshes
62  std::map<mesh_t, sf_mesh> & mesh_registry = user_globals::mesh_reg;
63  mesh_registry[reference_msh] = sf_mesh();
64  mesh_registry[reference_msh].comm = PETSC_COMM_WORLD;
65  mesh_registry[extra_elec_msh] = sf_mesh();
66 
67  setup_meshes();
68 
69  MaterialType mtype[2];
70  FILE_SPEC logger = f_open("electrics.log", param_globals::experiment != 4 ? "w" : "r");
71 
74  mtype[Electrics::extra_grid].regionIDs, true, "gregion_e");
75 
76  SF::vector<stimulus> stimuli;
77  elliptic_solver ellip_solver;
78  ellip_solver.init();
79  ellip_solver.rebuild_matrices(mtype, stimuli, logger);
80 
82 }
The scatterer registry class.
A vector storing arbitrary data.
Definition: SF_vector.h:28
void rebuild_matrices(MaterialType *mtype, SF::vector< stimulus > &stimuli, FILE_SPEC logger)
Definition: electrics.cc:1004
centralize time managment and output triggering
Definition: timer_utils.h:58
Top-level header of FEM module.
FILE * petsc_error_fd
file descriptor for petsc error output
Definition: main.cc:44
timer_manager * tm_manager
a manager for the various physics timers
Definition: main.cc:40
std::map< datavec_t, sf_vec * > datavec_reg
important solution vectors from different physics
Definition: main.cc:42
std::map< SF::quadruple< int >, SF::index_mapping< mesh_int_t > > map_reg
Registriy for the inter domain mappings.
Definition: main.cc:36
bool using_legacy_stimuli
flag storing whether legacy stimuli are used
Definition: main.cc:46
SF::scatter_registry scatter_reg
Registry for the different scatter objects.
Definition: main.cc:32
std::map< mesh_t, sf_mesh > mesh_reg
Registry for the different meshes used in a multi-physics simulation.
Definition: main.cc:34
std::map< physic_t, Basic_physic * > physics_reg
the physics
Definition: main.cc:38
void parse_params_cpy(int argc, char **argv)
Initialize input parameters on a copy of the real command line parameters.
Definition: sim_utils.cc:1150
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:391
SF::meshdata< mesh_int_t, mesh_real_t > sf_mesh
Definition: sf_interface.h:33
void cleanup_and_exit()
Definition: sim_utils.cc:2650
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:1346
FILE_SPEC f_open(const char *fname, const char *mode)
Open a FILE_SPEC.
Definition: basics.cc:123
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:94
@ reference_msh
Definition: sf_interface.h:54
@ extra_elec_msh
Definition: sf_interface.h:46
@ intra_elec_msh
Definition: sf_interface.h:45
void setup_meshes(bool require_fibers=true)
Read in the reference mesh and use its data to populate all meshes registered in the mesh registry.
Definition: sim_utils.cc:2235
void setup_petsc_err_log()
set up error logs for PETSc, so that it doesnt print errors to stderr.
Definition: sim_utils.cc:2677
Top-level header file of numerics module.
Top-level header of physics module.
description of materal properties in a mesh
Definition: fem_types.h:106
File descriptor struct.
Definition: basics.h:120
int main(int argc, char **argv)
Definition: testfem.cc:51