Peano
Loading...
Searching...
No Matches
AtmosphericPressure.cpph
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#include <cmath>
5
6template <auto Pa_, auto U_, auto T_, auto P0_>
8 atmosphericPressure(const auto x, [[maybe_unused]] const auto y, const auto t) {
9 constexpr auto lambda = U_ * T_;
10 constexpr auto xShift = -0.75 * lambda; // -3/4 * U*T
11
12 const auto xShifted = x + xShift;
13
14 // MATLAB: phase = (x./U) - (t-1)*60;
15 const auto phase = (xShifted / U_) - t;
16
17 // MATLAB: tt = round(2.*phase(i)./T);
18 const auto raw = 2.0 * phase / T_;
19 const auto tt = std::round(raw);
20
21 if (tt >= 0 && tt <= 1) {
22 // MATLAB: P0 - Pa*exp(-5.*double(tt))*sin((2*pi/T).*phase(i));
23
24 const auto damping = std::exp(-5.0 * tt);
25
26 const auto omega = 2.0 * M_PI / T_;
27
28 return P0_ - (Pa_ * damping * std::sin(omega * phase));
29 }
30 return P0_;
31}
static auto atmosphericPressure(const auto x, const auto y, const auto t)
Computes the pressure field p(x, y, t) following the Jörn test-case logic.