]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clean up the internal parser class a bit. 13773/head
authorDavid Wells <drwells@email.unc.edu>
Sat, 21 May 2022 19:29:30 +0000 (15:29 -0400)
committerDavid Wells <drwells@email.unc.edu>
Sat, 21 May 2022 21:10:00 +0000 (17:10 -0400)
include/deal.II/base/mu_parser_internal.h
source/base/mu_parser_internal.cc

index 040a49415207fe22a1b84e3c7e83a81ff1a37168..63f5e458cd99e61b4eceb6c9e236f190ed6481a4 100644 (file)
@@ -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<std::string, double> &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<dim> &p,
                const double      time,
                unsigned int      component) const;
 
+      /**
+       * Compute the values of all components.
+       */
       void
       do_all_values(const Point<dim> & p,
                     const double       time,
                     ArrayView<Number> &values) const;
 
+      /**
+       * An array of function expressions (one per component), required to
+       * initialize tfp in each thread.
+       */
+      std::vector<std::string> expressions;
+
+    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.
@@ -199,12 +222,6 @@ namespace internal
        */
       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.
index 07bf42886c81ff9e10da3fad0965d70af9d73362..fd528f82e2ed0b241f351294d052aa4d1ac8cf5f 100644 (file)
@@ -222,6 +222,11 @@ namespace internal
     };
 #endif
 
+    template <int dim, typename Number>
+    ParserImplementation<dim, Number>::ParserImplementation()
+      : initialized(false)
+      , n_vars(0)
+    {}
 
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.