Peano
euler.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 from .equation import Equation
4 
5 
6 class Euler(Equation):
7  def __init__(self, dimensions, gamma=1.4):
8  self.dimensionsdimensionsdimensions = dimensions
9  self.num_unknownsnum_unknownsnum_unknowns = 4 if dimensions == 2 else 5
10  self.num_auxiliary_variablesnum_auxiliary_variablesnum_auxiliary_variables = 0
11  self.gammagamma = gamma
12 
13  def eigenvalues(self):
14  return (
15  """
16  const double irho = 1.0 / Q[0];
17  constexpr double Gamma = """
18  + str(self.gammagamma)
19  + """;
20  const double p = (Gamma - 1.0) * (Q[4] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]+Q[3]*Q[3]));
21 
22  const double c = std::sqrt(Gamma * p * irho);
23  const double u = Q[normal + 1] * irho;
24 
25  return std::fmax(std::abs(u-c), std::abs(u+c));
26 """
27  if self.dimensionsdimensionsdimensions == 3
28  else """
29  const double irho = 1.0 / Q[0];
30  constexpr double Gamma = """
31  + str(self.gammagamma)
32  + """;
33  const double p = (Gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]));
34 
35  const double c = std::sqrt(Gamma * p * irho);
36  const double u = Q[normal + 1] * irho;
37 
38  return std::fmax(std::abs(u-c), std::abs(u+c));
39 """
40  )
41 
42  def flux(self):
43  return (
44  """
45  const double irho = 1.0 / Q[0];
46  constexpr double Gamma = """
47  + str(self.gammagamma)
48  + """;
49  const double p = (Gamma - 1.0) * (Q[4] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]+Q[3]*Q[3]));
50 
51  F[0] = Q[normal + 1];
52  F[1] = Q[normal + 1] * Q[1] * irho;
53  F[2] = Q[normal + 1] * Q[2] * irho;
54  F[3] = Q[normal + 1] * Q[3] * irho;
55  F[4] = Q[normal + 1] * irho * (Q[4] + p);
56 
57  F[normal + 1] += p;
58 """
59  if self.dimensionsdimensionsdimensions == 3
60  else """
61  const double irho = 1.0 / Q[0];
62  constexpr double Gamma = """
63  + str(self.gammagamma)
64  + """;
65  const double p = (Gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1]*Q[1]+Q[2]*Q[2]));
66 
67  F[0] = Q[normal + 1];
68  F[1] = Q[normal + 1] * Q[1] * irho;
69  F[2] = Q[normal + 1] * Q[2] * irho;
70  F[3] = Q[normal + 1] * irho * (Q[3] + p);
71 
72  F[normal + 1] += p;
73 """
74  )
def __init__(self, dimensions, gamma=1.4)
Definition: euler.py:7
str
Definition: ccz4.py:55