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 [[maybe_unused]] const bool gridIsConstructed
19) {
20 const double y = airfoilSymmetric(x[0]);
21
22 Q[0] = (y > x[1] && -y < x[1]) ? 1000.0 : 1.0;
23 Q[1] = 1.0;
24 Q[2] = 0.0;
25 Q[3] = 2.5;
26}
27
28void tutorials::exahype2::euler::EulerSolver::boundaryConditions(
29 [[maybe_unused]] const double* const NOALIAS Qinside, // Qinside[4+0]
30 [[maybe_unused]] double* const NOALIAS Qoutside, // Qoutside[4+0]
31 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
32 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
33 [[maybe_unused]] const double t,
34 [[maybe_unused]] const int normal
35) {
36 if (normal == 0 && x[0] == DomainOffset[0]) {
37 Qoutside[0] = 1.0;
38 Qoutside[1] = 1.0;
39 Qoutside[2] = 0.0;
40 Qoutside[3] = 2.5;
41 } else {
42 Qoutside[0] = Qinside[0];
43 Qoutside[1] = Qinside[1];
44 Qoutside[2] = Qinside[2];
45 Qoutside[3] = Qinside[3];
46 }
47}
48
49double tutorials::exahype2::euler::EulerSolver::maxEigenvalue(
50 [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
51 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
52 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
53 [[maybe_unused]] const double t,
54 [[maybe_unused]] const double dt,
55 [[maybe_unused]] const int normal
56) {
57 const double irho = 1.0 / Q[0];
58 constexpr double gamma = 1.4;
59 const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
60
61 const double c = std::sqrt(gamma * p * irho);
62 const double u = Q[normal + 1] * irho;
63
64 return std::max(std::abs(u - c), std::abs(u + c));
65}
66
67void tutorials::exahype2::euler::EulerSolver::flux(
68 [[maybe_unused]] const double* const NOALIAS Q, // Q[4+0]
69 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
70 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
71 [[maybe_unused]] const double t,
72 [[maybe_unused]] const double dt,
73 [[maybe_unused]] const int normal,
74 [[maybe_unused]] double* const NOALIAS F // F[4]
75) {
76 const double irho = 1.0 / Q[0];
77 constexpr double gamma = 1.4;
78 const double p = (gamma - 1) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
79
80 F[0] = Q[normal + 1];
81 F[1] = Q[normal + 1] * Q[1] * irho;
82 F[2] = Q[normal + 1] * Q[2] * irho;
83 F[3] = Q[normal + 1] * irho * (Q[3] + p);
84
85 F[normal + 1] += p;
86}
double airfoilSymmetric(double x, double c=100, double t=0.12)
gamma
Definition euler.py:90