|
Reference documentation for deal.II version 9.2.0
|
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\)
\(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\)
\(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\)
\(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Go to the documentation of this file.
61 "The names of the variables as they will be used in the "
62 "function, separated by commas. By default, the names of variables "
63 "at which the function will be evaluated are `x' (in 1d), `x,y' (in 2d) or "
64 "`x,y,z' (in 3d) for spatial coordinates and `t' for time. You can then "
65 "use these variable names in your function expression and they will be "
66 "replaced by the values of these variables at which the function is "
67 "currently evaluated. However, you can also choose a different set "
68 "of names for the independent variables at which to evaluate your function "
69 "expression. For example, if you work in spherical coordinates, you may "
70 "wish to set this input parameter to `r,phi,theta,t' and then use these "
71 "variable names in your function expression.");
74 std::string expr =
"0";
79 "Function expression",
82 "The formula that denotes the function you want to evaluate for "
83 "particular values of the independent variables. This expression "
84 "may contain any of the usual operations such as addition or "
85 "multiplication, as well as all of the common functions such as "
86 "`sin' or `cos'. In addition, it may contain expressions like "
87 "`if(x>0, 1, -1)' where the expression evaluates to the second "
88 "argument if the first argument is true, and to the third argument "
89 "otherwise. For a full overview of possible expressions accepted "
90 "see the documentation of the muparser library at http://muparser.beltoforion.de/."
92 "If the function you are describing represents a vector-valued "
93 "function with multiple components, then separate the expressions "
94 "for individual components by a semicolon.");
99 "Sometimes it is convenient to use symbolic constants in the "
100 "expression that describes the function, rather than having to "
101 "use its numeric value everywhere the constant appears. These "
102 "values can be defined using this parameter, in the form "
103 "`var1=value1, var2=value2, ...'."
105 "A typical example would be to set this runtime parameter to "
106 "`pi=3.1415926536' and then use `pi' in the expression of the "
107 "actual formula. (That said, for convenience this class actually "
108 "defines both `pi' and `Pi' by default, but you get the idea.)");
117 std::string vnames = prm.
get(
"Variable names");
118 std::string expression = prm.
get(
"Function expression");
119 std::string constants_list = prm.
get(
"Function constants");
121 std::vector<std::string> const_list =
123 std::map<std::string, double> constants;
124 for (
const auto &constant : const_list)
126 std::vector<std::string> this_c =
130 AssertThrow(std::sscanf(this_c[1].c_str(),
"%lf", &tmp),
132 constants[this_c[0]] = tmp;
145 function_object.initialize(vnames, expression, constants);
149 function_object.initialize(vnames, expression, constants,
true);
154 "The list of variables specified is <" + vnames +
155 "> which is a list of length " +
157 " but it has to be a list of length equal to" +
158 " either dim (for a time-independent function)" +
159 " or dim+1 (for a time-dependent function)."));
170 function_object.vector_value(p, values);
179 return function_object.value(p, comp);
188 function_object.set_time(newtime);
std::string get(const std::string &entry_string) const
static void declare_parameters(ParameterHandler &prm, const unsigned int n_components=1)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
static ::ExceptionBase & ExcNotImplemented()
void parse_parameters(ParameterHandler &prm)
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define DEAL_II_NAMESPACE_OPEN
virtual void set_time(const double newtime) override
virtual void set_time(const numbers::NumberTraits< double >::real_type new_time)
virtual void vector_value(const Point< dim > &p, Vector< double > &values) const override
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
#define Assert(cond, exc)
virtual double value(const Point< dim > &p, const unsigned int component=0) const override
static ::ExceptionBase & ExcZero()
#define DEAL_II_NAMESPACE_CLOSE
static constexpr double PI
#define AssertThrow(cond, exc)
ParsedFunction(const unsigned int n_components=1, const double h=1e-8)