Peano
Loading...
Searching...
No Matches
LLFRiemannSolver.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>
5static inline GPU_CALLABLE_METHOD double applications::exahype2::ShallowWater::llfRiemannSolver(
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 const T hLeft = QL[Shortcuts::h];
17 const T hRight = QR[Shortcuts::h];
18 const T huLeft = QL[Shortcuts::hu];
19 const T huRight = QR[Shortcuts::hu];
20 const T hvLeft = QL[Shortcuts::hu + 1];
21 const T hvRight = QR[Shortcuts::hu + 1];
22 const T bLeft = QL[Shortcuts::z];
23 const T bRight = QR[Shortcuts::z];
24
25 const T dryTol = std::pow(h[0], 4);
26
27 // Correction of particle velocities according to Kurganov (modified version):
28 const T uCorrectedLeft = huLeft * hLeft * std::sqrt(2)
29 / std::sqrt(std::pow(hLeft, 4) + std::pow(std::fmax(hLeft, dryTol), 4));
30 const T uCorrectedRight = huRight * hRight * std::sqrt(2)
31 / std::sqrt(std::pow(hRight, 4) + std::pow(std::fmax(hRight, dryTol), 4));
32 const T vCorrectedLeft = hvLeft * hLeft * std::sqrt(2)
33 / std::sqrt(std::pow(hLeft, 4) + std::pow(std::fmax(hLeft, dryTol), 4));
34 const T vCorrectedRight = hvRight * hRight * std::sqrt(2)
35 / std::sqrt(std::pow(hRight, 4) + std::pow(std::fmax(hRight, dryTol), 4));
36
37 // Determine the maximal bathymetry, and reconstruct the left and right height based on it
38 const T bathymetryMax = std::fmax(QR[Shortcuts::z], QL[Shortcuts::z]);
39 const T reconstructedHeightLeft = std::fmax(0.0, QL[Shortcuts::h] + QL[Shortcuts::z] - bathymetryMax);
40 const T reconstructedHeightRight = std::fmax(0.0, QR[Shortcuts::h] + QR[Shortcuts::z] - bathymetryMax);
41
42 // Also reconstruct the momentum based on the reconstructed height
43 const T reconstructedHuLeft = reconstructedHeightLeft * uCorrectedLeft;
44 const T reconstructedHvLeft = reconstructedHeightLeft * vCorrectedLeft;
45 const T reconstructedHuRight = reconstructedHeightRight * uCorrectedRight;
46 const T reconstructedHvRight = reconstructedHeightRight * vCorrectedRight;
47
48 const T cLeft = std::sqrt(g * reconstructedHeightLeft);
49 const T cRight = std::sqrt(g * reconstructedHeightRight);
50
51 const T LL[3]{
52 normal == 0 ? uCorrectedLeft + cLeft : vCorrectedLeft + cLeft,
53 normal == 0 ? uCorrectedLeft - cLeft : vCorrectedLeft - cLeft,
54 normal == 0 ? uCorrectedLeft : vCorrectedLeft
55 };
56
57 const T LR[3]{
58 normal == 0 ? uCorrectedRight + cRight : vCorrectedRight + cRight,
59 normal == 0 ? uCorrectedRight - cRight : vCorrectedRight - cRight,
60 normal == 0 ? uCorrectedRight : vCorrectedRight
61 };
62
63 T maxWaveSpeed = 0.0;
64
65 for (int i = 0; i < 3; i++) {
66 const T absEigenvalueLeft = std::fabs(LL[i]);
67 maxWaveSpeed = std::fmax(absEigenvalueLeft, maxWaveSpeed);
68 }
69
70 for (int i = 0; i < 3; i++) {
71 const T absEigenvalueRight = std::fabs(LR[i]);
72 maxWaveSpeed = std::fmax(absEigenvalueRight, maxWaveSpeed);
73 }
74
75 const T fluxLeft[3]{
76 normal == 0 ? reconstructedHuLeft : reconstructedHvLeft,
77 normal == 0
78 ? reconstructedHeightLeft * uCorrectedLeft * uCorrectedLeft
79 + 0.5 * g * (reconstructedHeightLeft * reconstructedHeightLeft)
80 : reconstructedHeightLeft * vCorrectedLeft * uCorrectedLeft,
81 normal == 0
82 ? reconstructedHeightLeft * uCorrectedLeft * vCorrectedLeft
83 : reconstructedHeightLeft * vCorrectedLeft * vCorrectedLeft
84 + 0.5 * g * (reconstructedHeightLeft * reconstructedHeightLeft)
85 };
86
87 const T fluxRight[3]{
88 normal == 0 ? reconstructedHuRight : reconstructedHvRight,
89 normal == 0
90 ? reconstructedHeightRight * uCorrectedRight * uCorrectedRight
91 + 0.5 * g * (reconstructedHeightRight * reconstructedHeightRight)
92 : reconstructedHeightRight * vCorrectedRight * uCorrectedRight,
93 normal == 0
94 ? reconstructedHeightRight * uCorrectedRight * vCorrectedRight
95 : reconstructedHeightRight * vCorrectedRight * vCorrectedRight
96 + 0.5 * g * (reconstructedHeightRight * reconstructedHeightRight)
97 };
98
99 const T deltaEta = reconstructedHeightRight - reconstructedHeightLeft;
100
101 // Modified Rusanov Flux
102 T netUpdates[3]{
103 0.5 * (fluxLeft[Shortcuts::h] + fluxRight[Shortcuts::h]) - 0.5 * maxWaveSpeed * deltaEta,
104 0.5 * (fluxLeft[Shortcuts::hu] + fluxRight[Shortcuts::hu])
105 - 0.5 * maxWaveSpeed * (reconstructedHuRight - reconstructedHuLeft),
106 0.5 * (fluxLeft[Shortcuts::hu + 1] + fluxRight[Shortcuts::hu + 1])
107 - 0.5 * maxWaveSpeed * (reconstructedHvRight - reconstructedHvLeft)
108 };
109
110 // Now include the source term already in the fluctuation computation
111 // Source term is based on the reconstructed water heights (for well-balancedness)
112 T sourceLeft[3] = {
113 0,
114 normal == 0
115 ? g * 0.5 * ((QL[Shortcuts::h] * QL[Shortcuts::h]) - (reconstructedHeightLeft * reconstructedHeightLeft))
116 : 0.0,
117 normal == 0
118 ? 0.0
119 : g * 0.5 * ((QL[Shortcuts::h] * QL[Shortcuts::h]) - (reconstructedHeightLeft * reconstructedHeightLeft))
120 };
121 T sourceRight[3] = {
122 0,
123 normal == 0
124 ? g * 0.5 * ((QR[Shortcuts::h] * QR[Shortcuts::h]) - (reconstructedHeightRight * reconstructedHeightRight))
125 : 0.0,
126 normal == 0
127 ? 0.0
128 : g * 0.5 * ((QR[Shortcuts::h] * QR[Shortcuts::h]) - (reconstructedHeightRight * reconstructedHeightRight))
129 };
130
131 for (int i = 0; i < 3; i++) {
132 FL[i] = netUpdates[i] + sourceLeft[i];
133 FR[i] = netUpdates[i] + sourceRight[i];
134 }
135
136 return maxWaveSpeed;
137}
static GPU_CALLABLE_METHOD double llfRiemannSolver(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)
Implementation of a LLF-Riemann Solver with Hydrostatic Reconstruction for.