ryujin 2.1.1 revision ef0fcd4010d109b860652ece4a7b8963fb7d46b1
initial_state_three_bumps_dam_break.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
10#include <compile_time_options.h>
11
13
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
24 template <typename Description, int dim, typename Number>
25 class ThreeBumpsDamBreak : public InitialState<Description, dim, Number>
26 {
27 public:
29 using View =
30 typename Description::template HyperbolicSystemView<dim, Number>;
31 using state_type = typename View::state_type;
32
33 ThreeBumpsDamBreak(const HyperbolicSystem &hyperbolic_system,
34 const std::string subsection)
35 : InitialState<Description, dim, Number>("three bumps dam break",
36 subsection)
37 , hyperbolic_system_(hyperbolic_system)
38 {
39 well_balancing_validation = false;
40 this->add_parameter(
41 "well balancing validation",
42 well_balancing_validation,
43 "If set to true then the initial profile is returned for all "
44 "times "
45 "(t>0); otherwise a constant inflow is computed for t>0 suitable "
46 "for prescribing Dirichlet conditions at the inflow boundary.");
47
48
49 left_depth = 1.875;
50 this->add_parameter("left water depth",
51 left_depth,
52 "Depth of water to the left of pseudo-dam");
53 right_depth = 0.;
54 this->add_parameter("right water depth",
55 right_depth,
56 "Depth of water to the right of pseudo-dam");
57
58 cone_magnitude = 1.;
59 this->add_parameter("cone magnitude",
60 cone_magnitude,
61 "To modify magnitude of cone heights");
62 }
63
64 state_type compute(const dealii::Point<dim> &point, Number t) final
65 {
66 const auto view = hyperbolic_system_.template view<dim, Number>();
67
68 const Number x = point[0];
69
70 /* Initial state: */
71
72 if (t <= 1.e-10 || well_balancing_validation) {
73 Number h = x < 16. ? left_depth : right_depth;
74 h = std::max(h - compute_bathymetry(point), Number(0.));
75 return state_type{{h, 0.}};
76 }
77
78 /* For t > 0 prescribe constant inflow Dirichlet data on the left: */
79
80 const auto &h = left_depth;
81 const auto a = view.speed_of_sound(state_type{{h, Number(0.)}});
82 return state_type{{h, h * a}};
83 }
84
85 auto initial_precomputations(const dealii::Point<dim> &point) ->
87 initial_precomputed_type final
88 {
89 /* Compute bathymetry: */
90 return {compute_bathymetry(point)};
91 }
92
93 private:
94 const HyperbolicSystem &hyperbolic_system_;
95
96 DEAL_II_ALWAYS_INLINE inline Number
97 compute_bathymetry(const dealii::Point<dim> &point) const
98 {
99 if constexpr (dim == 1) {
100 /* When dim = 1, we only have one cone */
101 const Number &x = point[0];
102
103 Number z3 = 3. - 3. / 10. * std::sqrt(std::pow(x - 47.5, 2));
104 return cone_magnitude * std::max({z3, Number(0.)});
105 }
106
107 const Number &x = point[0];
108 const Number &y = point[1];
109
110 Number z1 =
111 1. -
112 1. / 8. * std::sqrt(std::pow(x - 30., 2) + std::pow(y - 6., 2));
113
114 Number z2 =
115 1. -
116 1. / 8. * std::sqrt(std::pow(x - 30., 2) + std::pow(y - 24., 2));
117
118 Number z3 =
119 3. -
120 3. / 10. * std::sqrt(std::pow(x - 47.5, 2) + std::pow(y - 15., 2));
121
122 return cone_magnitude * std::max({z1, z2, z3, Number(0.)});
123 }
124
125 bool well_balancing_validation;
126 Number left_depth;
127 Number right_depth;
128 Number cone_magnitude;
129 };
130
131 } // namespace ShallowWaterInitialStates
132} // namespace ryujin
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
state_type compute(const dealii::Point< dim > &point, Number t) final
ThreeBumpsDamBreak(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::template HyperbolicSystemView< dim, Number > View
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:34