ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
initial_state_smooth_vortex.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 {
26 template <typename Description, int dim, typename Number>
27 class SmoothVortex : public InitialState<Description, dim, Number>
28 {
29 public:
31 using View = typename HyperbolicSystem::template View<dim, Number>;
32 using state_type = typename View::state_type;
33
34 SmoothVortex(const HyperbolicSystem &hyperbolic_system,
35 const std::string subsection)
36 : InitialState<Description, dim, Number>("smooth vortex", subsection)
37 , hyperbolic_system_(hyperbolic_system)
38 {
39 with_bathymetry = false;
40 this->add_parameter("with bathymetry",
41 with_bathymetry,
42 "If set to true then the initial profile includes "
43 "the bathymetry for the steady vortex. ");
44
45 depth_ = 1.0;
46 this->add_parameter("reference depth", depth_, "Reference water depth");
47
48 mach_number_ = 2.0;
49 this->add_parameter(
50 "mach number", mach_number_, "Mach number of unsteady vortex");
51
52 beta_ = 0.1;
53 this->add_parameter("beta", beta_, "vortex strength beta");
54 }
55
56 state_type compute(const dealii::Point<dim> &point, Number t) final
57 {
58 const auto view = hyperbolic_system_.template view<dim, Number>();
59 const auto gravity = view.gravity();
60
61 dealii::Point<2> point_bar;
62 point_bar[0] = point[0] - mach_number_ * t;
63 point_bar[1] = point[1];
64
65 const Number r_square = Number(point_bar.norm_square());
66
67 /* We assume r0 = 1 */
68 const Number factor =
69 beta_ / Number(2. * M_PI) *
70 exp(Number(0.5) - Number(0.5) * r_square /* /r0^ 2*/);
71
72 Number h =
73 depth_ - Number(1. / (2. * gravity /* * r0^2 */)) * factor * factor;
74
75 if (with_bathymetry)
76 h -= compute_bathymetry(point);
77
78 const Number u = mach_number_ - factor * Number(point_bar[1]);
79 const Number v = factor * Number(point_bar[0]);
80
81 if constexpr (dim == 2)
82 return state_type{{h, h * u, h * v}};
83
84 else {
85 AssertThrow(false, dealii::ExcNotImplemented());
86 __builtin_trap();
87 }
88 }
89
90 auto initial_precomputations(const dealii::Point<dim> &point) ->
92 initial_precomputed_type final
93 {
94 /* Compute bathymetry: */
95 return {compute_bathymetry(point)};
96 }
97
98 private:
99 const HyperbolicSystem &hyperbolic_system_;
100
101 DEAL_II_ALWAYS_INLINE inline Number
102 compute_bathymetry(const dealii::Point<dim> &point) const
103 {
104 const Number r_square = Number(point.norm_square());
105
106 /* We assume r0 = 1 */
107 const Number factor =
108 beta_ / Number(2. * M_PI) *
109 exp(Number(0.5) - Number(0.5) * r_square /* /r0^ 2*/);
110
111 Number bath = 0.;
112 if (with_bathymetry)
113 bath = depth_ / 4. * factor;
114
115 return bath;
116 }
117
118 bool with_bathymetry;
119 Number depth_;
120 Number mach_number_;
121 Number beta_;
122 };
123
124 } // namespace ShallowWaterInitialStates
125} // namespace ryujin
typename Description::HyperbolicSystem HyperbolicSystem
auto initial_precomputations(const dealii::Point< dim > &point) -> typename InitialState< Description, dim, Number >::initial_precomputed_type final
state_type compute(const dealii::Point< dim > &point, Number t) final
SmoothVortex(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34