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