Peano
Loading...
Searching...
No Matches
Rusanov.py
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
4rusanov_aderdg = r"""
5 // Compute average left and right states
6 const auto N{NumberOfUnknowns + NumberOfAuxiliaryVariables};
7 double QavgL[N] = {};
8 double QavgR[N] = {};
9 for (auto xy = 0; xy < Order + 1; ++xy) {
10 for (auto i = 0; i < N; ++i) {
11 QavgL[i] += kernels::{{SOLVER_NAME}}::Quadrature<double>::weights2[xy] * QL[xy * N + i];
12 QavgR[i] += kernels::{{SOLVER_NAME}}::Quadrature<double>::weights2[xy] * QR[xy * N + i];
13 }
14 }
15
16 // Wave speed estimation based on the flux Jacobian
17 auto sL{0.0};
18 if (QavgL[Shortcuts::h] > hThreshold) {
19 const auto VnL{QavgL[Shortcuts::hu + direction] / QavgL[Shortcuts::h]};
20 const auto cL{std::sqrt(g * QavgL[Shortcuts::h])};
21 sL = std::fmax(std::fabs(VnL - cL), std::fabs(VnL + cL));
22 }
23 auto sR{0.0};
24 if (QavgR[Shortcuts::h] > hThreshold) {
25 const auto VnR{QavgR[Shortcuts::hu + direction] / QavgR[Shortcuts::h]};
26 const auto cR{std::sqrt(g * QavgR[Shortcuts::h])};
27 sR = std::fmax(std::fabs(VnR - cR), std::fabs(VnR + cR));
28 }
29 const auto smax{std::fmax(sR, sL)};
30
31 auto j{0};
32 auto rusanovFlux{0.0};
33 for (auto xy = 0; xy < Order + 1; ++xy) {
34 for (auto i = 0; i < N; ++i) {
35 j = xy * N + i;
36 rusanovFlux = 0.5 * (FL[j] + FR[j] + smax * (QL[j] - QR[j]));
37 FL[j] = rusanovFlux;
38 FR[j] = rusanovFlux;
39 }
40 // Ignore flux for flow topography
41 j = xy * N + Shortcuts::z;
42 FL[j] = 0.0;
43 FR[j] = 0.0;
44 }
45"""
46
47rusanov_fv = r"""
48 flux(QL, x, h, t, dt, normal, FL);
49 flux(QR, x, h, t, dt, normal, FR);
50
51 const auto smax{std::fmax(maxEigenvalue(QL, x, h, t, dt, normal), maxEigenvalue(QR, x, h, t, dt, normal))};
52 const auto N{NumberOfAuxiliaryVariables + NumberOfUnknowns};
53
54 double Qavg[N] = {};
55 double DeltaQ[N] = {};
56 for (int i = 0; i < NumberOfUnknowns; ++i) {
57 Qavg[i] = 0.5 * (QL[i] + QR[i]);
58 DeltaQ[i] = QR[i] - QL[i];
59 FL[i] = 0.5 * (FL[i] + FR[i] - smax * DeltaQ[i]);
60 FR[i] = FL[i];
61 }
62
63 for (int i = NumberOfUnknowns; i < N; ++i) {
64 Qavg[i] = 0.5 * (QL[i] + QR[i]);
65 DeltaQ[i] = QR[i] - QL[i];
66 }
67
68 /*
69 double ncp[NumberOfUnknowns] = {};
70 nonconservativeProduct(Qavg, DeltaQ, x, h, t, dt, normal, ncp);
71 for (int i = 0; i < NumberOfUnknowns; ++i) {
72 FL[i] += 0.5 * ncp[i];
73 FR[i] -= 0.5 * ncp[i];
74 }
75 */
76
77 auto sL{0.0};
78 if (QL[Shortcuts::h] > hThreshold) {
79 const auto hL{QL[Shortcuts::h] > hThreshold ? QL[Shortcuts::h] : hThreshold};
80 const auto momentumL{std::sqrt(QL[Shortcuts::hu] * QL[Shortcuts::hu] + QL[Shortcuts::hv] * QL[Shortcuts::hv])};
81 sL = 2.0 * g * momentumL * invXi / (hL * hL);
82 }
83
84 auto sR{0.0};
85 if (QL[Shortcuts::h] > hThreshold) {
86 const auto hR{QR[Shortcuts::h] > hThreshold ? QR[Shortcuts::h] : hThreshold};
87 const auto momentumR{std::sqrt(QR[Shortcuts::hu] * QR[Shortcuts::hu] + QR[Shortcuts::hv] * QR[Shortcuts::hv])};
88 sR = 2.0 * g * momentumR * invXi / (hR * hR);
89 }
90
91 return std::fmax(smax, h[normal] * std::fmax(sL, sR));
92"""