#include <deal.II/base/auto_derivative_function.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/mu_parser_internal.h>
#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>
-#include <deal.II/base/thread_local_storage.h>
-#include <deal.II/base/mu_parser_internal.h>
#include <map>
-#include <memory>
#include <vector>
DEAL_II_NAMESPACE_OPEN
* @ingroup functions
*/
template <int dim>
-class FunctionParser : public AutoDerivativeFunction<dim>
+class FunctionParser
+ : public AutoDerivativeFunction<dim>,
+ protected internal::FunctionParser::ParserImplementation<dim, double>
{
public:
/**
//@}
private:
- /**
- * 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.
#include <deal.II/base/config.h>
+#include <deal.II/base/thread_local_storage.h>
+
+#include <memory>
#include <string>
#include <vector>
std::vector<std::unique_ptr<muParserBase>> parsers;
};
+ template <int dim, typename Number>
+ class ParserImplementation
+ {
+ public:
+ /**
+ * The muParser objects (hidden with the PIMPL idiom) for each thread (and
+ * one for each component).
+ */
+ mutable Threads::ThreadLocalStorage<internal::FunctionParser::ParserData>
+ parser_data;
+ };
+
int
mu_round(double val);
#include <deal.II/base/exceptions.h>
#include <deal.II/base/function_parser.h>
+#include <deal.II/base/mu_parser_internal.h>
#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/tensor_function.h>
-#include <deal.II/base/thread_local_storage.h>
-#include <deal.II/base/mu_parser_internal.h>
#include <map>
-#include <memory>
#include <vector>
DEAL_II_NAMESPACE_OPEN
* @ingroup functions
*/
template <int rank, int dim, typename Number = double>
-class TensorFunctionParser : public TensorFunction<rank, dim, Number>
+class TensorFunctionParser
+ : public TensorFunction<rank, dim, Number>,
+ protected internal::FunctionParser::ParserImplementation<dim, Number>
{
public:
/**
//@}
private:
- /**
- * 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 tfp in
* each thread.
// check that we have not already initialized the parser on the
// current thread, i.e., that the current function is only called
// once per thread
- internal::FunctionParser::ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = this->parser_data.get();
Assert(data.parsers.size() == 0 && data.vars.size() == 0, ExcInternalError());
// initialize the objects for the current thread
AssertIndexRange(component, this->n_components);
// initialize the parser if that hasn't happened yet on the current thread
- internal::FunctionParser::ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = this->parser_data.get();
if (data.vars.size() == 0)
init_muparser();
// initialize the parser if that hasn't happened yet on the current thread
- internal::FunctionParser::ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = this->parser_data.get();
if (data.vars.size() == 0)
init_muparser();
// check that we have not already initialized the parser on the
// current thread, i.e., that the current function is only called
// once per thread
- internal::FunctionParser::ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = this->parser_data.get();
Assert(data.parsers.size() == 0 && data.vars.size() == 0, ExcInternalError());
// initialize the objects for the current thread
Assert(initialized == true, ExcNotInitialized());
// initialize the parser if that hasn't happened yet on the current thread
- internal::FunctionParser::ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = this->parser_data.get();
if (data.vars.size() == 0)
init_muparser();