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