Peano
Loading...
Searching...
No Matches
PDE.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 void applications::exahype2::landslide::flux(
6 const T* const NOALIAS Q,
7 const tarch::la::Vector<DIMENSIONS, double>& x,
8 const tarch::la::Vector<DIMENSIONS, double>& h,
9 const double t,
10 const double dt,
11 const int normal,
12 T* const NOALIAS F
13) {
14 if (Q[Shortcuts::lsh] <= hThreshold) {
15 return;
16 }
17
18 const auto Vn{Q[Shortcuts::lshu + normal] / Q[Shortcuts::lsh]};
19 F[Shortcuts::lsh] = Q[Shortcuts::lshu + normal]; // Mass flux
20 F[Shortcuts::lshu] = Vn * Q[Shortcuts::lshu]; // Momentum-x flux
21 F[Shortcuts::lshv] = Vn * Q[Shortcuts::lshv]; // Momentum-y flux
22 // F[Shortcuts::lshu + normal] += 0.5 * g * Q[Shortcuts::lsh] * Q[Shortcuts::lsh]; // Hydrostatic pressure
23}
24
25template <class T, class Shortcuts>
26static inline GPU_CALLABLE_METHOD double applications::exahype2::landslide::maxEigenvalue(
27 const T* const NOALIAS Q,
28 const tarch::la::Vector<DIMENSIONS, double>& x,
29 const tarch::la::Vector<DIMENSIONS, double>& h,
30 const double t,
31 const double dt,
32 const int normal
33) {
34 // Landslide eigenvalue
35 T sFlux = 0.00;
36 if (Q[Shortcuts::lsh] > hThreshold) { // only if enough granular material present
37 const auto Vn{Q[Shortcuts::lshu + normal] / Q[Shortcuts::lsh]};
38 const auto c{std::sqrt(g * Q[Shortcuts::lsh])};
39 sFlux = std::fmax(std::fabs(Vn + c), std::fabs(Vn - c));
40 }
41 return sFlux;
42}
43
44template <class T, class Shortcuts>
45static inline GPU_CALLABLE_METHOD void applications::exahype2::landslide::nonconservativeProduct(
46 const T* const NOALIAS Q,
47 const T* const NOALIAS deltaQ,
48 const tarch::la::Vector<DIMENSIONS, double>& x,
49 const tarch::la::Vector<DIMENSIONS, double>& h,
50 const double t,
51 const double dt,
52 const int normal,
53 T* const NOALIAS BTimesDeltaQ
54) {
55 if (Q[Shortcuts::lsh] <= hThreshold) {
56 return;
57 }
58
59 // Bathymetry/topography-related effects
60 BTimesDeltaQ[Shortcuts::lshu + normal] = g * Q[Shortcuts::lsh] * (deltaQ[Shortcuts::lsh] + deltaQ[Shortcuts::z]);
61
62 // Compute stiff turbulent drag on the interface
63 const auto momentumSQR{Q[Shortcuts::lshu] * Q[Shortcuts::lshu] + Q[Shortcuts::lshv] * Q[Shortcuts::lshv]};
64 const auto momentum{std::sqrt(momentumSQR)};
65 if (tarch::la::greater(momentum / Q[Shortcuts::lsh], 0.0)) {
66 const auto turbulentDrag{g * momentumSQR * invXi / (Q[Shortcuts::lsh] * Q[Shortcuts::lsh])};
67 const auto directionVect{Q[Shortcuts::lshu + normal] / momentum};
68 BTimesDeltaQ[Shortcuts::lshu + normal] += h[normal] * turbulentDrag * directionVect;
69 }
70
71 BTimesDeltaQ[Shortcuts::hu + normal] += g * Q[Shortcuts::h] * deltaQ[Shortcuts::lsh];
72}
73
74template <class T, class Shortcuts, int NumberOfUnknowns, int NumberOfAuxiliaryVariables>
75static inline GPU_CALLABLE_METHOD void applications::exahype2::landslide::diffusiveSourceTerm(
76 [[maybe_unused]] const T* const NOALIAS Q, // Q[4+0]
77 [[maybe_unused]] const T* const NOALIAS deltaQ, // deltaQ[2 * (4+0)]
78 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
79 [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
80 [[maybe_unused]] const double t,
81 [[maybe_unused]] const double dt,
82 [[maybe_unused]] T* const NOALIAS S // S[4]
83) {
84
85 for (int n = 0; n < NumberOfUnknowns; n++) {
86 S[n] = 0.0;
87 }
88
89 if (Q[Shortcuts::lsh] <= hThreshold) {
90 return;
91 }
92
93 // Compute local slope cF
94 const auto dzx{deltaQ[Shortcuts::z]};
95 const auto dzy{deltaQ[Shortcuts::z + NumberOfUnknowns + NumberOfAuxiliaryVariables]};
96 const auto cF{1.0 / std::sqrt(1.0 + dzx * dzx + dzy * dzy)};
97
98 // Apply friction only if there is some movement
99 const auto momentumSQR{Q[Shortcuts::lshu] * Q[Shortcuts::lshu] + Q[Shortcuts::lshv] * Q[Shortcuts::lshv]};
100 const auto momentum{std::sqrt(momentumSQR)};
101 if (tarch::la::greater(momentum / Q[Shortcuts::lsh], 0.0)) {
102 const auto coulombFriction{mu * cF * Q[Shortcuts::lsh]};
103 const auto frictionTerm{-g * coulombFriction / momentum};
104 S[Shortcuts::lshu] = Q[Shortcuts::lshu] * frictionTerm;
105 S[Shortcuts::lshv] = Q[Shortcuts::lshv] * frictionTerm;
106 }
107}
static GPU_CALLABLE_METHOD void diffusiveSourceTerm(const T *const NOALIAS Q, const T *const NOALIAS deltaQ, const tarch::la::Vector< DIMENSIONS, double > &x, const tarch::la::Vector< DIMENSIONS, double > &h, const double t, const double dt, T *const NOALIAS S)
Definition PDE.cpph:75
static GPU_CALLABLE_METHOD double maxEigenvalue(const T *const NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &x, const tarch::la::Vector< DIMENSIONS, double > &h, const double t, const double dt, const int normal)
static GPU_CALLABLE_METHOD void flux(const T *const NOALIAS Q, 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 F)
static GPU_CALLABLE_METHOD void nonconservativeProduct(const T *const NOALIAS Q, const T *const NOALIAS deltaQ, 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 BTimesDeltaQ)