ryujin 2.1.1 revision 9dcb748690310d6a540ebb8b066d1a0834fc7604
initial_state_isentropic_vortex.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: MIT
3// Copyright (C) 2020 - 2023 by the ryujin authors
4//
5
6#pragma once
7
8#include <initial_state_library.h>
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:
31 typename HyperbolicSystem::template View<dim, Number>;
32 using state_type = typename HyperbolicSystemView::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 (!HyperbolicSystemView::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 if constexpr (HyperbolicSystemView::have_gamma) {
56 gamma_ = hyperbolic_system_.gamma();
57 }
58
59 /* In 3D we simply project onto the 2d plane: */
60 dealii::Point<2> point_bar;
61 point_bar[0] = point[0] - mach_number_ * t;
62 point_bar[1] = point[1];
63
64 const Number r_square = Number(point_bar.norm_square());
65
66 const Number factor = beta_ / Number(2. * M_PI) *
67 exp(Number(0.5) - Number(0.5) * r_square);
68
69 const Number T = Number(1.) - (gamma_ - Number(1.)) /
70 (Number(2.) * gamma_) * factor *
71 factor;
72
73 const Number u = mach_number_ - factor * Number(point_bar[1]);
74 const Number v = factor * Number(point_bar[0]);
75
76 const Number rho = ryujin::pow(T, Number(1.) / (Number(gamma_ - 1.)));
77 const Number p = ryujin::pow(rho, Number(gamma_));
78 const Number E =
79 p / (gamma_ - Number(1.)) + Number(0.5) * rho * (u * u + v * v);
80
81 if constexpr (dim == 2)
82 return state_type({rho, rho * u, rho * v, E});
83 else if constexpr (dim == 3)
84 return state_type({rho, rho * u, rho * v, Number(0.), E});
85 else {
86 AssertThrow(false, dealii::ExcNotImplemented());
87 __builtin_trap();
88 }
89 }
90
91 private:
92 const HyperbolicSystemView hyperbolic_system_;
93
94 Number gamma_;
95 Number mach_number_;
96 Number beta_;
97 };
98 } // namespace EulerInitialStates
99} // namespace ryujin
IsentropicVortex(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename HyperbolicSystemView::state_type state_type
typename HyperbolicSystem::template View< dim, Number > HyperbolicSystemView
typename Description::HyperbolicSystem HyperbolicSystem
state_type compute(const dealii::Point< dim > &point, Number t) final
T pow(const T x, const T b)
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32