openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
physics_types.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 #ifndef PHYSICS_TYPES_H
28 #define PHYSICS_TYPES_H
29 
30 #include "basics.h"
31 
32 namespace opencarp {
33 
34 // unit conversion
35 #define UM2_to_CM2 1.0e-8
36 #define UM_to_CM 1.0e-4
37 #define UM_to_MM 1.0e-3
38 #define MM_to_UM 1.0e3
39 
40 
51 enum physic_t {
54 };
55 
59 class Basic_physic {
60 public:
62  const char* name = NULL;
64  FILE_SPEC logger = NULL;
66  int timer_idx = -1;
67 
68  // For very heavy objects like the physics, we might not want to use the
69  // constructor / destructor mechanisms, to avoid expensive operations when
70  // someone (accidentaly) creates a local copy
71  virtual void initialize() = 0;
72  virtual void destroy() = 0;
73  virtual void compute_step() = 0;
74  virtual void output_step() = 0;
75 
76  virtual inline void output_timings()
77  {
78  if(name) log_msg(0,0,0, "%s:", name);
79  else log_msg(0,0,0, "<unnamed>:");
80  log_msg(0,0,0, " Init: %.2lf sec", initialize_time);
81  log_msg(0,0,0, " Compute: %.2lf sec", compute_time);
82  log_msg(0,0,0, " Output: %.2lf sec", output_time);
83  log_msg(0,0,0, "");
84  }
85 
86  // we also store timings for the main Basic_physic API
87  double initialize_time = 0.0;
88  double compute_time = 0.0;
89  double output_time = 0.0;
90 
91  virtual std::string timer_unit(const int timer_id) = 0;
92  virtual double timer_val(const int timer_id) = 0;
93 };
94 
95 
99 enum datavec_t {
101 };
102 
103 } // namespace opencarp
104 
105 #endif
virtual std::string timer_unit(const int timer_id)=0
FILE_SPEC logger
The logger of the physic, each physic should have one.
Definition: physics_types.h:64
virtual void output_step()=0
const char * name
The name of the physic, each physic should have one.
Definition: physics_types.h:62
physic_t
Identifier for the different physics we want to set up.
Definition: physics_types.h:51
virtual void destroy()=0
virtual double timer_val(const int timer_id)=0
The abstract physics interface we can use to trigger all physics.
Definition: physics_types.h:59
int timer_idx
the timer index received from the timer manager
Definition: physics_types.h:66
File descriptor struct.
Definition: basics.h:133
virtual void output_timings()
Definition: physics_types.h:76
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
Definition: basics.cc:72
virtual void compute_step()=0
datavec_t
Enum used to adress the different data vectors stored in the data registry.
Definition: physics_types.h:99
Basic utility structs and functions, mostly IO related.
virtual void initialize()=0