-
Notifications
You must be signed in to change notification settings - Fork 2
/
parameter_backup.h
394 lines (359 loc) · 11 KB
/
parameter_backup.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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/**
* @file parameter.h
* @brief Settings via preprocessor directives, typedefs, constants, structs.
*
* Many pre-processor directives are part of the implementation. The code can be used for simulations in one
* dimension, two dimensions and three dimensions via conditional compiling in dependence of the pre-processor
* directive DIM.
*
* @warning However, the code is currently not appropriately tested for `DIM 1` and `DIM 2` and therefore no statement
* about the functionality and correctness can be made at this point.
*
* Most important are the flags GRAVITY_SIM and SPH_SIM which enable or disable the gravitational
* and SPH part of the code.
*
* @author Michael Staneker
* @bug no known bugs
* @todo remove deprecated flags and avoid flags that don't match
*/
#ifndef MILUPHPC_PARAMETER_H
#define MILUPHPC_PARAMETER_H
#include <limits>
#include <iostream>
/**
* @brief Precision of simulation.
*
* Simulations can be either
*
* * single precision via `SINGLE_PRECISION 1`
* * or double precision via `SINGLE_PRECISION 0`
*
* @note
* Type definitions
* * `real` corresponds to floating point precision for whole program
* * `keyType` influences the maximal tree depth
* * maximal tree depth: (sizeof(keyType) - (sizeof(keyType) % DIM))/DIM
*/
#ifdef SINGLE_PRECISION
typedef float real;
#else
typedef double real;
#endif
typedef int integer;
typedef unsigned long keyType;
typedef int idInteger;
/// maximum tree level
#define MAX_LEVEL 21
/// compile & dispatch unit tests
#define UNIT_TESTING 0
/// enable/disable debugging calculations/outputs
#define DEBUGGING 0
/**
* * `SAFETY_LEVEL 0`: almost no safety measures
* * `SAFETY_LEVEL 1`: most relevant/important safety measures
* * `SAFETY_LEVEL 2`: more safety measures, including assertions
* * `SAFETY_LEVEL 3`: many security measures, including all assertions
*/
#define SAFETY_LEVEL 2
/// Dimension of the problem
#define DIM 3
/// function: \f$ 2^{x} \f$
#define power_two(x) (1 << (x))
/// \f$ 2^{DIM} \f$ which corresponds to the number of children for each node
#define POW_DIM power_two(DIM)
/// [0]: natural units, [1]: SI units
#define SI_UNITS 1
/// [0]: rectangular (and not necessarily cubic domains), [1]: cubic domains
#define CUBIC_DOMAINS 1
/// Simulation with gravitational forces
#define GRAVITY_SIM 1
/// SPH simulation
#define SPH_SIM 1
/// integrate energy equation
#define INTEGRATE_ENERGY 0
/// integrate density equation
#define INTEGRATE_DENSITY 1
/// integrate smoothing length
#define INTEGRATE_SML 0
/// decouple smoothing length for pc integrator(s)
#define DECOUPLE_SML 0
/// variable smoothing length
#define VARIABLE_SML 1
/// correct smoothing length
#define SML_CORRECTION 0
/**
* Choose the SPH representation to solve the momentum and energy equation:
* * **SPH_EQU_VERSION 1:** original version with
* * HYDRO \f$ \frac{dv_a}{dt} \sim - \left( \frac{p_a}{\rho_a^2} + \frac{p_b}{\rho_b^2} \right) \nabla_a W_{ab} \f$
* * SOLID \f$ \frac{dv_a}{dt} \sim \left( \frac{\sigma_a}{\rho_a^2} + \frac{\sigma_b}{\rho_b2} \right) \nabla_a W_{ab} \f$
* * **SPH_EQU_VERSION 2:** slighty different version with
* * HYDRO \f$ \frac{dv_a}{dt} \sim - \frac{p_a+p_b}{\rho_a \cdot \rho_b} \nabla_a W_{ab} \f$
* * SOLID \f$ \frac{dv_a}{dt} \sim \frac{\sigma_a+\sigma_b}{\rho_a \cdot \rho_b} \nabla_a W_{ab} \f$
*/
#define SPH_EQU_VERSION 1
/// @todo deprecated flag (`ARTIFICIAL_VISCOSITY` is default)
#define ARTIFICIAL_VISCOSITY 1
/// @todo not yet fully implemented (flags)
#define AVERAGE_KERNELS 0
#define DEAL_WITH_TOO_MANY_INTERACTIONS 0
#define SHEPARD_CORRECTION 0
#define SOLID 0
#define NAVIER_STOKES 0
#define ARTIFICIAL_STRESS 0
#define POROSITY 0
#define ZERO_CONSISTENCY 0
#define LINEAR_CONSISTENCY 0
#define FRAGMENTATION 0
#define PALPHA_POROSITY 0
#define PLASTICITY 0
#define KLEY_VISCOSITY 0
#define KEY_MAX ULONG_MAX
//#define DOMAIN_LIST_SIZE 512 // changed to be a runtime constant
#define MAX_DEPTH 128
#define MAX_NUM_INTERACTIONS 180
#define NUM_THREADS_LIMIT_TIME_STEP 256
#define NUM_THREADS_CALC_CENTER_OF_MASS 256
// (note that our sml is defined up to the zero of the kernel, not half of it)
/// Courant (CFL) number
#define COURANT_FACT 0.4
#define FORCES_FACT 0.2
constexpr real dbl_max = std::numeric_limits<real>::max();
#define DBL_MAX dbl_max;
/// (Physical) constants
namespace Constants {
/// Gravitational constant
constexpr real G = 6.67430e-11;
}
/**
* Simulation parameters.
*
* Some settings/parameters for dispatching simulation.
*/
typedef struct SimulationParameters {
/// output file(s) directory
std::string directory;
/// log file(s) directory
std::string logDirectory;
/// verbosity level
int verbosity;
/// time the CUDA kernels
bool timeKernels;
/// number of output files
int numOutputFiles;
/// time step
real timeStep;
/// max (allowed) time step
real maxTimeStep;
/// end time of simulation
real timeEnd;
/// apply load balancing
bool loadBalancing;
/// apply load balancing each x interval/simulation step
int loadBalancingInterval;
/// @todo deprecated
int loadBalancingBins;
/// input file containing initial particle distribution
std::string inputFile;
/// input file containing material configurations/parameters
std::string materialConfigFile;
/// specify a (MPI) rank for console logging (default: -1 logging all ranks)
int outputRank;
/// log performance to HDF5 file
bool performanceLog;
/// log particles sent to HDF5 file
bool particlesSent2H5;
/// space-filling curve selection
int sfcSelection;
/// integrator selection
int integratorSelection;
//#if GRAVITY_SIM
/// clumping parameter/ \f$ \theta $\f - parameter
real theta;
/// gravitational smoothing
real smoothing;
/// gravitational force version to be used
int gravityForceVersion;
//#endif
//#if SPH_SIM
/// (SPH) smoothing kernel selection
int smoothingKernelSelection;
/// SPH fixed-radius near-neighbor search (FRNN) version to be used
int sphFixedRadiusNNVersion;
//#endif
/// remove particles in dependence of some criterion
bool removeParticles;
/// criterion to remove particles (spherical/cubic/... domain)
int removeParticlesCriterion;
/// dimension to be removed (e.g. distance)
real removeParticlesDimension;
int bins;
/// calculate the angular momentum
bool calculateAngularMomentum;
/// calculate the energy
bool calculateEnergy;
/// calculate the center of mass (COM)
bool calculateCenterOfMass;
/// memory contingent: percentage of all particles that are possibly able to be on one process
real particleMemoryContingent;
/// domain list size, possible number of domain list nodes
int domainListSize;
} SimulationParameters;
/**
* @brief Specify target: device or host.
*
* Struct usable to specify e.g. copy commands.
*/
struct To
{
enum Target
{
host, device
};
Target t_;
To(Target t) : t_(t) {}
operator Target () const {return t_;}
private:
template<typename T>
operator T () const;
};
/**
* @brief (SPH) available smoothing kernels.
*
* available kernels:
*
* * spiky
* * cubic spline
* * wendlandc2, wendlandc4, wendlandc6
*/
struct Smoothing
{
enum Kernel
{
spiky, cubic_spline, wendlandc2, wendlandc4, wendlandc6
};
Kernel t_;
Smoothing(Kernel t) : t_(t) {}
operator Smoothing () const {return t_;}
private:
template<typename T>
operator T () const;
};
/**
* @brief Execution location (host/device).
*
* Execute e.g. a reduction operation either on the `host` or `device`.
*/
struct Execution
{
enum Location
{
host, device
};
Location t_;
Execution(Location t) : t_(t) {}
operator Location () const {return t_;}
private:
template<typename T>
operator T () const;
};
/**
* @brief Available space-filling curves.
*
* Available space-filling curves are:
*
* * Lebesgue SFC
* * Hilbert SFC
*
* whereas Hilbert SFC are derived from Lebesgue SFC.
*/
struct Curve
{
enum Type
{
lebesgue, hilbert
};
Type t_;
Curve(Type t) : t_(t) {}
operator Type () const {return t_;}
//friend std::ostream& operator<<(std::ostream& out, const Curve::Type curveType);
private:
template<typename T>
operator T () const;
};
/**
* @brief Available integrators.
*
* Available integrators are
*
* * explicit euler
* * Predictor-corrector Euler/Heun
*
* @note The gravitational part is currently separated and not included
* in the predictor-corrector integration scheme for several reasons.
*/
struct IntegratorSelection
{
enum Type
{
explicit_euler, predictor_corrector_euler
};
Type t_;
IntegratorSelection(Type t) : t_(t) {}
operator Type () const {return t_;}
private:
template<typename T>
operator T () const;
};
/**
* @brief Implemented equation of states
*
* Implemented equation of states are:
*
* * polytropic gas
* * isothermal gas
* * ideal gas
* * locally isothermal gas
*/
enum EquationOfStates {
//EOS_TYPE_ACCRETED = -2, // special flag for particles that got accreted by a gravitating point mass
//EOS_TYPE_IGNORE = -1, // particle is ignored
/** polytropic EOS for gas, needs polytropic_K and polytropic_gamma in material.cfg file */
EOS_TYPE_POLYTROPIC_GAS = 0,
//EOS_TYPE_MURNAGHAN = 1, // Murnaghan EOS for solid bodies, see Melosh "Impact Cratering", needs in material.cfg: rho_0, bulk_modulus, n
//EOS_TYPE_TILLOTSON = 2, // Tillotson EOS for solid bodies, see Melosh "Impact Cratering", needs in material.cfg: till_rho_0, till_A, till_B, till_E_0, till_E_iv, till_E_cv, till_a, till_b, till_alpha, till_beta; bulk_modulus and shear_modulus are needed to calculate the sound speed and crack growth speed for FRAGMENTATION
/** this is pure molecular hydrogen at 10 K */
EOS_TYPE_ISOTHERMAL_GAS = 3,
//EOS_TYPE_REGOLITH = 4, // The Bui et al. 2008 soil model
//EOS_TYPE_JUTZI = 5, // Tillotson EOS with p-alpha model by Jutzi et al.
//EOS_TYPE_JUTZI_MURNAGHAN = 6, // Murnaghan EOS with p-alpha model by Jutzi et al.
//EOS_TYPE_ANEOS = 7, // ANEOS (or tabulated EOS in ANEOS format)
//EOS_TYPE_VISCOUS_REGOLITH = 8, // describe regolith as a viscous material -> EXPERIMENTAL DO NOT USE
/** ideal gas equation, set polytropic_gamma in material.cfg */
EOS_TYPE_IDEAL_GAS = 9,
//EOS_TYPE_SIRONO = 10, // Sirono EOS modifed by Geretshauser in 2009/10
//EOS_TYPE_EPSILON = 11, // Tillotson EOS with epsilon-alpha model by Wuennemann, Collins et al.
/** locally isothermal gas: \f$ p = c_s^2 \cdot \rho \f$ */
EOS_TYPE_LOCALLY_ISOTHERMAL_GAS = 12,
//EOS_TYPE_JUTZI_ANEOS = 13// ANEOS EOS with p-alpha model by Jutzi et al.
};
struct Entry
{
enum Name
{
x,
#if DIM > 1
y,
#if DIM == 3
z,
#endif
#endif
mass
};
Name t_;
Entry(Name t) : t_(t) {}
operator Name () const {return t_;}
private:
template<typename T>
operator T () const;
};
#endif //MILUPHPC_PARAMETER_H