openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
physics_types.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: LicenseRef-APL-1.1
3 
12 #ifndef PHYSICS_TYPES_H
13 #define PHYSICS_TYPES_H
14 
15 #include "basics.h"
16 
17 namespace opencarp {
18 
19 // unit conversion
20 #define UM2_to_CM2 1.0e-8
21 #define UM_to_CM 1.0e-4
22 #define UM_to_MM 1.0e-3
23 #define MM_to_UM 1.0e3
24 
25 
36 enum physic_t {
39 };
40 
44 class Basic_physic {
45 public:
47  const char* name = NULL;
49  FILE_SPEC logger = NULL;
51  int timer_idx = -1;
52 
53  // For very heavy objects like the physics, we might not want to use the
54  // constructor / destructor mechanisms, to avoid expensive operations when
55  // someone (accidentaly) creates a local copy
56  virtual void initialize() = 0;
57  virtual void destroy() = 0;
58  virtual void compute_step() = 0;
59  virtual void output_step() = 0;
60 
61  virtual inline void output_timings()
62  {
63  if(name) log_msg(0,0,0, "%s:", name);
64  else log_msg(0,0,0, "<unnamed>:");
65  log_msg(0,0,0, " Init: %.2lf sec", initialize_time);
66  log_msg(0,0,0, " Compute: %.2lf sec", compute_time);
67  log_msg(0,0,0, " Output: %.2lf sec", output_time);
68  log_msg(0,0,0, "");
69  }
70 
71  // we also store timings for the main Basic_physic API
72  double initialize_time = 0.0;
73  double compute_time = 0.0;
74  double output_time = 0.0;
75 
76  virtual std::string timer_unit(const int timer_id) = 0;
77  virtual double timer_val(const int timer_id) = 0;
78 };
79 
80 
84 enum datavec_t {
86 };
87 
88 } // namespace opencarp
89 
90 #endif
Basic utility structs and functions, mostly IO related.
The abstract physics interface we can use to trigger all physics.
Definition: physics_types.h:44
virtual void destroy()=0
int timer_idx
the timer index received from the timer manager
Definition: physics_types.h:51
virtual void output_timings()
Definition: physics_types.h:61
FILE_SPEC logger
The logger of the physic, each physic should have one.
Definition: physics_types.h:49
virtual std::string timer_unit(const int timer_id)=0
virtual double timer_val(const int timer_id)=0
virtual void output_step()=0
virtual void compute_step()=0
virtual void initialize()=0
const char * name
The name of the physic, each physic should have one.
Definition: physics_types.h:47
physic_t
Identifier for the different physics we want to set up.
Definition: physics_types.h:36
datavec_t
Enum used to adress the different data vectors stored in the data registry.
Definition: physics_types.h:84
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
Definition: basics.cc:57
File descriptor struct.
Definition: basics.h:120