ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
initial_state_isentropic_vortex.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2022 - 2024 by the ryujin authors
4//
5
6#pragma once
7
9#include <simd.h>
10
11namespace ryujin
12{
13 namespace EulerInitialStates
14 {
25 template <typename Description, int dim, typename Number>
26 class IsentropicVortex : 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 IsentropicVortex(const HyperbolicSystem &hyperbolic_system,
35 const std::string subsection)
36 : InitialState<Description, dim, Number>("isentropic vortex",
37 subsection)
38 , hyperbolic_system_(hyperbolic_system)
39 {
40 gamma_ = 1.4;
41 if constexpr (!View::have_gamma) {
42 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
43 }
44
45 mach_number_ = 2.0;
46 this->add_parameter(
47 "mach number", mach_number_, "Mach number of isentropic vortex");
48
49 beta_ = 5.0;
50 this->add_parameter("beta", beta_, "vortex strength beta");
51 }
52
53 state_type compute(const dealii::Point<dim> &point, Number t) final
54 {
55 const auto view = hyperbolic_system_.template view<dim, Number>();
56
57 if constexpr (View::have_gamma) {
58 gamma_ = view.gamma();
59 }
60
61 /* In 3D we simply project onto the 2d plane: */
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 const Number factor = beta_ / Number(2. * M_PI) *
69 exp(Number(0.5) - Number(0.5) * r_square);
70
71 const Number T = Number(1.) - (gamma_ - Number(1.)) /
72 (Number(2.) * gamma_) * factor *
73 factor;
74
75 const Number u = mach_number_ - factor * Number(point_bar[1]);
76 const Number v = factor * Number(point_bar[0]);
77
78 const Number rho = ryujin::pow(T, Number(1.) / (Number(gamma_ - 1.)));
79 const Number p = ryujin::pow(rho, Number(gamma_));
80 const Number E =
81 p / (gamma_ - Number(1.)) + Number(0.5) * rho * (u * u + v * v);
82
83 if constexpr (dim == 2)
84 return state_type({rho, rho * u, rho * v, E});
85 else if constexpr (dim == 3)
86 return state_type({rho, rho * u, rho * v, Number(0.), E});
87 else {
88 AssertThrow(false, dealii::ExcNotImplemented());
89 __builtin_trap();
90 }
91 }
92
93 private:
94 const HyperbolicSystem &hyperbolic_system_;
95
96 Number gamma_;
97 Number mach_number_;
98 Number beta_;
99 };
100 } // namespace EulerInitialStates
101} // namespace ryujin
IsentropicVortex(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
typename Description::template HyperbolicSystemView< dim, Number > View
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32