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