ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
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 <compile_time_options.h>
9
11
12#include <deal.II/base/function_parser.h>
13
14namespace ryujin
15{
16 namespace BarotropicEquationOfStateLibrary
17 {
32 {
33 public:
34 Function(const std::string &subsection)
35 : BarotropicEquationOfState("function", subsection)
36 {
37 sie_expression_ = "4. * ln(rho)";
38 add_parameter("specific internal energy",
39 sie_expression_,
40 "A function expression for the specific internal energy "
41 "as a function of density: e(rho)");
42
43 p_expression_ = "4. * rho";
44 add_parameter("pressure",
45 p_expression_,
46 "A function expression for the pressure as a function of "
47 "density: p(rho)");
48
49 sos_expression_ = "2.";
50 add_parameter("speed of sound",
51 sos_expression_,
52 "A function expression for the speed of sound as a "
53 "function of density: a(rho)");
54
55 /*
56 * Set up the muparser object with the final equation of state
57 * description from the parameter file:
58 */
59 const auto set_up_muparser = [this] {
60 sie_function_ = std::make_unique<dealii::FunctionParser<1>>();
61 sie_function_->initialize("rho", sie_expression_, {});
62
63 p_function_ = std::make_unique<dealii::FunctionParser<1>>();
64 p_function_->initialize("rho", p_expression_, {});
65
66 sos_function_ = std::make_unique<dealii::FunctionParser<1>>();
67 sos_function_->initialize("rho", sos_expression_, {});
68 };
69
70 set_up_muparser();
71 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
72 }
73
74 double specific_internal_energy(double rho) const final
75 {
76 return sie_function_->value(dealii::Point<1>(rho));
77 }
78
79 double pressure(double rho) const final
80 {
81 return p_function_->value(dealii::Point<1>(rho));
82 }
83
84 double speed_of_sound(double rho) const final
85 {
86 return sos_function_->value(dealii::Point<1>(rho));
87 }
88
89 private:
90 std::string sie_expression_;
91 std::string p_expression_;
92 std::string sos_expression_;
93
94 std::unique_ptr<dealii::FunctionParser<1>> sie_function_;
95 std::unique_ptr<dealii::FunctionParser<1>> p_function_;
96 std::unique_ptr<dealii::FunctionParser<1>> sos_function_;
97 };
98 } // namespace BarotropicEquationOfStateLibrary
99} // namespace ryujin