ryujin 2.1.1 revision 46bf70e400e423a8ffffe8300887eeb35b8dfb2c
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
10#include <compile_time_options.h>
11
13
14#include <deal.II/base/function_parser.h>
15
16namespace ryujin
17{
18 namespace ShallowWaterInitialStates
19 {
25 template <typename Description, int dim, typename Number>
26 class HouTest : public InitialState<Description, dim, Number>
27 {
28 public:
30 using View =
31 typename Description::template HyperbolicSystemView<dim, Number>;
32 using state_type = typename View::state_type;
33
34 HouTest(const HyperbolicSystem &hyperbolic_system, const std::string s)
35 : InitialState<Description, dim, Number>("hou test", s)
36 , hyperbolic_system(hyperbolic_system)
37 {
38 depth_ = 35;
39 this->add_parameter("reservoir water depth",
40 depth_,
41 "Depth of water in reservoir behind dam");
42 }
43
44 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
45 {
46 if constexpr (dim == 1) {
47 AssertThrow(false, dealii::ExcNotImplemented());
48 __builtin_trap();
49
50 } else {
51 const Number x = point[0];
52
53 const Number bath = compute_bathymetry(point);
54
55 /* Set water depth behind resevoir */
56 Number h = 0.;
57 if (x < -100.)
58 h = std::max(depth_ - bath, Number(0.));
59
60 return state_type{{h, 0.}};
61 }
62 }
63
64 auto initial_precomputations(const dealii::Point<dim> &point) ->
66 initial_precomputed_type final
67 {
68 /* Compute bathymetry: */
69 return {compute_bathymetry(point)};
70 }
71
72 private:
73 const HyperbolicSystem &hyperbolic_system;
74 Number depth_;
75
76 DEAL_II_ALWAYS_INLINE inline Number
77 compute_bathymetry(const dealii::Point<dim> &point) const
78 {
79 const Number x = point[0];
80 const Number y = point[1];
81
82 Number base;
83 {
84 Number base1 = std::pow(x + 250., 2) / 1600. + std::pow(y, 2) / 400.;
85 Number base2 = std::pow(x, 2) / 225. + std::pow(y - 50., 2) / 225.;
86 Number base3 =
87 std::pow(x - 250., 2) / 1225. + std::pow(y, 2) / 225. - 10.;
88
89 base = std::min(base1, base2);
90 base = std::min(base, base3);
91 }
92
93 Number bumps;
94 {
95 Number bump1 =
96 80. - std::pow(x + 250., 2) / 50. - std::pow(y, 2) / 50.;
97
98 Number bump2 = (std::pow(x - 200., 2) + std::pow(y + 10., 2) <= 1000.)
99 ? 10.
100 : 0.;
101 Number bump3 = (std::abs(x - 380.) <= 40. && std::abs(y - 50.) <= 40.)
102 ? 20.
103 : 0.;
104
105 bumps = std::max(bump1, bump2);
106 bumps = std::max(bumps, bump3);
107 }
108 return std::max(base, bumps);
109 }
110 };
111
112 } // namespace ShallowWaterInitialStates
113} // 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:34