ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
barotropic_equation_of_state_function.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2025 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
10
11#include <deal.II/base/function_parser.h>
12
13namespace ryujin
14{
15 namespace BarotropicEquationsOfState
16 {
31 {
32 public:
33 Function(const std::string &subsection)
34 : BarotropicEquationOfState("function", subsection)
35 {
36 sie_expression_ = "4. * ln(rho)";
37 add_parameter("specific internal energy",
38 sie_expression_,
39 "A function expression for the specific internal energy "
40 "as a function of density: e(rho)");
41
42 p_expression_ = "4. * rho";
43 add_parameter("pressure",
44 p_expression_,
45 "A function expression for the pressure as a function of "
46 "density: p(rho)");
47
48 sos_expression_ = "2.";
49 add_parameter("speed of sound",
50 sos_expression_,
51 "A function expression for the speed of sound as a "
52 "function of density: a(rho)");
53
54 /*
55 * Set up the muparser object with the final equation of state
56 * description from the parameter file:
57 */
58 const auto set_up_muparser = [this] {
59 sie_function_ = std::make_unique<dealii::FunctionParser<1>>();
60 sie_function_->initialize("rho", sie_expression_, {});
61
62 p_function_ = std::make_unique<dealii::FunctionParser<1>>();
63 p_function_->initialize("rho", p_expression_, {});
64
65 sos_function_ = std::make_unique<dealii::FunctionParser<1>>();
66 sos_function_->initialize("rho", sos_expression_, {});
67 };
68
69 set_up_muparser();
70 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
71 }
72
73 double specific_internal_energy(double rho) const final
74 {
75 return sie_function_->value(dealii::Point<1>(rho));
76 }
77
78 double pressure(double rho) const final
79 {
80 return p_function_->value(dealii::Point<1>(rho));
81 }
82
83 double speed_of_sound(double rho) const final
84 {
85 return sos_function_->value(dealii::Point<1>(rho));
86 }
87
88 private:
89 std::string sie_expression_;
90 std::string p_expression_;
91 std::string sos_expression_;
92
93 std::unique_ptr<dealii::FunctionParser<1>> sie_function_;
94 std::unique_ptr<dealii::FunctionParser<1>> p_function_;
95 std::unique_ptr<dealii::FunctionParser<1>> sos_function_;
96 };
97 } // namespace BarotropicEquationsOfState
98} // namespace ryujin