ryujin 2.1.1 revision 3913ebe5e1d74c8fef21bcd286906a244031ce08
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
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 =
35 typename Description::template HyperbolicSystemView<dim, Number>;
36 using state_type = typename View::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 primitive_left_[2] = 1.e3;
48 this->add_parameter(
49 "primitive state left",
50 primitive_left_,
51 "Initial 1d primitive state (rho, u, p) on the left");
52
53 left_length_ = 0.1;
54 this->add_parameter("left region length",
55 left_length_,
56 "The length of the left region");
57
58 primitive_middle_[0] = 1.;
59 primitive_middle_[1] = 0.;
60 primitive_middle_[2] = 1.e-2;
61 this->add_parameter(
62 "primitive state middle",
63 primitive_middle_,
64 "Initial 1d primitive state (rho, u, p) in the middle");
65
66 middle_length_ = 0.8;
67 this->add_parameter("middle region length",
68 middle_length_,
69 "The length of the middle region");
70
71 primitive_right_[0] = 1.;
72 primitive_right_[1] = 0.;
73 primitive_right_[2] = 1.e2;
74 this->add_parameter(
75 "primitive state right",
76 primitive_right_,
77 "Initial 1d primitive state (rho, u, p) on the right");
78
79 const auto convert_states = [&]() {
80 const auto view = hyperbolic_system_.template view<dim, Number>();
81 state_left_ = view.from_initial_state(primitive_left_);
82 state_middle_ = view.from_initial_state(primitive_middle_);
83 state_right_ = view.from_initial_state(primitive_right_);
84 };
85 this->parse_parameters_call_back.connect(convert_states);
86 convert_states();
87 }
88
89 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
90 {
91 return point[0] >= left_length_ + middle_length_ ? state_right_
92 : point[0] >= left_length_ ? state_middle_
93 : state_left_;
94 }
95
96 private:
97 const HyperbolicSystem &hyperbolic_system_;
98
99 Number left_length_;
100 Number middle_length_;
101
102 dealii::Tensor<1, 3, Number> primitive_left_;
103 dealii::Tensor<1, 3, Number> primitive_middle_;
104 dealii::Tensor<1, 3, Number> primitive_right_;
105
106 state_type state_left_;
107 state_type state_middle_;
108 state_type state_right_;
109 };
110 } // namespace EulerInitialStates
111} // 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:34