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