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