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