Peano
Loading...
Searching...
No Matches
SourceTerm.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#pragma once
4
8#include "Constants.h"
9
10template <class T, class Shortcuts, int NumberOfUnknowns, int NumberOfAuxiliaryVariables>
11static inline GPU_CALLABLE_METHOD void applications::exahype2::ShallowWater::meteotsunami::sourceTerm(
12 const T* const NOALIAS Q,
13 const tarch::la::Vector<DIMENSIONS, double>& x,
14 const tarch::la::Vector<DIMENSIONS, double>& h,
15 const double t,
16 const double dt,
17 T* const NOALIAS S
18) {
19 namespace constants = ::applications::exahype2::ShallowWater;
20
21 // Default values
22 for (std::size_t n = 0; n < NumberOfUnknowns; n++) {
23 S[n] = 0.0;
24 }
25
26 // Check water level if too small
27 if (Q[Shortcuts::h] <= constants::hThreshold) {
28 return;
29 }
30
31 const auto xCoord = x(0);
32 const auto yCoord = x(1);
33
34 // Update Source term
35
36 // Corriolis force
37 S[Shortcuts::hu] = applications::exahype2::ShallowWater::coriolisForce::constant<constants::corriolis_param>()
38 * Q[Shortcuts::hv];
39 S[Shortcuts::hv] = -applications::exahype2::ShallowWater::coriolisForce::constant<constants::corriolis_param>()
40 * Q[Shortcuts::hu];
41
42 // Bottom/Manning friction
44 constants::g,
45 constants::manning_param>(Q[Shortcuts::h], Q[Shortcuts::hu], Q[Shortcuts::hv])
46 * Q[Shortcuts::hu];
48 constants::g,
49 constants::manning_param>(Q[Shortcuts::h], Q[Shortcuts::hu], Q[Shortcuts::hv])
50 * Q[Shortcuts::hv];
51
52 // Function wrapper for partial derivative
53 auto wrapperAtmosphericPressure = [](const auto x, const auto y, const auto t) {
55 constants::pressure,
56 constants::speed_pressure,
57 constants::period_pressure,
58 constants::background_pressure>(x, y, t);
59 };
60
61 // Atmospheric pressure forcing
62 S[Shortcuts::hu] += -Q[Shortcuts::h] * numerics::_3D::partialX(wrapperAtmosphericPressure, xCoord, yCoord, t)
63 / constants::water_density;
64 S[Shortcuts::hv] += -Q[Shortcuts::h] * numerics::_3D::partialY(wrapperAtmosphericPressure, xCoord, yCoord, t)
65 / constants::water_density;
66}
static auto atmosphericPressure(const auto x, const auto y, const auto t)
Computes the pressure field p(x, y, t) following the Jörn test-case logic.
static auto manningFriction(const auto h, const auto hu, const auto hv)
Computes the Manning bottom friction.
static GPU_CALLABLE_METHOD void sourceTerm(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, T *const NOALIAS S)
static auto partialX(auto f, const auto x, const auto y, const auto t)
Approximates the partial derivative ∂f/∂x of a function f(x, y, t) using central differences.
static auto partialY(auto f, const auto x, const auto y, const auto t)
Approximates the partial derivative ∂f/∂y of a function f(x, y, t) using central differences.