Peano
Loading...
Searching...
No Matches
RusanovRiemannSolver.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
4template <class T, class Shortcuts, int NumberOfUnknowns, int NumberOfAuxiliaryVariables>
5static inline GPU_CALLABLE_METHOD double applications::exahype2::landslide::rusanovRiemannSolverFV(
6 const T* const NOALIAS QL,
7 const T* const NOALIAS QR,
8 const tarch::la::Vector<DIMENSIONS, double>& x,
9 const tarch::la::Vector<DIMENSIONS, double>& h,
10 const double t,
11 const double dt,
12 const int normal,
13 T* const NOALIAS FL,
14 T* const NOALIAS FR
15) {
16 ShallowWater::flux<T, Shortcuts, NumberOfUnknowns>(QL, x, h, t, dt, normal, FL);
17 ShallowWater::flux<T, Shortcuts, NumberOfUnknowns>(QR, x, h, t, dt, normal, FR);
18
19 landslide::flux<T, Shortcuts>(QL, x, h, t, dt, normal, FL);
20 landslide::flux<T, Shortcuts>(QR, x, h, t, dt, normal, FR);
21
22 const auto smax{std::fmax(
23 std::fmax(
24 ShallowWater::maxEigenvalue<T, Shortcuts>(QL, x, h, t, dt, normal),
25 ShallowWater::maxEigenvalue<T, Shortcuts>(QR, x, h, t, dt, normal)
26 ),
27 std::fmax(
28 landslide::maxEigenvalue<T, Shortcuts>(QL, x, h, t, dt, normal),
29 landslide::maxEigenvalue<T, Shortcuts>(QR, x, h, t, dt, normal)
30 )
31 )};
32 const auto N{NumberOfAuxiliaryVariables + NumberOfUnknowns};
33
34 double Qavg[N] = {};
35 double DeltaQ[N] = {};
36 for (int i = 0; i < NumberOfUnknowns; ++i) {
37 Qavg[i] = 0.5 * (QL[i] + QR[i]);
38 DeltaQ[i] = QR[i] - QL[i];
39 FL[i] = 0.5 * (FL[i] + FR[i] - smax * DeltaQ[i]);
40 FR[i] = FL[i];
41 }
42
43 for (int i = NumberOfUnknowns; i < N; ++i) {
44 Qavg[i] = 0.5 * (QL[i] + QR[i]);
45 DeltaQ[i] = QR[i] - QL[i];
46 }
47
48 double ncp[NumberOfUnknowns] = {};
49 ShallowWater::nonconservativeProduct<T, Shortcuts, NumberOfUnknowns>(Qavg, DeltaQ, x, h, t, dt, normal, ncp);
50 landslide::nonconservativeProduct<T, Shortcuts>(Qavg, DeltaQ, x, h, t, dt, normal, ncp);
51 for (int i = 0; i < NumberOfUnknowns; ++i) {
52 FL[i] += 0.5 * ncp[i];
53 FR[i] -= 0.5 * ncp[i];
54 }
55
56 auto sL{0.0};
57 if (QL[Shortcuts::lsh] > hThreshold) {
58 const auto hL{QL[Shortcuts::lsh] > hThreshold ? QL[Shortcuts::lsh] : hThreshold};
59 const auto momentumL{
60 std::sqrt(QL[Shortcuts::lshu] * QL[Shortcuts::lshu] + QL[Shortcuts::lshv] * QL[Shortcuts::lshv])
61 };
62 sL = 2.0 * g * momentumL * invXi / (hL * hL);
63 }
64
65 auto sR{0.0};
66 if (QL[Shortcuts::lsh] > hThreshold) {
67 const auto hR{QR[Shortcuts::lsh] > hThreshold ? QR[Shortcuts::lsh] : hThreshold};
68 const auto momentumR{
69 std::sqrt(QR[Shortcuts::lshu] * QR[Shortcuts::lshu] + QR[Shortcuts::lshv] * QR[Shortcuts::lshv])
70 };
71 sR = 2.0 * g * momentumR * invXi / (hR * hR);
72 }
73
74 return std::fmax(smax, h[normal] * std::fmax(sL, sR));
75}
static GPU_CALLABLE_METHOD double rusanovRiemannSolverFV(const T *const NOALIAS QL, const T *const NOALIAS QR, const tarch::la::Vector< DIMENSIONS, double > &x, const tarch::la::Vector< DIMENSIONS, double > &h, const double t, const double dt, const int normal, T *const NOALIAS FL, T *const NOALIAS FR)