ryujin 2.1.1 revision 46bf70e400e423a8ffffe8300887eeb35b8dfb2c
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 <compile_time_options.h>
9
10#include "hyperbolic_system.h"
12
13#include <deal.II/base/function_parser.h>
14
15namespace ryujin
16{
17 namespace ScalarConservation
18 {
19 struct Description;
20
26 template <int dim, typename Number>
27 class Function : public InitialState<Description, dim, Number>
28 {
29 public:
31 using state_type = typename View::state_type;
32
33 Function(const HyperbolicSystem &hyperbolic_system,
34 const std::string subsection)
35 : InitialState<Description, dim, Number>("function", 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
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