From: David Wells Date: Sat, 21 May 2022 19:29:30 +0000 (-0400) Subject: Clean up the internal parser class a bit. X-Git-Tag: v9.4.0-rc1~132^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c037e72c61de29405e5613ce82a2b194973cf30;p=dealii.git Clean up the internal parser class a bit. --- diff --git a/include/deal.II/base/mu_parser_internal.h b/include/deal.II/base/mu_parser_internal.h index 040a494152..63f5e458cd 100644 --- a/include/deal.II/base/mu_parser_internal.h +++ b/include/deal.II/base/mu_parser_internal.h @@ -158,10 +158,9 @@ namespace internal class ParserImplementation { public: - ParserImplementation() - : initialized(false) - , n_vars(0) - {} + ParserImplementation(); + + virtual ~ParserImplementation() = default; /** * Initialize the internal state of the object. This is the same as the @@ -174,19 +173,43 @@ namespace internal const std::map &constants, const bool time_dependent = false); + /** + * Set up the internal muParser objects to parse and evaluate mathematical + * expressions. + */ void init_muparser() const; + /** + * Compute the value of a single component. + */ Number do_value(const Point &p, const double time, unsigned int component) const; + /** + * Compute the values of all components. + */ void do_all_values(const Point & p, const double time, ArrayView &values) const; + /** + * An array of function expressions (one per component), required to + * initialize tfp in each thread. + */ + std::vector expressions; + + 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. @@ -199,12 +222,6 @@ namespace internal */ std::vector var_names; - /** - * An array of function expressions (one per component), required to - * initialize tfp in each thread. - */ - std::vector 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. diff --git a/source/base/mu_parser_internal.cc b/source/base/mu_parser_internal.cc index 07bf42886c..fd528f82e2 100644 --- a/source/base/mu_parser_internal.cc +++ b/source/base/mu_parser_internal.cc @@ -222,6 +222,11 @@ namespace internal }; #endif + template + ParserImplementation::ParserImplementation() + : initialized(false) + , n_vars(0) + {}