10#include <deal.II/base/function_parser.h>
12#include <boost/algorithm/string/classification.hpp>
13#include <boost/algorithm/string/split.hpp>
30 :
Flux(
"function", subsection)
32 expression_ =
"0.5*u*u";
33 add_parameter(
"expression",
35 "A function expression of the flux as a function of "
36 "state used to create a muparser object to evaluate the "
37 "flux. For two, or three dimensional fluxes, components "
38 "are separated with a semicolon (;).");
41 add_parameter(
"derivative approximation delta",
43 "Step size of the central difference quotient to compute "
44 "an approximation of the flux derivative");
50 const auto set_up_muparser = [
this] {
51 std::vector<std::string> split_expressions;
52 boost::split(split_expressions, expression_, boost::is_any_of(
";"));
54 const auto size = split_expressions.size();
56 Assert(0 < size && size <= 3,
58 "user specified flux description must be either one, two, "
59 "or three strings separated by a comma"));
60 flux_function_ = std::make_unique<dealii::FunctionParser<1>>(
62 flux_function_->initialize({
"u"}, split_expressions, {});
68 ParameterAcceptor::parse_parameters_call_back.connect(set_up_muparser);
72 double value(
const double state,
73 const unsigned int direction)
const override
75 return flux_function_->value(dealii::Point<1>(state), direction);
80 const unsigned int direction)
const override
82 return flux_function_->gradient(dealii::Point<1>(state), direction)[0];
87 std::string expression_;
89 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