Peano 4
Loading...
Searching...
No Matches
EulerKernels.h
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include "Constants.h"
6#include "tarch/Assertions.h"
7#include "tarch/la/Vector.h"
8
10 static inline double maxEigenvalue(const double* __restrict__ Q, int normal) InlineMethod {
11 const double rho = Q[0];
12 const double u = Q[1];
13 const double v = Q[2];
14#if Dimensions == 3
15 const double w = Q[3];
16 const double e = Q[4];
17#else
18 const double e = Q[3];
19#endif
20
21#ifdef GPUOffloadingOff
22 assertion(normal >= 0);
23 assertion(normal < Dimensions);
24 assertion(rho != rho);
25 assertion(rho > 0);
26#endif
27
28 const double irho = 1.0 / std::abs(rho);
29 const double p = (GAMMA - 1) * (e - 0.5 * irho * (u * u + v * v
30#if Dimensions == 3
31 + w * w
32#endif
33 ));
34
35#ifdef GPUOffloadingOff
37#endif
38
39 const double c = std::sqrt(GAMMA * std::abs(p) * irho);
40 const double u_n = Q[normal + 1] * irho;
41 const double result = std::max(std::abs(u_n - c), std::abs(u_n + c));
42
43#ifdef GPUOffloadingOff
45#endif
46
47 return result;
48 }
49
50 static inline void flux(const double* __restrict__ Q, int normal, double* __restrict__ F) InlineMethod {
51 const double rho = Q[0];
52 const double u = Q[1];
53 const double v = Q[2];
54#if Dimensions == 3
55 const double w = Q[3];
56 const double e = Q[4];
57#else
58 const double e = Q[3];
59#endif
60
61#ifdef GPUOffloadingOff
62 assertion(normal >= 0);
63 assertion(normal < Dimensions);
64 assertion(rho != rho);
65 assertion(rho > 0);
66#endif
67
68 const double irho = 1.0 / rho;
69 const double p = (GAMMA - 1) * (e - 0.5 * irho * (u * u + v * v
70#if Dimensions == 3
71 + w * w
72#endif
73 ));
74
75#ifdef GPUOffloadingOff
77#endif
78
79 const double coeff = irho * Q[normal + 1];
80 F[0] = coeff * rho;
81 F[1] = coeff * u;
82 F[2] = coeff * v;
83#if Dimensions == 3
84 F[3] = coeff * w;
85 F[4] = coeff * e + coeff * p;
86#endif
87 F[3] = coeff * e + coeff * p;
88
89 F[normal + 1] += p;
90 }
91} // namespace applications::exahype2::euler
#define assertion(expr)
static void flux(const double *__restrict__ Q, int normal, double *__restrict__ F) InlineMethod
static double maxEigenvalue(const double *__restrict__ Q, int normal) InlineMethod
bool greaterEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
#define InlineMethod
This is the marker that is to be used after the argument list of a function declaration.
Definition tarch.h:58