From: heister Date: Fri, 7 Feb 2014 21:37:43 +0000 (+0000) Subject: switch to ThreadLocal::clear, clean up code X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f86db954a96363b30407b193cc8f703d988ccca;p=dealii-svn.git switch to ThreadLocal::clear, clean up code git-svn-id: https://svn.dealii.org/branches/branch_muparser@32435 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/function_parser.h b/deal.II/include/deal.II/base/function_parser.h index 5a83e54adc..aed11555f1 100644 --- a/deal.II/include/deal.II/base/function_parser.h +++ b/deal.II/include/deal.II/base/function_parser.h @@ -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 > vars; + /** + * the muParser objects for each thread (and one for each component) + */ mutable Threads::ThreadLocalStorage > fp; - mutable Threads::ThreadLocalStorage 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 var_names; + /** + * the expressions, required to initialize fp in each thread + */ std::vector expressions; + /** + * this function will initialize fp on the current thread + */ void init_muparser() const; #else /** diff --git a/deal.II/source/base/function_parser.cc b/deal.II/source/base/function_parser.cc index fe95dd5fe2..76afd0182b 100644 --- a/deal.II/source/base/function_parser.cc +++ b/deal.II/source/base/function_parser.cc @@ -51,7 +51,6 @@ FunctionParser::FunctionParser(const unsigned int n_components, : Function(n_components, initial_time) #ifdef DEAL_II_WITH_MUPARSER - ,version(0) #else ,fp (0) #endif @@ -105,7 +104,7 @@ void FunctionParser::initialize (const std::string &vars, template void FunctionParser:: 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::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;