From 2c037e72c61de29405e5613ce82a2b194973cf30 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 21 May 2022 15:29:30 -0400 Subject: [PATCH] Clean up the internal parser class a bit. --- include/deal.II/base/mu_parser_internal.h | 37 +++++++++++++++++------ source/base/mu_parser_internal.cc | 5 +++ 2 files changed, 32 insertions(+), 10 deletions(-) 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) + {} -- 2.39.5