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