ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
initial_state_function.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>
11
12#include <deal.II/base/function_parser.h>
13
14namespace ryujin
15{
16 namespace ScalarConservation
17 {
18 struct HyperbolicDescription;
19
25 template <int dim, typename Number>
26 class Function : public InitialState<HyperbolicDescription, dim, Number>
27 {
28 public:
30 using state_type = typename View::state_type;
31
32 Function(const HyperbolicSystem &hyperbolic_system,
33 const std::string subsection)
34 : InitialState<HyperbolicDescription, dim, Number>("function",
35 subsection)
36 , hyperbolic_system(hyperbolic_system)
37 {
38 expression_ = "0.25 * x";
39 this->add_parameter("expression",
40 expression_,
41 "A function expression for the initial state");
42
43 /*
44 * Set up the muparser object with the final flux description from
45 * the parameter file:
46 */
47 const auto set_up_muparser = [this] {
48 /*
49 * This variant of the constructor initializes the function
50 * parser with support for a time-dependent description involving
51 * a variable »t«:
52 */
53 function_ =
54 std::make_unique<dealii::FunctionParser<dim>>(expression_);
55 };
56
57 set_up_muparser();
58 this->parse_parameters_call_back.connect(set_up_muparser);
59 }
60
61 state_type compute(const dealii::Point<dim> &point, Number t) final
62 {
63 function_->set_time(t);
64 state_type result;
65 result[0] = function_->value(point);
66 return result;
67 }
68
69 private:
70 const HyperbolicSystem &hyperbolic_system;
71
72 std::string expression_;
73 std::unique_ptr<dealii::FunctionParser<dim>> function_;
74 };
75 } // namespace ScalarConservation
76} // namespace ryujin
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
Function(const HyperbolicSystem &hyperbolic_system, const std::string subsection)
state_type compute(const dealii::Point< dim > &point, Number t) final
dealii::Tensor< 1, problem_dimension, Number > state_type