ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
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 - 2025 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
11#include <simd.h>
12
13namespace ryujin
14{
15 namespace EulerInitialStates
16 {
27 template <typename Description, int dim, typename Number>
28 class IsentropicVortex : public InitialState<Description, dim, Number>
29 {
30 public:
32 using View = typename HyperbolicSystem::template View<dim, Number>;
33 using state_type = typename View::state_type;
34
35 IsentropicVortex(const HyperbolicSystem &hyperbolic_system,
36 const std::string subsection)
37 : InitialState<Description, dim, Number>("isentropic vortex",
38 subsection)
39 , hyperbolic_system_(hyperbolic_system)
40 {
41 gamma_ = 1.4;
42 if constexpr (!View::have_gamma) {
43 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
44 }
45
46 mach_number_ = 2.0;
47 this->add_parameter(
48 "mach number", mach_number_, "Mach number of isentropic vortex");
49
50 beta_ = 5.0;
51 this->add_parameter("beta", beta_, "vortex strength beta");
52 }
53
54 state_type compute(const dealii::Point<dim> &point, Number t) final
55 {
56 const auto view = hyperbolic_system_.template view<dim, Number>();
57
58 if constexpr (View::have_gamma) {
59 gamma_ = view.gamma();
60 }
61
62 /* In 3D we simply project onto the 2d plane: */
63 dealii::Point<2> point_bar;
64 point_bar[0] = point[0] - mach_number_ * t;
65 point_bar[1] = point[1];
66
67 const Number r_square = Number(point_bar.norm_square());
68
69 const Number factor = beta_ / Number(2. * M_PI) *
70 exp(Number(0.5) - Number(0.5) * r_square);
71
72 const Number T = Number(1.) - (gamma_ - Number(1.)) /
73 (Number(2.) * gamma_) * factor *
74 factor;
75
76 const Number u = mach_number_ - factor * Number(point_bar[1]);
77 const Number v = factor * Number(point_bar[0]);
78
79 const Number rho = ryujin::pow(T, Number(1.) / (Number(gamma_ - 1.)));
80 const Number p = ryujin::pow(rho, Number(gamma_));
81 const Number E =
82 p / (gamma_ - Number(1.)) + Number(0.5) * rho * (u * u + v * v);
83
84 AssertThrow(dim > 1, dealii::ExcNotImplemented());
85
86 state_type result;
87 result[0] = rho;
88 result[1] = rho * u;
89 if constexpr (dim >= 2)
90 result[2] = rho * v;
91 if constexpr (View::have_energy_equation)
92 result[dim + 1] = E;
93
94 return result;
95 }
96
97 private:
98 const HyperbolicSystem &hyperbolic_system_;
99
100 Number gamma_;
101 Number mach_number_;
102 Number beta_;
103 };
104 } // namespace EulerInitialStates
105} // 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)
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34