ryujin 2.1.1 revision d1a5601757449924e68a428cfd892dfe8915810d
initial_state_leblanc.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include <cmath>
10
11namespace ryujin
12{
13 namespace EulerInitialStates
14 {
27 template <typename Description, int dim, typename Number>
28 class LeBlanc : public InitialState<Description, dim, Number>
29 {
30 public:
32 using View =
33 typename Description::template HyperbolicSystemView<dim, Number>;
34 using state_type = typename View::state_type;
35
36 using ScalarNumber = typename View::ScalarNumber;
37
38 LeBlanc(const HyperbolicSystem &hyperbolic_system,
39 const std::string subsection)
40 : InitialState<Description, dim, Number>("leblanc", subsection)
41 , hyperbolic_system_(hyperbolic_system)
42 {
43 } /* Constructor */
44
45 state_type compute(const dealii::Point<dim> &point, Number t) final
46 {
47 /*
48 * The Le Blanc shock tube:
49 */
50
51 /* Initial left and right states (rho, u, p): */
52 using state_type_1d = std::array<Number, 3>;
53 constexpr state_type_1d primitive_left{1., 0., Number(2. / 3. * 1.e-1)};
54 constexpr state_type_1d primitive_right{
55 1.e-3, 0., Number(2. / 3. * 1.e-10)};
56
57 /* The intermediate wave-speeds appearing on the Riemann fan: */
58 constexpr Number rarefaction_speed = 0.49578489518897934;
59 constexpr Number contact_velocity = 0.62183867139173454;
60 constexpr Number right_shock_speed = 0.82911836253346982;
61
62 /*
63 * Velocity and pressure are constant across the middle discontinuity,
64 * only the density jumps: it's a contact wave!
65 */
66 constexpr Number pre_contact_density = 5.4079335349316249e-02;
67 constexpr Number post_contact_density = 3.9999980604299963e-03;
68 constexpr Number contact_pressure = 0.51557792765096996e-03;
69
70 state_type_1d primitive_state;
71 const double &x = point[0];
72
73 if (x <= -1.0 / 3.0 * t) {
74 /* Left state: */
75 primitive_state = primitive_left;
76
77 } else if (x < rarefaction_speed * t) {
78 /* Expansion data (with self-similar variable chi): */
79 const double chi = x / t;
80 primitive_state[0] = std::pow(0.75 - 0.75 * chi, 3.0);
81 primitive_state[1] = 0.75 * (1.0 / 3.0 + chi);
82 primitive_state[2] = (1.0 / 15.0) * std::pow(0.75 - 0.75 * chi, 5.0);
83
84 } else if (x < contact_velocity * t) {
85 primitive_state[0] = pre_contact_density;
86 primitive_state[1] = contact_velocity;
87 primitive_state[2] = contact_pressure;
88
89 } else if (x < right_shock_speed * t) {
90 /* Contact-wave data (velocity and pressure are continuous): */
91 primitive_state[0] = post_contact_density;
92 primitive_state[1] = contact_velocity;
93 primitive_state[2] = contact_pressure;
94
95 } else {
96 /* Right state: */
97 primitive_state = primitive_right;
98 }
99
100 state_type conserved_state;
101 {
102 const auto &[rho, u, p] = primitive_state;
103 conserved_state[0] = rho;
104 conserved_state[1] = rho * u;
105 conserved_state[dim + 1] =
106 p / ScalarNumber(5. / 3. - 1.) + ScalarNumber(0.5) * rho * u * u;
107 }
108
109 return conserved_state;
110 }
111
112 private:
113 const HyperbolicSystem &hyperbolic_system_;
114 };
115 } // namespace EulerInitialStates
116} // namespace ryujin
typename Description::template HyperbolicSystemView< dim, Number > View
LeBlanc(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename View::ScalarNumber ScalarNumber
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