ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
initial_state_three_state_contrast.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
12namespace ryujin
13{
14 namespace EulerInitialStates
15 {
29 template <typename Description, int dim, typename Number>
30 class ThreeStateContrast : public InitialState<Description, dim, Number>
31 {
32 public:
34 using View = typename HyperbolicSystem::template View<dim, Number>;
35 using state_type = typename View::state_type;
37 typename HyperbolicSystem::template View<1, Number>::state_type;
38
39 ThreeStateContrast(const HyperbolicSystem &hyperbolic_system,
40 const std::string &subsection)
41 : InitialState<Description, dim, Number>("three state contrast",
42 subsection)
43 , hyperbolic_system_(hyperbolic_system)
44 {
45
46 primitive_left_[0] = 1.;
47 primitive_left_[1] = 0.;
48 if constexpr (View::have_energy_equation)
49 primitive_left_[2] = 1.e3;
50 this->add_parameter("primitive state left",
51 primitive_left_,
52 "1d primitive state [rho, u, p] on the left (or "
53 "[rho, u] for the barotropic Euler module)");
54
55 left_length_ = 0.1;
56 this->add_parameter("left region length",
57 left_length_,
58 "The length of the left region");
59
60 primitive_middle_[0] = 1.;
61 primitive_middle_[1] = 0.;
62 if constexpr (View::have_energy_equation)
63 primitive_middle_[2] = 1.e-2;
64 this->add_parameter("primitive state middle",
65 primitive_middle_,
66 "1d primitive state [rho, u, p] in the middle (or "
67 "[rho, u] for the barotropic Euler module)");
68
69 middle_length_ = 0.8;
70 this->add_parameter("middle region length",
71 middle_length_,
72 "The length of the middle region");
73
74 primitive_right_[0] = 1.;
75 primitive_right_[1] = 0.;
76 if constexpr (View::have_energy_equation)
77 primitive_right_[2] = 1.e2;
78 this->add_parameter("primitive state right",
79 primitive_right_,
80 "1d primitive state [rho, u, p] on the right (or "
81 "[rho, u] for the barotropic Euler module)");
82
83 const auto convert_states = [&]() {
84 const auto view = hyperbolic_system_.template view<dim, Number>();
85 state_left_ = view.from_initial_state(primitive_left_);
86 state_middle_ = view.from_initial_state(primitive_middle_);
87 state_right_ = view.from_initial_state(primitive_right_);
88 };
89 this->parse_parameters_call_back.connect(convert_states);
90 convert_states();
91 }
92
93 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
94 {
95 return point[0] >= left_length_ + middle_length_ ? state_right_
96 : point[0] >= left_length_ ? state_middle_
97 : state_left_;
98 }
99
100 private:
101 const HyperbolicSystem &hyperbolic_system_;
102
103 Number left_length_;
104 Number middle_length_;
105
106 state_type_1d primitive_left_;
107 state_type_1d primitive_middle_;
108 state_type_1d primitive_right_;
109
110 state_type state_left_;
111 state_type state_middle_;
112 state_type state_right_;
113 };
114 } // namespace EulerInitialStates
115} // namespace ryujin
state_type compute(const dealii::Point< dim > &point, Number) final
typename HyperbolicSystem::template View< 1, Number >::state_type state_type_1d
ThreeStateContrast(const HyperbolicSystem &hyperbolic_system, const std::string &subsection)
typename HyperbolicSystem::template View< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34