ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_noh.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 {
26 template <typename Description, int dim, typename Number>
27 class Noh : public InitialState<Description, dim, Number>
28 {
29 public:
30 using HyperbolicSystem = typename Description::HyperbolicSystem;
31 using View = typename HyperbolicSystem::template View<dim, Number>;
32 using state_type = typename View::state_type;
33
34 Noh(const HyperbolicSystem &hyperbolic_system,
35 const std::string &subsection)
36 : InitialState<Description, dim, Number>("noh", subsection)
37 , hyperbolic_system_(hyperbolic_system)
38 {
39 gamma_ = 1.4;
40 if constexpr (!View::have_gamma) {
41 this->add_parameter("gamma", gamma_, "The ratio of specific heats");
42 }
43
44 rho0_ = 1.0;
45 this->add_parameter(
46 "reference density", rho0_, "The reference density");
47
48 /*
49 * Exact solution assumes this value is negative, but we are just
50 * switching u0 to -u0 by hand in the formulas.
51 */
52 u0_ = 1.0;
53 this->add_parameter("reference velocity magnitude",
54 u0_,
55 "The reference velocity magnitude");
56
57
58 p0_ = 1.e-12;
59 this->add_parameter(
60 "reference pressure", p0_, "The reference pressure");
61
62 this->parse_parameters_call_back.connect([&]() {
63 if constexpr (View::have_gamma) {
64 const auto view = hyperbolic_system_.template view<dim, Number>();
65 gamma_ = view.gamma();
66 }
67 });
68 }
69
70 /* Compute solution */
71 auto compute(const dealii::Point<dim> &point, Number t)
72 -> state_type final
73 {
74 const auto view = hyperbolic_system_.template view<dim, Number>();
75
76 const auto norm = point.norm();
77 const auto min = 10. * std::numeric_limits<Number>::min();
78
79 /* Initialize primitive variables */
80 Number rho = rho0_;
81 auto vel = -u0_ * point / (norm + min);
82 Number p = p0_;
83
84 /* Define exact solutions */
85 const auto D = u0_ * (gamma_ - 1.) / 2.;
86 const bool in_interior = t == Number(0.) ? false : norm / t < D;
87
88 if (in_interior) {
89 rho = rho0_ * std::pow((gamma_ + 1.) / (gamma_ - 1.), dim);
90 vel = 0. * point;
91 p = 0.5 * rho0_ * u0_ * u0_;
92 p *= std::pow(gamma_ + 1., dim) / std::pow(gamma_ - 1., dim - 1);
93 } else {
94 rho = rho0_ * std::pow(1. + t / (norm + min), dim - 1);
95 }
96
97 /* Assemble final state: */
98 state_type result;
99 result[0] = rho;
100 result[1] = Number(vel[0]);
101 if constexpr (dim >= 2)
102 result[2] = Number(vel[1]);
103 if constexpr (dim >= 3)
104 result[3] = Number(vel[2]);
105 if constexpr (View::have_energy_equation)
106 result[dim + 1] = p;
107
108 return view.from_initial_state(result);
109 }
110
111 private:
112 const HyperbolicSystem &hyperbolic_system_;
113 Number gamma_;
114 Number rho0_;
115 Number u0_;
116 Number p0_;
117 };
118 } // namespace EulerInitialStates
119} // namespace ryujin
Noh(const HyperbolicSystem &hyperbolic_system, const std::string &subsection)
typename HyperbolicSystem::template View< dim, Number > View
typename View::state_type state_type
auto compute(const dealii::Point< dim > &point, Number t) -> state_type final
typename Description::HyperbolicSystem HyperbolicSystem