ryujin 2.1.1 revision 9dcb748690310d6a540ebb8b066d1a0834fc7604
initial_state_triangular_dam_break.h
Go to the documentation of this file.
1
2#pragma once
3
4#include "hyperbolic_system.h"
5#include <initial_state.h>
6
7namespace ryujin
8{
9 namespace ShallowWater
10 {
16 template <int dim, typename Number, typename state_type>
17 class TriangularDamBreak : public InitialState<dim, Number, state_type, 1>
18 {
19 public:
20 TriangularDamBreak(const HyperbolicSystem &hyperbolic_system,
21 const std::string s)
22 : InitialState<dim, Number, state_type, 1>("triangular dam break", s)
23 , hyperbolic_system(hyperbolic_system)
24 {
25 left_depth = 0.75;
26 this->add_parameter("left resevoir depth",
27 left_depth,
28 "Depth of water at left resevoir");
29
30 left_position = 0.00;
31 this->add_parameter("left resevoir position",
32 left_position,
33 "Position of left resevoir");
34
35 right_depth = 0.15;
36 this->add_parameter("right resevoir depth",
37 right_depth,
38 "Depth of water at right resevoir");
39
40 right_position = 14.5;
41 this->add_parameter("right resevoir position",
42 right_position,
43 "Position of right resevoir");
44
45
46 step_position = 13.0;
47 this->add_parameter("step position",
48 step_position,
49 "Center position of the triangular step");
50
51 step_width = 6.0;
52 this->add_parameter(
53 "step width", step_width, "Total width of the triangular step");
54
55 step_height = 0.4;
56 this->add_parameter(
57 "step height", step_height, "Height of the triangular step");
58 }
59
60 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
61 {
62 const Number x = point[0];
63 const Number bath = compute_bathymetry(point);
64
65 /* Set water depths at the two resevoirs */
66 Number h = 0.;
67 if (x < left_position)
68 h = std::max(Number(0.), left_depth - bath);
69 else if (x > right_position)
70 h = std::max(Number(0.), right_depth - bath);
71
72 return hyperbolic_system.template expand_state<dim>(
74 }
75
76 auto initial_precomputations(const dealii::Point<dim> &point) ->
78 final
79 {
80 /* Compute bathymetry: */
81 return {compute_bathymetry(point)};
82 }
83
84 private:
85 const HyperbolicSystem &hyperbolic_system;
86
87 DEAL_II_ALWAYS_INLINE inline Number
88 compute_bathymetry(const dealii::Point<dim> &point) const
89 {
90 const Number x = point[0];
91
92 const Number slope = Number(2.) * step_height / step_width;
93 const Number triangular_step =
94 step_height - slope * std::abs(x - step_position);
95 return std::max(Number(0.), triangular_step);
96 }
97
98 Number left_depth;
99 Number left_position;
100
101 Number right_depth;
102 Number right_position;
103
104 Number step_position;
105 Number step_width;
106 Number step_height;
107 };
108
109 } // namespace ShallowWater
110} // namespace ryujin
typename HyperbolicSystemView::state_type state_type
dealii::Tensor< 1, problem_dimension< dim >, Number > state_type
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< dim, Number, state_type, 1 >::precomputed_type final
TriangularDamBreak(const HyperbolicSystem &hyperbolic_system, const std::string s)
state_type compute(const dealii::Point< dim > &point, Number) final