Peano
Loading...
Searching...
No Matches
EulerSolver.cpp
Go to the documentation of this file.
1//
2// A sample implementation file for this problem:
3//
4#include "EulerSolver.h"
5
6tarch::logging::Log tutorials::exahype2::euler::EulerSolver::_log("tutorials::exahype2::euler::EulerSolver");
7
8// c chord length, t maximum relative thickness.
9double 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
14void 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) {
19 const double y = airfoilSymmetric(x[0]);
20
21 Q[0] = (y > x[1] && -y < x[1]) ? 1000.0 : 1.0;
22 Q[1] = 1.0;
23 Q[2] = 0.0;
24 Q[3] = 2.5;
25}
26
27void tutorials::exahype2::euler::EulerSolver::boundaryConditions(
28 [[maybe_unused]] const double* const NOALIAS Qinside, // Qinside[4+0]
29 [[maybe_unused]] double* const NOALIAS Qoutside, // Qoutside[4+0]
30 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
31 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
32 [[maybe_unused]] const double t,
33 [[maybe_unused]] const int normal
34) {
35 if (normal == 0 && x[0] == DomainOffset[0]) {
36 Qoutside[0] = 1.0;
37 Qoutside[1] = 1.0;
38 Qoutside[2] = 0.0;
39 Qoutside[3] = 2.5;
40 } else {
41 Qoutside[0] = Qinside[0];
42 Qoutside[1] = Qinside[1];
43 Qoutside[2] = Qinside[2];
44 Qoutside[3] = Qinside[3];
45 }
46}
47
48double tutorials::exahype2::euler::EulerSolver::maxEigenvalue(
49 [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
50 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
51 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
52 [[maybe_unused]] const double t,
53 [[maybe_unused]] const double dt,
54 [[maybe_unused]] const int normal
55) {
56 const double irho = 1.0 / Q[0];
57 constexpr double gamma = 1.4;
58 const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
59
60 const double c = std::sqrt(gamma * p * irho);
61 const double u = Q[normal + 1] * irho;
62
63 return std::max(std::abs(u - c), std::abs(u + c));
64}
65
66void tutorials::exahype2::euler::EulerSolver::flux(
67 [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
68 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
69 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
70 [[maybe_unused]] const double t,
71 [[maybe_unused]] const double dt,
72 [[maybe_unused]] const int normal,
73 [[maybe_unused]] double* const NOALIAS F // F[4]
74) {
75 const double irho = 1.0 / Q[0];
76 constexpr double gamma = 1.4;
77 const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
78
79 F[0] = Q[normal + 1];
80 F[1] = Q[normal + 1] * Q[1] * irho;
81 F[2] = Q[normal + 1] * Q[2] * irho;
82 F[3] = Q[normal + 1] * irho * (Q[3] + p);
83
84 F[normal + 1] += p;
85}
double airfoilSymmetric(double x, double c=100, double t=0.12)