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