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