Peano
fvSWE.cpp
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 #include "fvSWE.h"
4 #include "exahype2/RefinementControl.h"
5 
6 tarch::logging::Log exahype::limiting::swe::fvSWE::_log( "exahype::limiting::swe::fvSWE" );
7 
8 
10  [[maybe_unused]] const double* const NOALIAS Q, // Q[3+1]
11  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
12  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
13  [[maybe_unused]] const double t,
14  [[maybe_unused]] const double dt,
15  [[maybe_unused]] const int normal,
16  [[maybe_unused]] double* const NOALIAS L
17 ) {
18 
19  static constexpr double g = 9.81;
20 
21  const double u = Q[0] > 1e-5 ? Q[1 + normal] / Q[0] : 0.0;
22  const double c = Q[0] > 1e-5 ? sqrt(g * Q[0]) : 0.0;
23  L[0] = u;
24  L[1] = u + c;
25  L[2] = u - c;
26 
27 }
28 
30  [[maybe_unused]] const double* const NOALIAS Q, // Q[3+1]
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 double dt,
35  [[maybe_unused]] const int normal,
36  [[maybe_unused]] double* const NOALIAS F // F[3]
37 ) {
38 
39  static constexpr double g = 9.81;
40 
41  const double ih = Q[0] > 1e-5 ? 1.0 / Q[0] : 0.0;
42  F[0] = Q[1 + normal];
43  F[1 + 0] = ih * Q[1 + normal] * Q[1 + 0];
44  F[1 + 1] = ih * Q[1 + normal] * Q[1 + 1];
45  F[1 + normal] += 0.5 * g * Q[0] * Q[0];
46 
47 }
48 
49 extern "C" {
51  const double* NOALIAS ql,
52  const double* NOALIAS qr,
53  double* NOALIAS amdq,
54  double* NOALIAS apdq, const int* normal);
55 }
56 
57 double exahype::limiting::swe::fvSWE::solveRiemannProblem(
58  [[maybe_unused]] const double* const NOALIAS QL, // QL[3+1]
59  [[maybe_unused]] const double* const NOALIAS QR, // QR[3+1]
60  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
61  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
62  [[maybe_unused]] const double t,
63  [[maybe_unused]] const double dt,
64  [[maybe_unused]] const int normal,
65  [[maybe_unused]] double* const NOALIAS FL, // FL[3]
66  [[maybe_unused]] double* const NOALIAS FR // FR[3]
67 ) {
68 #if 0
69  double smax = rpn2_augmented_wrapper(QL, QR, FL, FR, &normal);
70 #else
71  const double cL = std::sqrt(9.81 * QL[0]);
72  double uL = QL[normal + 1] * QL[0] * std::sqrt(2)/std::sqrt(std::pow(QL[0], 4) + std::pow(std::max(QL[0], 1e-5), 4));
73 
74  double smaxL = std::max(std::abs(uL - cL), std::abs(uL + cL));
75 
76  const double cR = std::sqrt(9.81 * QR[0]);
77  double uR = QR[normal + 1] * QR[0] * std::sqrt(2)/std::sqrt(std::pow(QR[0], 4) + std::pow(std::max(QR[0], 1e-5), 4));
78 
79  double smaxR = std::max(std::abs(uR - cR), std::abs(uR + cR));
80 
81  double smax = std::max(smaxL, smaxR);
82 
83  // double smax = std::max(smax, maxEigenvalue(QL, x, h, t, dt, normal));
84  // smax = std::max(smax, maxEigenvalue(QR, x, h, t, dt, normal));
85 
86  flux(QL, x, h, t, dt, normal, FL);
87  flux(QR, x, h, t, dt, normal, FR);
88 
89  // h gets added term from bathimetry, u and v are regular Rusanov, b does not change
90  FL[0] = 0.5*(FL[0]+FR[0] + smax*(QL[0]+QL[3]-QR[0]-QR[3]) );
91  FL[1] = 0.5*(FL[1]+FR[1] + smax*(QL[1]-QR[1]) );
92  FL[2] = 0.5*(FL[2]+FR[2] + smax*(QL[2]-QR[2]) );
93  // FL[3] = 0.0;
94 
95  FR[0] = FL[0];
96  FR[1] = FL[1];
97  FR[2] = FL[2];
98  // FR[3] = 0.0;
99 
100  //Contribution from NCP
101  FL[normal+1] += 0.5*9.81*0.5*(QL[0]+QR[0])*(QR[3]-QL[3]);
102  FR[normal+1] -= 0.5*9.81*0.5*(QL[0]+QR[0])*(QR[3]-QL[3]);
103 #endif
104 
105  return smax;
106 }
double rpn2_augmented_wrapper(const double *NOALIAS ql, const double *NOALIAS qr, double *NOALIAS amdq, double *NOALIAS apdq, const int *normal)
u
Definition: euler.py:113
flux
Definition: euler.py:29
g
Definition: swe.py:85
h
Definition: swe.py:79
tarch::logging::Log _log
This is variant 1 of the fused kernels.