8#include <compile_time_options.h>
12#include <deal.II/base/function_parser.h>
14#include <boost/algorithm/string/classification.hpp>
15#include <boost/algorithm/string/split.hpp>
32 :
Flux(
"function", subsection)
34 expression_ =
"0.5*u*u";
35 add_parameter(
"expression",
37 "A function expression of the flux as a function of "
38 "state used to create a muparser object to evaluate the "
39 "flux. For two, or three dimensional fluxes, components "
40 "are separated with a semicolon (;).");
43 add_parameter(
"derivative approximation delta",
45 "Step size of the central difference quotient to compute "
46 "an approximation of the flux derivative");
52 const auto set_up_muparser = [
this] {
53 std::vector<std::string> split_expressions;
54 boost::split(split_expressions, expression_, boost::is_any_of(
";"));
56 const auto size = split_expressions.size();
58 Assert(0 < size && size <= 3,
60 "user specified flux description must be either one, two, "
61 "or three strings separated by a comma"));
62 flux_function_ = std::make_unique<dealii::FunctionParser<1>>(
64 flux_function_->initialize({
"u"}, split_expressions, {});
70 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
74 double value(
const double state,
75 const unsigned int direction)
const override
77 return flux_function_->value(dealii::Point<1>(state), direction);
82 const unsigned int direction)
const override
84 return flux_function_->gradient(dealii::Point<1>(state), direction)[0];
89 std::string expression_;
91 std::unique_ptr<dealii::FunctionParser<1>> flux_function_;
std::string flux_formula_
double derivative_approximation_delta_
Function(const std::string &subsection)
double gradient(const double state, const unsigned int direction) const override
double value(const double state, const unsigned int direction) const override