]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
switch to ThreadLocal::clear, clean up code
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 7 Feb 2014 21:37:43 +0000 (21:37 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 7 Feb 2014 21:37:43 +0000 (21:37 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_muparser@32435 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/function_parser.h
deal.II/source/base/function_parser.cc

index 5a83e54adccc0eb4d14ef0dedcb90c2e5cc9fa38..aed11555f1141718564b23e6746d748bc4e56bc7 100644 (file)
@@ -564,19 +564,29 @@ public:
 private:
 #ifdef DEAL_II_WITH_MUPARSER
   /**
-   * muParser will stores references to these variables.
+   * place for the variables for each thread
    */
-
-    // TODO: document variables
     mutable Threads::ThreadLocalStorage<std::vector<double> > vars;
+    /**
+     * the muParser objects for each thread (and one for each component)
+     */
     mutable Threads::ThreadLocalStorage<std::vector<mu::Parser> > fp;
-    mutable Threads::ThreadLocalStorage<unsigned int> init_at_version;
 
-    unsigned int version;
-    
+    /**
+     * keep track of all the constants, required to initialize fp in each thread
+     */
     std::map< std::string, double > constants;
+    /**
+     * variable names, required to initialize fp in each thread
+     */
     std::vector<std::string> var_names;
+    /**
+     * the expressions, required to initialize fp in each thread
+     */
     std::vector<std::string> expressions;
+    /**
+     * this function will initialize fp on the current thread
+     */
     void init_muparser() const;
 #else
   /**
index fe95dd5fe260f4012a850f65188113f63d7f001e..76afd0182b323fdb553b25316da00f6519595a5d 100644 (file)
@@ -51,7 +51,6 @@ FunctionParser<dim>::FunctionParser(const unsigned int n_components,
   :
   Function<dim>(n_components, initial_time)
 #ifdef DEAL_II_WITH_MUPARSER
-  ,version(0)
 #else
   ,fp (0)
 #endif
@@ -105,7 +104,7 @@ void FunctionParser<dim>::initialize (const std::string              &vars,
 template <int dim>
 void FunctionParser<dim>:: init_muparser() const
 {
-  if (version == init_at_version.get())
+  if (fp.get().size()>0)
     return;
   
   fp.get().resize(this->n_components);
@@ -151,8 +150,8 @@ void FunctionParser<dim>::initialize (const std::string   &variables,
 {
 
 #ifdef DEAL_II_WITH_MUPARSER
-  version++;
-
+  this->fp.clear(); // this will reset all thread-local objects
+  
   this->constants = constants;
   this->var_names = Utilities::split_string_list(variables, ',');
   this->expressions = expressions;

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.