//@}
private:
- /**
- * An array to keep track of all the constants, required to initialize fp in
- * each thread.
- */
- std::map<std::string, double> constants;
-
- /**
- * An array for the variable names, required to initialize fp in each
- * thread.
- */
- std::vector<std::string> var_names;
-
/**
* Initialize fp and vars on the current thread. This function may only be
* called once per thread. A thread can test whether the function has
*/
void
init_muparser() const;
-
- /**
- * An array of function expressions (one per component), required to
- * initialize fp in each thread.
- */
- std::vector<std::string> expressions;
-
- /**
- * State of usability. This variable is checked every time the function is
- * called for evaluation. It's set to true in the initialize() methods.
- */
- bool initialized;
-
- /**
- * Number of variables. If this is also a function of time, then the number
- * of variables is dim+1, otherwise it is dim. In the case that this is a
- * time dependent function, the time is supposed to be the last variable. If
- * #n_vars is not identical to the number of the variables parsed by the
- * initialize() method, then an exception is thrown.
- */
- unsigned int n_vars;
};
class ParserImplementation
{
public:
+ ParserImplementation()
+ : initialized(false)
+ , n_vars(0)
+ {}
+
/**
* The muParser objects (hidden with the PIMPL idiom) for each thread (and
* one for each component).
*/
mutable Threads::ThreadLocalStorage<internal::FunctionParser::ParserData>
parser_data;
+
+ /**
+ * An array to keep track of all the constants, required to initialize fp
+ * in each thread.
+ */
+ std::map<std::string, double> constants;
+
+ /**
+ * An array for the variable names, required to initialize fp in each
+ * thread.
+ */
+ std::vector<std::string> var_names;
+
+ /**
+ * An array of function expressions (one per component), required to
+ * initialize tfp in each thread.
+ */
+ std::vector<std::string> expressions;
+
+ /**
+ * State of usability. This variable is checked every time the function is
+ * called for evaluation. It's set to true in the initialize() methods.
+ */
+ bool initialized;
+
+ /**
+ * Number of variables. If this is also a function of time, then the
+ * number of variables is dim+1, otherwise it is dim. In the case that
+ * this is a time dependent function, the time is supposed to be the last
+ * variable. If #n_vars is not identical to the number of the variables
+ * parsed by the initialize() method, then an exception is thrown.
+ */
+ unsigned int n_vars;
};
int
//@}
private:
- /**
- * An array to keep track of all the constants, required to initialize tfp in
- * each thread.
- */
- std::map<std::string, double> constants;
-
- /**
- * An array for the variable names, required to initialize tfp in each
- * thread.
- */
- std::vector<std::string> var_names;
-
/**
* Initialize tfp and vars on the current thread. This function may only be
* called once per thread. A thread can test whether the function has
void
init_muparser() const;
- /**
- * An array of function expressions (one per component), required to
- * initialize tfp in each thread.
- */
- std::vector<std::string> expressions;
-
- /**
- * State of usability. This variable is checked every time the function is
- * called for evaluation. It's set to true in the initialize() methods.
- */
- bool initialized;
-
- /**
- * Number of variables. If this is also a function of time, then the number
- * of variables is dim+1, otherwise it is dim. In the case that this is a
- * time dependent function, the time is supposed to be the last variable. If
- * #n_vars is not identical to the number of the variables parsed by the
- * initialize() method, then an exception is thrown.
- */
- unsigned int n_vars;
-
/**
* Number of components is equal dim<sup>rank</sup>.
*/
const std::vector<std::string> &
FunctionParser<dim>::get_expressions() const
{
- return expressions;
+ return this->expressions;
}
const double initial_time,
const double h)
: AutoDerivativeFunction<dim>(h, n_components, initial_time)
- , initialized(false)
- , n_vars(0)
{}
: AutoDerivativeFunction<dim>(
h,
Utilities::split_string_list(expression, ';').size())
- , initialized(false)
- , n_vars(0)
{
auto constants_map = Patterns::Tools::Convert<ConstMap>::to_value(
constants,
this->constants = constants;
this->var_names = Utilities::split_string_list(variables, ',');
this->expressions = expressions;
- AssertThrow(((time_dependent) ? dim + 1 : dim) == var_names.size(),
+ AssertThrow(((time_dependent) ? dim + 1 : dim) == this->var_names.size(),
ExcMessage("Wrong number of variables"));
// We check that the number of components of this function matches the
// to the dimension. Once we parsed the variables string, if none of this is
// the case, then an exception is thrown.
if (time_dependent)
- n_vars = dim + 1;
+ this->n_vars = dim + 1;
else
- n_vars = dim;
+ this->n_vars = dim;
// create a parser object for the current thread we can then query in
// value() and vector_value(). this is not strictly necessary because a user
init_muparser();
// finally set the initialization bit
- initialized = true;
+ this->initialized = true;
}
namespace internal
// initialize the objects for the current thread
data.parsers.reserve(this->n_components);
- data.vars.resize(var_names.size());
+ data.vars.resize(this->var_names.size());
for (unsigned int component = 0; component < this->n_components; ++component)
{
data.parsers.emplace_back(
dynamic_cast<internal::FunctionParserImplementation::Parser &>(
*data.parsers.back());
- for (const auto &constant : constants)
+ for (const auto &constant : this->constants)
parser.DefineConst(constant.first, constant.second);
- for (unsigned int iv = 0; iv < var_names.size(); ++iv)
- parser.DefineVar(var_names[iv], &data.vars[iv]);
+ for (unsigned int iv = 0; iv < this->var_names.size(); ++iv)
+ parser.DefineVar(this->var_names[iv], &data.vars[iv]);
// define some compatibility functions:
parser.DefineFun("if", internal::FunctionParser::mu_if, true);
// (the fparser library) but also makes no real sense.
// consequently, in the expressions we set, remove any space
// we may find after function names
- std::string transformed_expression = expressions[component];
+ std::string transformed_expression = this->expressions[component];
for (const auto ¤t_function_name :
internal::FunctionParser::get_function_names())
FunctionParser<dim>::value(const Point<dim> & p,
const unsigned int component) const
{
- Assert(initialized == true, ExcNotInitialized());
+ Assert(this->initialized == true, ExcNotInitialized());
AssertIndexRange(component, this->n_components);
// initialize the parser if that hasn't happened yet on the current thread
for (unsigned int i = 0; i < dim; ++i)
data.vars[i] = p(i);
- if (dim != n_vars)
+ if (dim != this->n_vars)
data.vars[dim] = this->get_time();
try
FunctionParser<dim>::vector_value(const Point<dim> &p,
Vector<double> & values) const
{
- Assert(initialized == true, ExcNotInitialized());
+ Assert(this->initialized == true, ExcNotInitialized());
Assert(values.size() == this->n_components,
ExcDimensionMismatch(values.size(), this->n_components));
for (unsigned int i = 0; i < dim; ++i)
data.vars[i] = p(i);
- if (dim != n_vars)
+ if (dim != this->n_vars)
data.vars[dim] = this->get_time();
for (unsigned int component = 0; component < this->n_components; ++component)
const std::vector<std::string> &
TensorFunctionParser<rank, dim, Number>::get_expressions() const
{
- return expressions;
+ return this->expressions;
}
TensorFunctionParser<rank, dim, Number>::TensorFunctionParser(
const double initial_time)
: TensorFunction<rank, dim, Number>(initial_time)
- , initialized(false)
- , n_vars(0)
, n_components(Utilities::pow(dim, rank))
{}
const std::string &constants,
const std::string &variable_names)
: TensorFunction<rank, dim, Number>()
- , initialized(false)
- , n_vars(0)
, n_components(Utilities::pow(dim, rank))
{
auto constants_map = Patterns::Tools::Convert<ConstMap>::to_value(
this->constants = constants;
this->var_names = Utilities::split_string_list(variables, ',');
this->expressions = expressions;
- AssertThrow(((time_dependent) ? dim + 1 : dim) == var_names.size(),
+ AssertThrow(((time_dependent) ? dim + 1 : dim) == this->var_names.size(),
ExcMessage("Wrong number of variables"));
// We check that the number of
// none of this is the case, then
// an exception is thrown.
if (time_dependent)
- n_vars = dim + 1;
+ this->n_vars = dim + 1;
else
- n_vars = dim;
+ this->n_vars = dim;
// create a parser object for the current thread we can then query
// in value() and vector_value(). this is not strictly necessary
init_muparser();
// finally set the initialization bit
- initialized = true;
+ this->initialized = true;
}
// initialize the objects for the current thread
data.parsers.reserve(this->n_components);
- data.vars.resize(var_names.size());
+ data.vars.resize(this->var_names.size());
for (unsigned int component = 0; component < this->n_components; ++component)
{
data.parsers.emplace_back(
dynamic_cast<internal::TensorFunctionParserImplementation::Parser &>(
*data.parsers.back());
- for (const auto &constant : constants)
+ for (const auto &constant : this->constants)
parser.DefineConst(constant.first, constant.second);
- for (unsigned int iv = 0; iv < var_names.size(); ++iv)
- parser.DefineVar(var_names[iv], &data.vars[iv]);
+ for (unsigned int iv = 0; iv < this->var_names.size(); ++iv)
+ parser.DefineVar(this->var_names[iv], &data.vars[iv]);
// define some compatibility functions:
parser.DefineFun("if", internal::FunctionParser::mu_if, true);
// (the fparser library) but also makes no real sense.
// consequently, in the expressions we set, remove any space
// we may find after function names
- std::string transformed_expression = expressions[component];
+ std::string transformed_expression = this->expressions[component];
for (const auto ¤t_function_name :
internal::FunctionParser::get_function_names())
Tensor<rank, dim, Number>
TensorFunctionParser<rank, dim, Number>::value(const Point<dim> &p) const
{
- Assert(initialized == true, ExcNotInitialized());
+ Assert(this->initialized == true, ExcNotInitialized());
// initialize the parser if that hasn't happened yet on the current thread
internal::FunctionParser::ParserData &data = this->parser_data.get();
for (unsigned int i = 0; i < dim; ++i)
data.vars[i] = p(i);
- if (dim != n_vars)
+ if (dim != this->n_vars)
data.vars[dim] = this->get_time();
std::array<Number, Tensor<rank, dim, Number>::n_independent_components>