ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
initial_state_paraboloid.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0
3// [LANL Copyright Statement]
4// Copyright (C) 2022 - 2025 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
14namespace ryujin
15{
16 namespace ShallowWaterInitialStates
17 {
30 template <typename Description, int dim, typename Number>
31 class Paraboloid : public InitialState<Description, dim, Number>
32 {
33 public:
35 using View = typename HyperbolicSystem::template View<dim, Number>;
36 using state_type = typename View::state_type;
37
38 Paraboloid(const HyperbolicSystem &hyperbolic_system,
39 const std::string subsection)
40 : InitialState<Description, dim, Number>("paraboloid", subsection)
41 , hyperbolic_system_(hyperbolic_system)
42 {
43 a_ = 1.;
44 this->add_parameter(
45 "free surface radius", a_, "Radius of the circular free surface");
46
47 h_0_ = 0.1;
48 this->add_parameter(
49 "water height", h_0_, "Water height at central point");
50
51 if constexpr (dim == 1) {
52
53 length_ = 10000.;
54 this->add_parameter(
55 "paraboloid length", length_, "Length of 1D paraboloid");
56
57 B_ = 2.;
58 this->add_parameter("speed", B_, "The 1D paraboloid speed");
59
60 } else {
61 eta_ = 0.5;
62 this->add_parameter("eta", eta_, "The eta parameter");
63 }
64 }
65
66 state_type compute(const dealii::Point<dim> &point, Number t) final
67 {
68 const auto view = hyperbolic_system_.template view<dim, Number>();
69
70 /* Common quantities */
71 const auto z = compute_bathymetry(point);
72 const auto g = view.gravity();
73 const Number omega = std::sqrt(2. * g * h_0_) / a_;
74 const Number &x = point[0];
75
76 /* Initialize primitive variables */
77 Number h, v_x, v_y = 0.;
78
79 /* Define slightly different profiles for each dimension */
80
81 if constexpr (dim == 1) {
82
83 const Number k = view.manning_friction_coefficient();
84 const Number p = std::sqrt(8. * g * h_0_) / a_;
85 const Number s = std::sqrt(p * p - k * k) / 2.;
86
87 auto term1 =
88 (a_ * a_ * B_ * B_) / (8. * g * g * h_0_) * std::exp(-k * t);
89 term1 *= (1. / 4. * k * k - s * s) * std::cos(2. * s * t) -
90 s * k * sin(2. * s * t);
91
92 const auto term2 = -(B_ * B_ / (4. * g)) * std::exp(-k * t);
93
94 auto term3 = -(B_ / g) * std::exp(-1. / 2. * k * t);
95 term3 *= (s * std::cos(s * t) + 1. / 2. * k * std::sin(s * t)) *
96 (point[0] - 1. / 2. * length_);
97
98 auto htilde = h_0_ - compute_bathymetry(point);
99 htilde += term1 + term2 + term3;
100
101 h = std::max(htilde, Number(0.));
102 v_x = B_ * std::exp(-1. / 2. * k * t) * std::sin(s * t);
103
104 return state_type{{h, h * v_x}};
105 } else if constexpr (dim == 2) {
106
107 const Number &y = point[1];
108
109 const Number elevation =
110 eta_ * h_0_ / (a_ * a_) *
111 (2. * x * std::cos(omega * t) + 2. * y * std::sin(omega * t));
112
113 h = std::max(elevation - z, Number(0.));
114 v_x = -eta_ * omega * std::sin(omega * t);
115 v_y = eta_ * omega * std::cos(omega * t);
116
117 return state_type{{h, h * v_x, h * v_y}};
118
119 } else {
120 AssertThrow(false, dealii::ExcNotImplemented());
121 __builtin_trap();
122 }
123 }
124
125
126 auto initial_precomputations(const dealii::Point<dim> &point) ->
128 initial_precomputed_type final
129 {
130 /* Compute bathymetry: */
131 return {compute_bathymetry(point)};
132 }
133
134 private:
135 const HyperbolicSystem &hyperbolic_system_;
136
137 DEAL_II_ALWAYS_INLINE inline Number
138 compute_bathymetry(const dealii::Point<dim> &point) const
139 {
140 if constexpr (dim == 1)
141 return h_0_ / (a_ * a_) * std::pow(point[0] - 0.5 * length_, 2);
142 else
143 return -h_0_ * (Number(1.) - point.norm_square() / (a_ * a_));
144 }
145
146 Number a_;
147 Number h_0_;
148 Number eta_;
149 Number length_;
150 Number B_;
151 };
152
153 } // namespace ShallowWaterInitialStates
154} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
Paraboloid(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
state_type compute(const dealii::Point< dim > &point, Number t) final
typename HyperbolicSystem::template View< dim, Number > View
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34