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