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