From: David Wells Date: Sat, 21 May 2022 03:43:45 +0000 (-0400) Subject: Move FunctionParser's thread-local data into a base class. X-Git-Tag: v9.4.0-rc1~132^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9dc837877f87b22acc7cca79a548398c459fe43;p=dealii.git Move FunctionParser's thread-local data into a base class. --- diff --git a/include/deal.II/base/function_parser.h b/include/deal.II/base/function_parser.h index da8d955e58..05c81c7a23 100644 --- a/include/deal.II/base/function_parser.h +++ b/include/deal.II/base/function_parser.h @@ -21,13 +21,11 @@ #include #include +#include #include #include -#include -#include #include -#include #include DEAL_II_NAMESPACE_OPEN @@ -216,7 +214,9 @@ class Vector; * @ingroup functions */ template -class FunctionParser : public AutoDerivativeFunction +class FunctionParser + : public AutoDerivativeFunction, + protected internal::FunctionParser::ParserImplementation { public: /** @@ -381,13 +381,6 @@ public: //@} private: - /** - * The muParser objects (hidden with the PIMPL idiom) for each thread (and one - * for each component). - */ - mutable Threads::ThreadLocalStorage - parser_data; - /** * An array to keep track of all the constants, required to initialize fp in * each thread. diff --git a/include/deal.II/base/mu_parser_internal.h b/include/deal.II/base/mu_parser_internal.h index 76a567b897..39ffa8c098 100644 --- a/include/deal.II/base/mu_parser_internal.h +++ b/include/deal.II/base/mu_parser_internal.h @@ -21,6 +21,9 @@ #include +#include + +#include #include #include @@ -85,6 +88,18 @@ namespace internal std::vector> parsers; }; + template + class ParserImplementation + { + public: + /** + * The muParser objects (hidden with the PIMPL idiom) for each thread (and + * one for each component). + */ + mutable Threads::ThreadLocalStorage + parser_data; + }; + int mu_round(double val); diff --git a/include/deal.II/base/tensor_function_parser.h b/include/deal.II/base/tensor_function_parser.h index eba3e486e5..568febb6b2 100644 --- a/include/deal.II/base/tensor_function_parser.h +++ b/include/deal.II/base/tensor_function_parser.h @@ -21,14 +21,12 @@ #include #include +#include #include #include #include -#include -#include #include -#include #include DEAL_II_NAMESPACE_OPEN @@ -105,7 +103,9 @@ class Vector; * @ingroup functions */ template -class TensorFunctionParser : public TensorFunction +class TensorFunctionParser + : public TensorFunction, + protected internal::FunctionParser::ParserImplementation { public: /** @@ -263,13 +263,6 @@ public: //@} private: - /** - * The muParser objects (hidden with the PIMPL idiom) for each thread (and one - * for each component). - */ - mutable Threads::ThreadLocalStorage - parser_data; - /** * An array to keep track of all the constants, required to initialize tfp in * each thread. diff --git a/source/base/function_parser.cc b/source/base/function_parser.cc index ea1c952ad5..09037c51eb 100644 --- a/source/base/function_parser.cc +++ b/source/base/function_parser.cc @@ -158,7 +158,7 @@ FunctionParser::init_muparser() const // 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 @@ -280,7 +280,7 @@ FunctionParser::value(const Point & p, 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(); @@ -327,7 +327,7 @@ FunctionParser::vector_value(const Point &p, // 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(); diff --git a/source/base/tensor_function_parser.cc b/source/base/tensor_function_parser.cc index 1402675a9e..6396a0062e 100644 --- a/source/base/tensor_function_parser.cc +++ b/source/base/tensor_function_parser.cc @@ -173,7 +173,7 @@ TensorFunctionParser::init_muparser() const // 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 @@ -294,7 +294,7 @@ TensorFunctionParser::value(const Point &p) const 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();