ryujin 2.1.1 revision 863a4d36dcc743d4e1a9b41cfabd03d0aea57863
initial_state_four_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 FourStateContrast : 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 FourStateContrast(const HyperbolicSystem &hyperbolic_system,
37 const std::string &subsection)
38 : InitialState<Description, dim, Number>("four state contrast",
39 subsection)
40 , hyperbolic_system_(hyperbolic_system)
41 {
42 primitive_bottom_left_[0] = 1.4;
43 primitive_bottom_left_[1] = 0.;
44 primitive_bottom_left_[2] = 0.;
45 primitive_bottom_left_[3] = 1.;
46 this->add_parameter(
47 "primitive state bottom left",
48 primitive_bottom_left_,
49 "Initial primitive state (rho, u, v, p) on bottom left");
50
51 primitive_bottom_right_[0] = 1.4;
52 primitive_bottom_right_[1] = 0.;
53 primitive_bottom_right_[2] = 0.;
54 primitive_bottom_right_[3] = 1.;
55 this->add_parameter(
56 "primitive state bottom right",
57 primitive_bottom_right_,
58 "Initial primitive state (rho, u, v, p) on bottom right");
59
60 primitive_top_left_[0] = 1.4;
61 primitive_top_left_[1] = 0.;
62 primitive_top_left_[2] = 0.;
63 primitive_top_left_[3] = 1.;
64
65 this->add_parameter(
66 "primitive state top left",
67 primitive_top_left_,
68 "Initial primitive state (rho, u, v, p) on top left");
69
70 primitive_top_right_[0] = 1.4;
71 primitive_top_right_[1] = 0.;
72 primitive_top_right_[2] = 0.;
73 primitive_top_right_[3] = 1.;
74 this->add_parameter(
75 "primitive state top right",
76 primitive_top_right_,
77 "Initial primitive state (rho, u, v, p) on top right");
78
79 const auto convert_states = [&]() {
80 const auto view = hyperbolic_system_.template view<dim, Number>();
81 if constexpr (dim != 1) {
82 state_bottom_left_ =
83 view.from_initial_state(primitive_bottom_left_);
84 state_bottom_right_ =
85 view.from_initial_state(primitive_bottom_right_);
86 state_top_left_ = view.from_initial_state(primitive_top_left_);
87 state_top_right_ = view.from_initial_state(primitive_top_right_);
88 }
89 };
90 this->parse_parameters_call_back.connect(convert_states);
91 convert_states();
92 }
93
94 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
95 {
96 if constexpr (dim == 1) {
97 AssertThrow(false, dealii::ExcNotImplemented());
98 __builtin_trap();
99
100 } else {
101
102 const auto top = point[0] >= 0. ? state_top_right_ : state_top_left_;
103 const auto bottom =
104 point[0] >= 0. ? state_bottom_right_ : state_bottom_left_;
105 return (point[1] >= 0. ? top : bottom);
106 }
107 }
108
109 private:
110 const HyperbolicSystem &hyperbolic_system_;
111
112 dealii::Tensor<1, 4, Number> primitive_bottom_left_;
113 dealii::Tensor<1, 4, Number> primitive_bottom_right_;
114 dealii::Tensor<1, 4, Number> primitive_top_left_;
115 dealii::Tensor<1, 4, Number> primitive_top_right_;
116
117 state_type state_bottom_left_;
118 state_type state_bottom_right_;
119 state_type state_top_left_;
120 state_type state_top_right_;
121 };
122 } // namespace EulerInitialStates
123} // namespace ryujin
state_type compute(const dealii::Point< dim > &point, Number) final
FourStateContrast(const HyperbolicSystem &hyperbolic_system, const std::string &subsection)
typename Description::template HyperbolicSystemView< dim, Number > View
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32