ryujin 2.1.1 revision dbf0e3ba7acdb60b6d558e4257815df4a8f8daf9
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
10#include <compile_time_options.h>
11
13
14#include <simd.h>
15
16namespace ryujin
17{
18 namespace ShallowWaterInitialStates
19 {
27 template <typename Description, int dim, typename Number>
28 class SlopingFriction : public InitialState<Description, dim, Number>
29 {
30 public:
32 using View =
33 typename Description::template HyperbolicSystemView<dim, Number>;
34 using state_type = typename View::state_type;
35
36 SlopingFriction(const HyperbolicSystem &hyperbolic_system,
37 const std::string subsection)
38 : InitialState<Description, dim, Number>("sloping friction",
39 subsection)
40 , hyperbolic_system_(hyperbolic_system)
41 {
42 slope_ = 1.;
43 this->add_parameter(
44 "ramp slope",
45 slope_,
46 "The (positive) slope of the inclined plane used to "
47 "define the bathymetry");
48
49 q_0_ = 0.1;
50 this->add_parameter("initial discharge",
51 q_0_,
52 "The initial (unit) discharge in [m^2 / s]");
53 }
54
55 state_type compute(const dealii::Point<dim> & /*point*/,
56 Number /*t*/) final
57 {
58 const auto view = hyperbolic_system_.template view<dim, Number>();
59
60 /*
61 * Water depth profile depends on slope, discharge and Manning's
62 * coefficient. The gamma quantity in ref is fixed to 4. / 3.
63 */
64
65 const Number n = view.manning_friction_coefficient();
66 const Number exponent = 1. / (2. + 4. / 3.);
67
68 Number profile = n * n * q_0_ * q_0_ / slope_;
69 Number h = ryujin::pow(profile, exponent);
70
71 return state_type{{h, q_0_}};
72 }
73
74 auto initial_precomputations(const dealii::Point<dim> &point) ->
76 initial_precomputed_type final
77 {
78 /* Compute bathymetry: */
79 return {compute_bathymetry(point)};
80 }
81
82 private:
83 const HyperbolicSystem &hyperbolic_system_;
84
85 DEAL_II_ALWAYS_INLINE inline Number
86 compute_bathymetry(const dealii::Point<dim> &point) const
87 {
88 return -slope_ * point[0];
89 }
90
91 Number slope_;
92 Number q_0_;
93 };
94
95 } // namespace ShallowWaterInitialStates
96} // 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:34