-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathidefix.hpp
More file actions
237 lines (195 loc) · 5.08 KB
/
idefix.hpp
File metadata and controls
237 lines (195 loc) · 5.08 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// ***********************************************************************************
// Idefix MHD astrophysical code
// Copyright(C) Geoffroy R. J. Lesur <[email protected]>
// and other code contributors
// Licensed under CeCILL 2.1 License, see COPYING for more information
// ***********************************************************************************
#ifndef IDEFIX_HPP_
#define IDEFIX_HPP_
#include <fstream>
#include <iostream>
#include <cstdio>
#include <Kokkos_Core.hpp>
// #include <Kokkos_DualView.hpp> // do we still need this?
#ifdef WITH_MPI
#include <mpi.h>
#endif
using Device = Kokkos::DefaultExecutionSpace;
using Layout = Kokkos::LayoutRight;
/// Type of loops we admit in idefix (see loop.hpp for details)
enum class LoopPattern { SIMDFOR, RANGE, MDRANGE, TPX, TPTTRTVR, UNDEFINED };
#define YES 255
#define NO 0
#define SMALL_NUMBER (1e-10)
#ifndef MHD
#warning MHD flag should be set to yes or no explicitly. I will assume MHD is enabled.
#define MHD YES
#endif
/* ---- Geometry Labels ( > 0) ---- */
#define CARTESIAN 1
#define CYLINDRICAL 2
#define POLAR 3
#define SPHERICAL 4
#define IDIR 0
#define JDIR 1
#define KDIR 2
// Basic configuration
#ifndef DEFINITIONS_FILE
#include "definitions.hpp"
#else
#include DEFINITIONS_FILE
#endif
#include "real_types.hpp"
#ifdef EMF_AVERAGE
#error EMF_AVERAGE is deprecated. Use hydro/emf in the input file to set the emf averaging scheme
#endif
#if GEOMETRY == CYLINDRICAL && DIMENSIONS == 3
#error CYLINDRICAL should only be used with DIMENSIONS <= 2. Use POLAR for 3D problems.
#endif
// Check whether we're isothermal. If we're not, then we need to solve an energy equation
#ifndef HAVE_ENERGY
#ifdef ISOTHERMAL
#define HAVE_ENERGY 0
#else
#define HAVE_ENERGY 1
#endif
#endif
// Shortcuts for fields used in the code
#define RHO 0
#define MX1 1
#define MX2 (COMPONENTS >= 2 ? 2: 255)
#define MX3 (COMPONENTS == 3 ? 3: 254)
#if MHD == YES
#define BX1 (COMPONENTS + 1 + HAVE_ENERGY)
#define BX2 (COMPONENTS >= 2 ? (BX1+1): 252)
#define BX3 (COMPONENTS == 3 ? (BX1+2): 251)
#else
#define BX1 253
#define BX2 252
#define BX3 251
#endif
#if HAVE_ENERGY == 1
#define ENG (COMPONENTS + 1)
#else
#define ENG 250
#endif
#define PRS ENG
#define VX1 MX1
#define VX2 MX2
#define VX3 MX3
#if MHD == YES
#define NFLX (1 + 2*COMPONENTS + HAVE_ENERGY)
#define TRG NFLX // Gas Tracer index
#define TRD (NFLX-COMPONENTS) // Dust Tracer index
#else
#define NFLX (1 + COMPONENTS + HAVE_ENERGY)
#define TRG NFLX
#define TRD NFLX
#endif
// Face-centered variables
#define BX1s 0
#define BX2s 1
#define BX3s 2
// Edge-centered variables
#ifdef EVOLVE_VECTOR_POTENTIAL
#if DIMENSIONS < 3
#define AX1e 250
#define AX2e 251
#define AX3e 0
#else
#define AX1e 0
#define AX2e 1
#define AX3e 2
#endif
#endif
// User-Friendly variables in non-cartesian geometry
#if GEOMETRY == CYLINDRICAL
#if COMPONENTS >= 1
#define iVR VX1
#define iMR MX1
#define iBR BX1
#endif
#if COMPONENTS >= 2
#define iVZ VX2
#define iMZ MX2
#define iBZ BX2
#endif
#if COMPONENTS >= 3
#define iVPHI VX3
#define iMPHI MX3
#define iBPHI BX3
#endif
#endif
#if GEOMETRY == POLAR
#if COMPONENTS >= 1
#define iVR VX1
#define iMR MX1
#define iBR BX1
#endif
#if COMPONENTS >= 2
#define iVPHI VX2
#define iMPHI MX2
#define iBPHI BX2
#endif
#if COMPONENTS == 3
#define iVZ VX3
#define iMZ MX3
#define iBZ BX3
#endif
#endif
#if GEOMETRY == SPHERICAL
#if COMPONENTS >= 1
#define iVR VX1
#define iMR MX1
#define iBR BX1
#endif
#if COMPONENTS >= 2
#define iVTH VX2
#define iMTH MX2
#define iBTH BX2
#endif
#if COMPONENTS == 3
#define iVPHI VX3
#define iMPHI MX3
#define iBPHI BX3
#endif
#endif
// Some macro definitions
#if DIMENSIONS == 1
#define IOFFSET 1
#define JOFFSET 0
#define KOFFSET 0
#endif
#if DIMENSIONS == 2
#define IOFFSET 1
#define JOFFSET 1
#define KOFFSET 0
#endif
#if DIMENSIONS == 3
#define IOFFSET 1
#define JOFFSET 1
#define KOFFSET 1
#endif
#define NVAR (NFLX)
// File handler depends on the type of I/O we use
#ifdef WITH_MPI
using IdfxFileHandler = MPI_File;
#else
using IdfxFileHandler = FILE*;
#endif
// Types of boundary which can be treated
enum BoundaryType { internal, periodic, reflective, outflow, shearingbox, axis, userdef, undefined};
enum BoundarySide { left, right};
enum class SliceType {Cut, Average};
// Type of grid coarsening
enum GridCoarsening{disabled,
enabled,
dynamic}; ///< enabled = static coarsening (static is a reserved c++ keyword)
// Commonly used classes and functions
#include "global.hpp"
#include "error.hpp"
#include "macros.hpp"
#include "loop.hpp"
#include "reduce.hpp"
#include "arrays.hpp"
#endif // IDEFIX_HPP_