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
7#include "../ProjectionAEA.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 auto projectionFunctionForward = [](const auto lon, const auto lat) {
36 constants::aeaEllipsoidA,
37 constants::aeaEllipsoidE,
38 constants::aeaStdParallel1,
39 constants::aeaStdParallel2,
40 constants::aeaLon0,
41 constants::aeaLat0>(lon, lat);
42 };
43
44 auto projectionFunctionInverse = [](const auto x, const auto y) {
46 constants::aeaEllipsoidA,
47 constants::aeaEllipsoidE,
48 constants::aeaStdParallel1,
49 constants::aeaStdParallel2,
50 constants::aeaLon0,
51 constants::aeaLat0>(x, y);
52 };
53
54 const auto [lonCoord, latCoord] = projectionFunctionInverse(xCoord, yCoord);
55
56 // Update Source term
57
58 // Corriolis force
59 S[Shortcuts::hu] = applications::exahype2::ShallowWater::coriolisForce::sphere<constants::coriolis_omega>(latCoord)
60 * Q[Shortcuts::hv];
61 S[Shortcuts::hv] = -applications::exahype2::ShallowWater::coriolisForce::sphere<constants::coriolis_omega>(latCoord)
62 * Q[Shortcuts::hu];
63
64 // Bottom/Manning friction
66 constants::g,
67 constants::manning_param>(Q[Shortcuts::h], Q[Shortcuts::hu], Q[Shortcuts::hv])
68 * Q[Shortcuts::hu];
70 constants::g,
71 constants::manning_param>(Q[Shortcuts::h], Q[Shortcuts::hu], Q[Shortcuts::hv])
72 * Q[Shortcuts::hv];
73
74 // Function wrapper for partial derivative
75 auto wrapperAtmosphericPressure =
76 [projectionFunctionInverse, projectionFunctionForward](const auto x, const auto y, const auto t) {
78 constants::pointLonA,
79 constants::pointLatA,
80 constants::pointLonB,
81 constants::pointLatB>(x, y, t, projectionFunctionForward, projectionFunctionInverse);
82 };
83
84 // Atmospheric pressure forcing
85 S[Shortcuts::hu] += -Q[Shortcuts::h] * numerics::_3D::partialX(wrapperAtmosphericPressure, xCoord, yCoord, t)
86 / constants::water_density;
87 S[Shortcuts::hv] += -Q[Shortcuts::h] * numerics::_3D::partialY(wrapperAtmosphericPressure, xCoord, yCoord, t)
88 / constants::water_density;
89}
static auto atmosphericPressure(const auto x, const auto y, const auto t, auto projectionFunctionForward, auto projectionFunctionInverse)
Computes the moving atmospheric pressure disturbance for the Gulf of Mexico test case.
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.
static auto forward(const auto lonDeg, const auto latDeg)
static auto inverse(const auto x, const auto y)
Inverts the Albers Equal-Area Conic projection for WGS_1984 and returns the geographic coordinates (l...