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