ryujin 2.1.1 revision 336b16a72e829721302c626ec7071b92032b8248
initial_state_paraboloid.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0
3// [LANL Copyright Statement]
4// Copyright (C) 2022 - 2024 by the ryujin authors
5// Copyright (C) 2023 - 2024 by Triad National Security, LLC
6//
7
8#pragma once
9
11
12namespace ryujin
13{
14 namespace ShallowWaterInitialStates
15 {
28 template <typename Description, int dim, typename Number>
29 class Paraboloid : public InitialState<Description, dim, Number>
30 {
31 public:
33 using View =
34 typename Description::template HyperbolicSystemView<dim, Number>;
35 using state_type = typename View::state_type;
36
37 Paraboloid(const HyperbolicSystem &hyperbolic_system,
38 const std::string subsection)
39 : InitialState<Description, dim, Number>("paraboloid", subsection)
40 , hyperbolic_system_(hyperbolic_system)
41 {
42 a_ = 1.;
43 this->add_parameter(
44 "free surface radius", a_, "Radius of the circular free surface");
45
46 h_0_ = 0.1;
47 this->add_parameter(
48 "water height", h_0_, "Water height at central point");
49
50 if constexpr (dim == 1) {
51
52 length_ = 10000.;
53 this->add_parameter(
54 "paraboloid length", length_, "Length of 1D paraboloid");
55
56 B_ = 2.;
57 this->add_parameter("speed", B_, "The 1D paraboloid speed");
58
59 } else {
60 eta_ = 0.5;
61 this->add_parameter("eta", eta_, "The eta parameter");
62 }
63 }
64
65 state_type compute(const dealii::Point<dim> &point, Number t) final
66 {
67 const auto view = hyperbolic_system_.template view<dim, Number>();
68
69 /* Common quantities */
70 const auto z = compute_bathymetry(point);
71 const auto g = view.gravity();
72 const Number omega = std::sqrt(2. * g * h_0_) / a_;
73 const Number &x = point[0];
74
75 /* Initialize primitive variables */
76 Number h, v_x, v_y = 0.;
77
78 /* Define slightly different profiles for each dimension */
79
80 if constexpr (dim == 1) {
81
82 const Number k = view.manning_friction_coefficient();
83 const Number p = std::sqrt(8. * g * h_0_) / a_;
84 const Number s = std::sqrt(p * p - k * k) / 2.;
85
86 auto term1 =
87 (a_ * a_ * B_ * B_) / (8. * g * g * h_0_) * std::exp(-k * t);
88 term1 *= (1. / 4. * k * k - s * s) * std::cos(2. * s * t) -
89 s * k * sin(2. * s * t);
90
91 const auto term2 = -(B_ * B_ / (4. * g)) * std::exp(-k * t);
92
93 auto term3 = -(B_ / g) * std::exp(-1. / 2. * k * t);
94 term3 *= (s * std::cos(s * t) + 1. / 2. * k * std::sin(s * t)) *
95 (point[0] - 1. / 2. * length_);
96
97 auto htilde = h_0_ - compute_bathymetry(point);
98 htilde += term1 + term2 + term3;
99
100 h = std::max(htilde, Number(0.));
101 v_x = B_ * std::exp(-1. / 2. * k * t) * std::sin(s * t);
102
103 return state_type{{h, h * v_x}};
104 } else if constexpr (dim == 2) {
105
106 const Number &y = point[1];
107
108 const Number elevation =
109 eta_ * h_0_ / (a_ * a_) *
110 (2. * x * std::cos(omega * t) + 2. * y * std::sin(omega * t));
111
112 h = std::max(elevation - z, Number(0.));
113 v_x = -eta_ * omega * std::sin(omega * t);
114 v_y = eta_ * omega * std::cos(omega * t);
115
116 return state_type{{h, h * v_x, h * v_y}};
117
118 } else {
119 AssertThrow(false, dealii::ExcNotImplemented());
120 __builtin_trap();
121 }
122 }
123
124
125 auto initial_precomputations(const dealii::Point<dim> &point) ->
127 initial_precomputed_type final
128 {
129 /* Compute bathymetry: */
130 return {compute_bathymetry(point)};
131 }
132
133 private:
134 const HyperbolicSystem &hyperbolic_system_;
135
136 DEAL_II_ALWAYS_INLINE inline Number
137 compute_bathymetry(const dealii::Point<dim> &point) const
138 {
139 if constexpr (dim == 1)
140 return h_0_ / (a_ * a_) * std::pow(point[0] - 0.5 * length_, 2);
141 else
142 return -h_0_ * (Number(1.) - point.norm_square() / (a_ * a_));
143 }
144
145 Number a_;
146 Number h_0_;
147 Number eta_;
148 Number length_;
149 Number B_;
150 };
151
152 } // namespace ShallowWaterInitialStates
153} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
Paraboloid(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
state_type compute(const dealii::Point< dim > &point, Number t) final
typename Description::template HyperbolicSystemView< dim, Number > View
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32