Peano
Loading...
Searching...
No Matches
PDE.py
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
4compute_primitive_variables = r"""
5 const auto irho = 1.0 / Q[Shortcuts::rho];
6 const auto u0 = Q[Shortcuts::rhoU + 0] * irho;
7 const auto u1 = Q[Shortcuts::rhoU + 1] * irho;
8#if DIMENSIONS == 3
9 const auto u2 = Q[Shortcuts::rhoU + 2] * irho;
10#endif
11
12#if DIMENSIONS == 3
13 const auto uSq = u0 * u0 + u1 * u1 + u2 * u2;
14 const auto u_n = (normal == 0) ? u0 : (normal == 1) ? u1 : u2;
15#else
16 const auto uSq = u0 * u0 + u1 * u1;
17 const auto u_n = (normal == 0) ? u0 : u1;
18#endif
19
20 const auto internalE = Q[Shortcuts::rhoE] - 0.5 * Q[Shortcuts::rho] * uSq;
21 const auto p = (GAMMA - 1.0) * internalE;
22"""
23
24max_eigenvalue = r"""
25 {compute_primitive_variables}
26 const auto speedOfSound = std::sqrt(GAMMA * p * irho);
27 auto result = std::fmax(0.0, std::fabs(u_n - speedOfSound));
28 result = std::fmax(result, std::fabs(u_n + speedOfSound));
29 return result;
30""".format(
31 compute_primitive_variables=compute_primitive_variables
32)
33
34flux = r"""
35 {compute_primitive_variables}
36
37 F[Shortcuts::rho] = Q[Shortcuts::rhoU + normal];
38
39 F[Shortcuts::rhoU + 0] = Q[Shortcuts::rhoU + 0] * u_n;
40 F[Shortcuts::rhoU + 1] = Q[Shortcuts::rhoU + 1] * u_n;
41#if DIMENSIONS == 3
42 F[Shortcuts::rhoU + 2] = Q[Shortcuts::rhoU + 2] * u_n;
43#endif
44
45 F[Shortcuts::rhoU + normal] += p;
46
47 F[Shortcuts::rhoE] = (Q[Shortcuts::rhoE] + p) * u_n;
48""".format(
49 compute_primitive_variables=compute_primitive_variables
50)
51
52source_term = r"""
53 S[Shortcuts::rho] = 0.0;
54 S[Shortcuts::rhoU + 0] = 0.0;
55 S[Shortcuts::rhoU + 1] = -Q[Shortcuts::rho] * GRAVITY;
56#if DIMENSIONS == 3
57 S[Shortcuts::rhoU + 2] = 0.0;
58#endif
59 S[Shortcuts::rhoE] = -Q[Shortcuts::rhoU + 1] * GRAVITY;
60"""