ryujin 2.1.1 revision 863a4d36dcc743d4e1a9b41cfabd03d0aea57863
initial_state_contrast.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2022 - 2024 by the ryujin authors
4//
5
6#pragma once
7
9
10namespace ryujin
11{
12 namespace EulerInitialStates
13 {
24 template <typename Description, int dim, typename Number>
25 class Contrast : public InitialState<Description, dim, Number>
26 {
27 public:
29 using View =
30 typename Description::template HyperbolicSystemView<dim, Number>;
31 using state_type = typename View::state_type;
32
33 Contrast(const HyperbolicSystem &hyperbolic_system,
34 const std::string subsection)
35 : InitialState<Description, dim, Number>("contrast", subsection)
36 , hyperbolic_system_(hyperbolic_system)
37 {
38 primitive_left_[0] = 1.4;
39 primitive_left_[1] = 0.;
40 primitive_left_[2] = 1.;
41 this->add_parameter(
42 "primitive state left",
43 primitive_left_,
44 "Initial 1d primitive state (rho, u, p) on the left");
45
46 primitive_right_[0] = 1.4;
47 primitive_right_[1] = 0.;
48 primitive_right_[2] = 1.;
49 this->add_parameter(
50 "primitive state right",
51 primitive_right_,
52 "Initial 1d primitive state (rho, u, p) on the right");
53
54 const auto convert_states = [&]() {
55 const auto view = hyperbolic_system_.template view<dim, Number>();
56 state_left_ = view.from_initial_state(primitive_left_);
57 state_right_ = view.from_initial_state(primitive_right_);
58 };
59 this->parse_parameters_call_back.connect(convert_states);
60 convert_states();
61 }
62
63 state_type compute(const dealii::Point<dim> &point, Number /*t*/) final
64 {
65 return (point[0] > 0. ? state_right_ : state_left_);
66 }
67
68 private:
69 const HyperbolicSystem &hyperbolic_system_;
70
71 dealii::Tensor<1, 3, Number> primitive_left_;
72 dealii::Tensor<1, 3, Number> primitive_right_;
73
74 state_type state_left_;
75 state_type state_right_;
76 };
77 } // namespace EulerInitialStates
78} // namespace ryujin
state_type compute(const dealii::Point< dim > &point, Number) final
Contrast(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
typename Description::template HyperbolicSystemView< dim, Number > View
typename Description::HyperbolicSystem HyperbolicSystem
Euler::HyperbolicSystem HyperbolicSystem
Definition: description.h:32