ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_flow_over_bump.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>
11#include <ryujin/base/simd.h>
13
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
24 template <typename Description, int dim, typename Number>
25 class FlowOverBump : public InitialState<Description, dim, Number>
26 {
27 public:
28 using HyperbolicSystem = typename Description::HyperbolicSystem;
29 using View = typename HyperbolicSystem::template View<dim, Number>;
30 using state_type = typename View::state_type;
31
32 FlowOverBump(const HyperbolicSystem &hyperbolic_system,
33 const std::string subsection)
34 : InitialState<Description, dim, Number>("flow over bump", subsection)
35 , hyperbolic_system_(hyperbolic_system)
36 {
37 dealii::ParameterAcceptor::parse_parameters_call_back.connect(
39
40 which_case_ = "transcritical";
41 this->add_parameter("flow type",
42 which_case_,
43 "Either 'transcritical' flow with shock "
44 "or 'subsonic' flow.");
45 }
46
48 {
49 AssertThrow(which_case_ == "subsonic" || which_case_ == "transcritical",
50 dealii::ExcMessage("Flow type must be 'transcritical' "
51 "or 'subsonic'. "));
52 }
53
54 state_type compute(const dealii::Point<dim> &point, Number t) final
55 {
56 const auto view = hyperbolic_system_.template view<dim, Number>();
57 const auto g = view.gravity();
58
59 const auto x = point[0];
60
61 /* Define constants for transcritical flow */
62 const Number xM = 10.;
63 const Number xS = 11.7;
64 const Number zM = 0.2;
65 Number h_inflow = 0.28205279813802181;
66 Number q_inflow = 0.18;
67 Number cBer =
68 zM + 1.5 * ryujin::pow(q_inflow * q_inflow / g, Number(1. / 3.));
69
70
71 /* Subsonic flow constants */
72 if (which_case_ == "subsonic") {
73 q_inflow = 4.42;
74 h_inflow = 2.;
75 cBer = std::pow(q_inflow / h_inflow, 2) / (2. * g) + h_inflow;
76 }
77
78 /* General values for Cardano's formula */
79 const Number d = q_inflow * q_inflow / (2. * g);
80 const Number b = compute_bathymetry(point) - cBer;
81 const Number Q = -std::pow(b, 2) / 9.;
82 const Number R = -(27. * d + 2. * std::pow(b, 3)) / 54.;
83 const Number theta = acos(ryujin::pow(-Q, Number(-1.5)) * R);
84
85 /* Define initial and exact solution */
86 const Number h_initial = h_inflow - compute_bathymetry(point);
87
88 /* Explicitly return initial state */
89 if (t < 1e-12) {
90 return state_type{{h_initial, q_inflow}};
91 }
92
93 Number h_exact = 2. * std::sqrt(-Q) * cos(theta / 3.) - b / 3.;
94 if (which_case_ == "transcritical") {
95 if (xM <= x && x < xS) {
96 h_exact = 2. * std::sqrt(-Q) *
97 cos((4. * dealii::numbers::PI + theta) / 3.) -
98 b / 3.;
99 } else if (xS < x) {
100 h_exact = 0.28205279813802181;
101 }
102 }
103
104 return state_type{{h_exact, q_inflow}};
105 }
106
107 auto initial_precomputations(const dealii::Point<dim> &point) ->
109 initial_precomputed_type final
110 {
111 /* Compute bathymetry: */
112 return {compute_bathymetry(point)};
113 }
114
115 private:
116 const HyperbolicSystem &hyperbolic_system_;
117
118 DEAL_II_ALWAYS_INLINE
119 inline Number compute_bathymetry(const dealii::Point<dim> &point) const
120 {
121 const auto x = point[0];
122
123 const Number bump = Number(0.2 / 64.) * std::pow(x - Number(8.), 3) *
124 std::pow(Number(12.) - x, 3);
125
126 Number bath = 0.;
127 if (8. <= x && x <= 12.)
128 bath = bump;
129 return bath;
130 }
131
132 std::string which_case_;
133 };
134
135 } // namespace ShallowWaterInitialStates
136} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
FlowOverBump(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< dim, Number > View
DEAL_II_HOST_DEVICE T pow(const T x, const T b)