ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
initial_state_hou_test.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0
3// [LANL Copyright Statement]
4// Copyright (C) 2023 - 2024 by the ryujin authors
5// Copyright (C) 2023 - 2024 by Triad National Security, LLC
6//
7
8#pragma once
9
11
12#include <deal.II/base/function_parser.h>
13
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
23 template <typename Description, int dim, typename Number>
24 class HouTest : public InitialState<Description, dim, Number>
25 {
26 public:
28 using View =
29 typename Description::template HyperbolicSystemView<dim, Number>;
30 using state_type = typename View::state_type;
31
32 HouTest(const HyperbolicSystem &hyperbolic_system, const std::string s)
33 : InitialState<Description, dim, Number>("hou test", s)
34 , hyperbolic_system(hyperbolic_system)
35 {
36 depth_ = 35;
37 this->add_parameter("reservoir water depth",
38 depth_,
39 "Depth of water in reservoir behind dam");
40 }
41
42 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
43 {
44 if constexpr (dim == 1) {
45 AssertThrow(false, dealii::ExcNotImplemented());
46 __builtin_trap();
47
48 } else {
49 const Number x = point[0];
50
51 const Number bath = compute_bathymetry(point);
52
53 /* Set water depth behind resevoir */
54 Number h = 0.;
55 if (x < -100.)
56 h = std::max(depth_ - bath, Number(0.));
57
58 return state_type{{h, 0.}};
59 }
60 }
61
62 auto initial_precomputations(const dealii::Point<dim> &point) ->
64 initial_precomputed_type final
65 {
66 /* Compute bathymetry: */
67 return {compute_bathymetry(point)};
68 }
69
70 private:
71 const HyperbolicSystem &hyperbolic_system;
72 Number depth_;
73
74 DEAL_II_ALWAYS_INLINE inline Number
75 compute_bathymetry(const dealii::Point<dim> &point) const
76 {
77 const Number x = point[0];
78 const Number y = point[1];
79
80 Number base;
81 {
82 Number base1 = std::pow(x + 250., 2) / 1600. + std::pow(y, 2) / 400.;
83 Number base2 = std::pow(x, 2) / 225. + std::pow(y - 50., 2) / 225.;
84 Number base3 =
85 std::pow(x - 250., 2) / 1225. + std::pow(y, 2) / 225. - 10.;
86
87 base = std::min(base1, base2);
88 base = std::min(base, base3);
89 }
90
91 Number bumps;
92 {
93 Number bump1 =
94 80. - std::pow(x + 250., 2) / 50. - std::pow(y, 2) / 50.;
95
96 Number bump2 = (std::pow(x - 200., 2) + std::pow(y + 10., 2) <= 1000.)
97 ? 10.
98 : 0.;
99 Number bump3 = (std::abs(x - 380.) <= 40. && std::abs(y - 50.) <= 40.)
100 ? 20.
101 : 0.;
102
103 bumps = std::max(bump1, bump2);
104 bumps = std::max(bumps, bump3);
105 }
106 return std::max(base, bumps);
107 }
108 };
109
110 } // namespace ShallowWaterInitialStates
111} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
HouTest(const HyperbolicSystem &hyperbolic_system, const std::string s)
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
typename Description::template HyperbolicSystemView< dim, Number > View
state_type compute(const dealii::Point< dim > &point, Number) final
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32