ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
initial_state_sloping_friction.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0
3// [LANL Copyright Statement]
4// Copyright (C) 2024 by the ryujin authors
5// Copyright (C) 2023 - 2024 by Triad National Security, LLC
6//
7
8#pragma once
9
11
12#include <simd.h>
13
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
25 template <typename Description, int dim, typename Number>
26 class SlopingFriction : public InitialState<Description, dim, Number>
27 {
28 public:
30 using View =
31 typename Description::template HyperbolicSystemView<dim, Number>;
32 using state_type = typename View::state_type;
33
34 SlopingFriction(const HyperbolicSystem &hyperbolic_system,
35 const std::string subsection)
36 : InitialState<Description, dim, Number>("sloping friction",
37 subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 {
40 slope_ = 1.;
41 this->add_parameter(
42 "ramp slope",
43 slope_,
44 "The (positive) slope of the inclined plane used to "
45 "define the bathymetry");
46
47 q_0_ = 0.1;
48 this->add_parameter("initial discharge",
49 q_0_,
50 "The initial (unit) discharge in [m^2 / s]");
51 }
52
53 state_type compute(const dealii::Point<dim> & /*point*/,
54 Number /*t*/) final
55 {
56 const auto view = hyperbolic_system_.template view<dim, Number>();
57
58 /*
59 * Water depth profile depends on slope, discharge and Manning's
60 * coefficient. The gamma quantity in ref is fixed to 4. / 3.
61 */
62
63 const Number n = view.manning_friction_coefficient();
64 const Number exponent = 1. / (2. + 4. / 3.);
65
66 Number profile = n * n * q_0_ * q_0_ / slope_;
67 Number h = ryujin::pow(profile, exponent);
68
69 return state_type{{h, q_0_}};
70 }
71
72 auto initial_precomputations(const dealii::Point<dim> &point) ->
74 initial_precomputed_type final
75 {
76 /* Compute bathymetry: */
77 return {compute_bathymetry(point)};
78 }
79
80 private:
81 const HyperbolicSystem &hyperbolic_system_;
82
83 DEAL_II_ALWAYS_INLINE inline Number
84 compute_bathymetry(const dealii::Point<dim> &point) const
85 {
86 return -slope_ * point[0];
87 }
88
89 Number slope_;
90 Number q_0_;
91 };
92
93 } // namespace ShallowWaterInitialStates
94} // namespace ryujin
SlopingFriction(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::template HyperbolicSystemView< 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 > &, Number) final
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32