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