ryujin 2.1.1 revision 9dcb748690310d6a540ebb8b066d1a0834fc7604
initial_state_solitary_wave.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: MIT
3// Copyright (C) 2020 - 2023 by the ryujin authors
4//
5
6#pragma once
7
8#include "hyperbolic_system.h"
9#include <initial_state.h>
10
11namespace ryujin
12{
13 namespace ShallowWater
14 {
20 template <int dim, typename Number, typename state_type>
21 class SolitaryWave : public InitialState<dim, Number, state_type, 1>
22 {
23 public:
24 SolitaryWave(const HyperbolicSystem &hyperbolic_system,
25 const std::string subsec)
26 : InitialState<dim, Number, state_type, 1>("solitary wave", subsec)
27 , hyperbolic_system(hyperbolic_system)
28 {
29 depth_ = 0.5;
30 this->add_parameter("water depth", depth_, "Depth of still water");
31
32 amplitude_ = 0.2;
33 this->add_parameter(
34 "amplitude", amplitude_, "Solitary wave amplitude ");
35 }
36
37 state_type compute(const dealii::Point<dim> &point, Number t) final
38 {
39 const auto g = hyperbolic_system.gravity();
40 const Number x = point[0];
41
42 const Number celerity = std::sqrt(g * (amplitude_ + depth_));
43
44 const Number width =
45 std::sqrt(3. * amplitude_ /
46 (4. * std::pow(depth_, 2) * (amplitude_ + depth_)));
47
48 const Number sechSqd =
49 1. / std::pow(cosh(width * (x - celerity * t)), 2);
50
51 const Number wave = depth_ + amplitude_ * sechSqd;
52
53 const Number h = std::max(wave, Number(0.));
54 const Number v = celerity * (wave - depth_) / wave;
55
56 return hyperbolic_system.template expand_state<dim>(
58
59#if 0
60 // FIXME
61 if (this->hyperbolic_system.description() == "Hyperbolic Serre") {
62 const Number h_prime =
63 -2. * amplitude_ * width * tanh(width * (x - celerity * t)) * sechSqd;
64
65 final_state[3] = h * h;
66 final_state[4] =
67 -std::pow(h, 2) * (celerity * depth_ * h_prime) / std::pow(wave, 2);
68 final_state[5] = Number(0.);
69 }
70#endif
71 }
72
73 /* Default bathymetry of 0 */
74
75 private:
76 const HyperbolicSystem &hyperbolic_system;
77
78 Number depth_;
79 Number amplitude_;
80 };
81
82 } // namespace ShallowWater
83} // namespace ryujin
typename HyperbolicSystemView::state_type state_type
dealii::Tensor< 1, problem_dimension< dim >, Number > state_type
SolitaryWave(const HyperbolicSystem &hyperbolic_system, const std::string subsec)
state_type compute(const dealii::Point< dim > &point, Number t) final
T pow(const T x, const T b)