Peano
EulerSolver.cpp
Go to the documentation of this file.
1 //
2 // A sample implementation file for this problem:
3 //
4 #include "EulerSolver.h"
5 
6 tarch::logging::Log tutorials::exahype2::euler::EulerSolver::_log("tutorials::exahype2::euler::EulerSolver");
7 
8 // c chord length, t maximum relative thickness.
9 double airfoilSymmetric(double x, double c = 100, double t = 0.12) {
10  return 5.0 * t * c
11  * (0.2969 * sqrt(x / c) + ((((-0.1015) * (x / c) + 0.2843) * (x / c) - 0.3516) * (x / c) - 0.1260) * (x / c));
12 }
13 
14 void tutorials::exahype2::euler::EulerSolver::initialCondition(
15  [[maybe_unused]] double* const NOALIAS Q, // Q[4+0]
16  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
17  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
18  [[maybe_unused]] const bool gridIsConstructed
19 ) {
20  const double y = airfoilSymmetric(x[0]);
21  const double alpha = (y > x[1] && -y < x[1]) ? 0.0 : 1.0;
22 
23  Q[0] = (y > x[1] && -y < x[1]) ? 1000.0 : 1.0;
24  Q[1] = alpha * 1.0;
25  Q[2] = 0.0;
26  Q[3] = alpha * 2.5;
27 }
28 
29 void tutorials::exahype2::euler::EulerSolver::boundaryConditions(
30  [[maybe_unused]] const double* const NOALIAS Qinside, // Qinside[4+0]
31  [[maybe_unused]] double* const NOALIAS Qoutside, // Qoutside[4+0]
32  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
33  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
34  [[maybe_unused]] const double t,
35  [[maybe_unused]] const int normal
36 ) {
37  if (normal == 0 && x[0] == DomainOffset[0]) {
38  Qoutside[0] = 1.0;
39  Qoutside[1] = 1.0;
40  Qoutside[2] = 0.0;
41  Qoutside[3] = 2.5;
42  } else {
43  Qoutside[0] = Qinside[0];
44  Qoutside[1] = Qinside[1];
45  Qoutside[2] = Qinside[2];
46  Qoutside[3] = Qinside[3];
47  }
48 }
49 
51  [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
52  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
53  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
54  [[maybe_unused]] const double t,
55  [[maybe_unused]] const double dt,
56  [[maybe_unused]] const int normal
57 ) {
58  const double irho = 1.0 / Q[0];
59  constexpr double gamma = 1.4;
60  const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
61 
62  const double c = std::sqrt(gamma * p * irho);
63  const double u = Q[normal + 1] * irho;
64 
65  return std::max(std::abs(u - c), std::abs(u + c));
66 }
67 
69  [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
70  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
71  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
72  [[maybe_unused]] const double t,
73  [[maybe_unused]] const double dt,
74  [[maybe_unused]] const int normal,
75  [[maybe_unused]] double* const NOALIAS F // F[4]
76 ) {
77  const double irho = 1.0 / Q[0];
78  constexpr double gamma = 1.4;
79  const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
80 
81  F[0] = Q[normal + 1];
82  F[1] = Q[normal + 1] * Q[1] * irho;
83  F[2] = Q[normal + 1] * Q[2] * irho;
84  F[3] = Q[normal + 1] * irho * (Q[3] + p);
85 
86  F[normal + 1] += p;
87 }
double airfoilSymmetric(double x, double c=100, double t=0.12)
Definition: EulerSolver.cpp:9
static double maxEigenvalue(const double *const Q, int normal, const double CCZ4e, const double CCZ4ds, const double CCZ4GLMc, const double CCZ4GLMd)
u
Definition: euler.py:113
flux
Definition: euler.py:29
gamma
Definition: euler.py:90
h
Definition: swe.py:79
tarch::logging::Log _log
This is variant 1 of the fused kernels.