forked from hel-astro-lab/runko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinitions.h
56 lines (42 loc) · 1.98 KB
/
definitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
// math constants
#define PI 3.14159265358979323846
// Old type definitions
// FIXME: remove completely and switch to the new one below.
using Realf = double;
using Real = double;
using creal = const double;
// General double and single precision lengths used in the modules.
//
// By default, most of the arrays are stored with real_short. Some quantities
// that need more precision are temporarily casted to real_long (and often
// back to real_short in the end). I.e., most of the algorithms are mixed-precision.
//
// For extreme simulations the memory footprint can be reduced further by
// setting real_long = float. In this case, however, you must be sure that
// physics is not affected by insufficient floating point accuracy.
//
// It is also worth mentioning that most IO files are already manually set
// to float type to reduce storage requirements.
using real_long = double; /// some spesific algorithmic manipulations are done via this
using real_short = float; /// mainly used for mesh storage types
// nan prevention tolerance
#define EPS 1e-7
// Separate short float type for particles. In most applications it is enough
// to keep this as float. However, some special cases might require extra
// resolution so fall-back to double might be needed.
//
// NOTE: Some calculations are still mixed-precision, as before, because critical
// numerical parts are still done via real_long precision.
//
// NOTE: To force a purely single-precision particle algorithms make
// real_long also float.
using real_prtcl = float; /// particle storage type; NOTE: don't forget MPI type below
// corresponding MPI datatype for particle communications; MPI_FLOAT or MPI_DOUBLE
#define MPI_FLOAT_TP MPI_FLOAT
// FIXME: These should be cleaned away also at some point and moved to
// relevant modules instead (like vlv).
#define NBLOCKS 20 /// default cube size
#define BLOCK_WID 4 /// block width
using indices_t = std::array<size_t, 3>;
using vblock_t = std::array<Real, BLOCK_WID>;