Peano
Loading...
Searching...
No Matches
adiabatic_index.h
Go to the documentation of this file.
1#pragma once
2
10namespace exaparty {
11 namespace kernels {
12 namespace legacy {
13 namespace adiabaticIndex {
14
15/* Powers of the adiabatic index */
16#if defined(HYDRO_GAMMA_5_3)
17
18#define hydro_gamma 1.66666666666666667
19#define hydro_gamma_minus_one 0.66666666666666667
20#define hydro_gamma_plus_one 2.66666666666666667
21#define hydro_one_over_gamma_minus_one 1.5
22#define hydro_gamma_plus_one_over_two_gamma 0.8
23#define hydro_gamma_minus_one_over_two_gamma 0.2
24#define hydro_gamma_minus_one_over_gamma_plus_one 0.25
25#define hydro_two_over_gamma_plus_one 0.75
26#define hydro_two_over_gamma_minus_one 3.f
27#define hydro_gamma_minus_one_over_two 0.33333333333333333
28#define hydro_two_gamma_over_gamma_minus_one 5.
29#define hydro_one_over_gamma 0.6
30
31#elif defined(HYDRO_GAMMA_7_5)
32
33#define hydro_gamma 1.4
34#define hydro_gamma_minus_one 0.4
35#define hydro_gamma_plus_one 2.4
36#define hydro_one_over_gamma_minus_one 2.5
37#define hydro_gamma_plus_one_over_two_gamma 0.857142857
38#define hydro_gamma_minus_one_over_two_gamma 0.142857143
39#define hydro_gamma_minus_one_over_gamma_plus_one 0.166666667
40#define hydro_two_over_gamma_plus_one 0.83333333
41#define hydro_two_over_gamma_minus_one 5.
42#define hydro_gamma_minus_one_over_two 0.2
43#define hydro_two_gamma_over_gamma_minus_one 7.
44#define hydro_one_over_gamma 0.714285714
45
46#elif defined(HYDRO_GAMMA_4_3)
47
48#define hydro_gamma 1.33333333333333333
49#define hydro_gamma_minus_one 0.33333333333333333
50#define hydro_gamma_plus_one 2.33333333333333333
51#define hydro_one_over_gamma_minus_one 3.
52#define hydro_gamma_plus_one_over_two_gamma 0.875
53#define hydro_gamma_minus_one_over_two_gamma 0.125
54#define hydro_gamma_minus_one_over_gamma_plus_one 0.142857143
55#define hydro_two_over_gamma_plus_one 0.857142857
56#define hydro_two_over_gamma_minus_one 6.
57#define hydro_gamma_minus_one_over_two 0.166666666666666666
58#define hydro_two_gamma_over_gamma_minus_one 8.
59#define hydro_one_over_gamma 0.75
60
61#elif defined(HYDRO_GAMMA_2_1)
62
63#define hydro_gamma 2.
64#define hydro_gamma_minus_one 1.
65#define hydro_gamma_plus_one 3.
66#define hydro_one_over_gamma_minus_one 1.
67#define hydro_gamma_plus_one_over_two_gamma 0.75
68#define hydro_gamma_minus_one_over_two_gamma 0.25
69#define hydro_gamma_minus_one_over_gamma_plus_one 0.33333333333333333
70#define hydro_two_over_gamma_plus_one 0.66666666666666666
71#define hydro_two_over_gamma_minus_one 2.
72#define hydro_gamma_minus_one_over_two 0.5
73#define hydro_two_gamma_over_gamma_minus_one 4.
74#define hydro_one_over_gamma 0.5
75
76#else
77
78#error "An adiabatic index needs to be chosen!"
79
80#endif
81
87 __attribute__((always_inline, const)) inline static double pow_gamma(double x) {
88
89#if defined(HYDRO_GAMMA_5_3)
90
91 const double cbrt = std::cbrt(x); /* x^(1/3) */
92 return cbrt * cbrt * x; /* x^(5/3) */
93
94#elif defined(HYDRO_GAMMA_7_5)
95
96 return std::pow(x, 1.4); /* x^(7/5) */
97
98#elif defined(HYDRO_GAMMA_4_3)
99
100 return std::cbrt(x) * x; /* x^(4/3) */
101
102#elif defined(HYDRO_GAMMA_2_1)
103
104 return x * x;
105
106#else
107
108 error("The adiabatic index is not defined !");
109 return 0.f;
110
111#endif
112 }
113
120 __attribute__((always_inline, const)) inline static double pow_gamma_minus_one(double x) {
121
122#if defined(HYDRO_GAMMA_5_3)
123
124 const double cbrt = std::cbrt(x); /* x^(1/3) */
125 return cbrt * cbrt; /* x^(2/3) */
126
127#elif defined(HYDRO_GAMMA_7_5)
128
129 return std::pow(x, 0.4); /* x^(2/5) */
130
131#elif defined(HYDRO_GAMMA_4_3)
132
133 return std::cbrt(x); /* x^(1/3) */
134
135#elif defined(HYDRO_GAMMA_2_1)
136
137 return x;
138
139#else
140
141 error("The adiabatic index is not defined !");
142 return 0.f;
143
144#endif
145 }
146
153 __attribute__((always_inline, const)) inline static double pow_minus_gamma_minus_one(double x) {
154
155#if defined(HYDRO_GAMMA_5_3)
156
157 const double cbrt_inv = 1. / std::cbrt(x); /* x^(-1/3) */
158 return cbrt_inv * cbrt_inv; /* x^(-2/3) */
159
160#elif defined(HYDRO_GAMMA_7_5)
161
162 return std::pow(x, -0.4); /* x^(-2/5) */
163
164#elif defined(HYDRO_GAMMA_4_3)
165
166 return 1.f / std::cbrt(x); /* x^(-1/3) */
167
168#elif defined(HYDRO_GAMMA_2_1)
169
170 return 1.f / x;
171
172#else
173
174 error("The adiabatic index is not defined !");
175 return 0.f;
176
177#endif
178 }
179
189 __attribute__((always_inline, const)) inline static double pow_minus_gamma(double x) {
190
191#if defined(HYDRO_GAMMA_5_3)
192
193 const double cbrt_inv = 1.f / std::cbrt(x); /* x^(-1/3) */
194 const double cbrt_inv2 = cbrt_inv * cbrt_inv; /* x^(-2/3) */
195 return cbrt_inv * cbrt_inv2 * cbrt_inv2; /* x^(-5/3) */
196
197#elif defined(HYDRO_GAMMA_7_5)
198
199 return std::pow(x, -1.4); /* x^(-7/5) */
200
201#elif defined(HYDRO_GAMMA_4_3)
202
203 const double cbrt_inv = 1.f / std::cbrt(x); /* x^(-1/3) */
204 const double cbrt_inv2 = cbrt_inv * cbrt_inv; /* x^(-2/3) */
205 return cbrt_inv2 * cbrt_inv2; /* x^(-4/3) */
206
207#elif defined(HYDRO_GAMMA_2_1)
208
209 const double inv = 1.f / x;
210 return inv * inv;
211
212#else
213
214 error("The adiabatic index is not defined !");
215 return 0.f;
216
217#endif
218 }
219
229 __attribute__((always_inline, const)) inline static double pow_two_over_gamma_minus_one(double x) {
230
231#if defined(HYDRO_GAMMA_5_3)
232
233 return x * x * x; /* x^3 */
234
235#elif defined(HYDRO_GAMMA_7_5)
236
237 const double x2 = x * x;
238 const double x3 = x2 * x;
239 return x2 * x3;
240
241#elif defined(HYDRO_GAMMA_4_3)
242
243 const double x3 = x * x * x; /* x^3 */
244 return x3 * x3; /* x^6 */
245
246#elif defined(HYDRO_GAMMA_2_1)
247
248 return x * x; /* x^2 */
249
250#else
251
252 error("The adiabatic index is not defined !");
253 return 0.f;
254
255#endif
256 }
257
268 __attribute__((always_inline, const)) inline static double pow_two_gamma_over_gamma_minus_one(double x) {
269
270#if defined(HYDRO_GAMMA_5_3)
271
272 const double x2 = x * x;
273 const double x3 = x2 * x;
274 return x2 * x3;
275
276#elif defined(HYDRO_GAMMA_7_5)
277
278 const double x2 = x * x;
279 const double x4 = x2 * x2;
280 return x4 * x2 * x;
281
282#elif defined(HYDRO_GAMMA_4_3)
283
284 const double x2 = x * x;
285 const double x4 = x2 * x2;
286 return x4 * x4; /* x^8 */
287
288#elif defined(HYDRO_GAMMA_2_1)
289
290 const double x2 = x * x;
291 return x2 * x2; /* x^4 */
292
293#else
294
295 error("The adiabatic index is not defined !");
296 return 0.f;
297
298#endif
299 }
300
311 __attribute__((always_inline, const)) inline static double pow_gamma_minus_one_over_two_gamma(double x) {
312
313#if defined(HYDRO_GAMMA_5_3)
314
315 return std::pow(x, 0.2); /* x^0.2 */
316
317#elif defined(HYDRO_GAMMA_7_5)
318
319 return std::pow(x, hydro_gamma_minus_one_over_two_gamma);
320
321#elif defined(HYDRO_GAMMA_4_3)
322
323 return std::pow(x, 0.125); /* x^0.125 */
324
325#elif defined(HYDRO_GAMMA_2_1)
326
327 return std::pow(x, 0.25); /* x^0.25 */
328
329#else
330
331 error("The adiabatic index is not defined !");
332 return 0.f;
333
334#endif
335 }
336
347 __attribute__((always_inline, const)) inline static double pow_minus_gamma_plus_one_over_two_gamma(double x) {
348
349#if defined(HYDRO_GAMMA_5_3)
350
351 return std::pow(x, -0.8); /* x^-0.8 */
352
353#elif defined(HYDRO_GAMMA_7_5)
354
355 return std::pow(x, -hydro_gamma_plus_one_over_two_gamma);
356
357#elif defined(HYDRO_GAMMA_4_3)
358
359 return std::pow(x, -0.875); /* x^-0.875 */
360
361#elif defined(HYDRO_GAMMA_2_1)
362
363 return std::pow(x, -0.75); /* x^-0.75 */
364
365#else
366
367 error("The adiabatic index is not defined !");
368 return 0.f;
369
370#endif
371 }
372
381 __attribute__((always_inline, const)) inline static double pow_one_over_gamma(double x) {
382
383#if defined(HYDRO_GAMMA_5_3)
384
385 return std::pow(x, hydro_one_over_gamma); /* x^(3/5) */
386
387#elif defined(HYDRO_GAMMA_7_5)
388
389 return std::pow(x, hydro_one_over_gamma);
390
391#elif defined(HYDRO_GAMMA_4_3)
392
393 return std::pow(x, hydro_one_over_gamma); /* x^(3/4) */
394
395#elif defined(HYDRO_GAMMA_2_1)
396
397 return std::sqrt(x); /* x^(1/2) */
398
399#else
400
401 error("The adiabatic index is not defined !");
402 return 0.f;
403
404#endif
405 }
406
414 __attribute__((always_inline, const)) inline static double pow_three_gamma_minus_two(double x) {
415
416#if defined(HYDRO_GAMMA_5_3)
417
418 return x * x * x; /* x^(3) */
419
420#elif defined(HYDRO_GAMMA_7_5)
421
422 return std::pow(x, 2.2); /* x^(11/5) */
423
424#elif defined(HYDRO_GAMMA_4_3)
425
426 return x * x; /* x^(2) */
427
428#elif defined(HYDRO_GAMMA_2_1)
429
430 return x * x * x * x; /* x^(4) */
431
432#else
433
434 error("The adiabatic index is not defined !");
435 return 0.f;
436
437#endif
438 }
439
448 __attribute__((always_inline, const)) inline static double pow_three_gamma_minus_five_over_two(double x) {
449
450#if defined(HYDRO_GAMMA_5_3)
451
452 return 1.f; /* x^(0) */
453
454#elif defined(HYDRO_GAMMA_7_5)
455
456 return std::pow(x, -0.4); /* x^(-2/5) */
457
458#elif defined(HYDRO_GAMMA_4_3)
459
460 return 1.f / std::sqrt(x); /* x^(-1/2) */
461
462#elif defined(HYDRO_GAMMA_2_1)
463
464 return std::sqrt(x); /* x^(1/2) */
465
466#else
467
468 error("The adiabatic index is not defined !");
469 return 0.f;
470
471#endif
472 }
473
481 __attribute__((always_inline, const)) inline static double pow_three_gamma_minus_one(double x) {
482
483#if defined(HYDRO_GAMMA_5_3)
484
485 return x * x; /* x^(2) */
486
487#elif defined(HYDRO_GAMMA_7_5)
488
489 return std::pow(x, 1.2); /* x^(6/5) */
490
491#elif defined(HYDRO_GAMMA_4_3)
492
493 return x; /* x^(1) */
494
495#elif defined(HYDRO_GAMMA_2_1)
496
497 return x * x * x; /* x^(3) */
498
499#else
500
501 error("The adiabatic index is not defined !");
502 return 0.f;
503
504#endif
505 }
506
507 } // namespace adiabaticIndex
508 } // namespace legacy
509 }
510} // namespace exaparty
__attribute__((always_inline, const)) inline static double pow_gamma(double x)
Returns the argument to the power given by the adiabatic index.
This file is part of the ExaParty project.
Definition __init__.py:1