ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
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 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
9#include <ryujin/base/simd.h>
11
12namespace ryujin
13{
14 namespace EulerInitialStates
15 {
26 template <typename Description, int dim, typename Number>
27 class IsentropicVortex : public InitialState<Description, dim, Number>
28 {
29 public:
30 using HyperbolicSystem = typename Description::HyperbolicSystem;
31 using View = typename HyperbolicSystem::template View<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 AssertThrow(dim > 1, dealii::ExcNotImplemented());
84
85 state_type result;
86 result[0] = rho;
87 result[1] = rho * u;
88 if constexpr (dim >= 2)
89 result[2] = rho * v;
90 if constexpr (View::have_energy_equation)
91 result[dim + 1] = E;
92
93 return result;
94 }
95
96 private:
97 const HyperbolicSystem &hyperbolic_system_;
98
99 Number gamma_;
100 Number mach_number_;
101 Number beta_;
102 };
103 } // namespace EulerInitialStates
104} // namespace ryujin
IsentropicVortex(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystem::template View< dim, Number > View
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
DEAL_II_HOST_DEVICE T pow(const T x, const T b)