// ---------------------------------------------------------------------
//
-// Copyright (C) 2005 - 2013 by the deal.II authors
+// Copyright (C) 2005 - 2014 by the deal.II authors
//
// This file is part of the deal.II library.
//
template <int dim>
void FunctionParser<dim>:: init_muparser() const
{
- if (fp.get().size()>0)
- return;
+ // check that we have not already initialized the parser on the
+ // current thread, i.e., that the current function is only called
+ // once per thread
+ Assert (fp.get().size()==0, ExcInternalError());
+ // initialize the objects for the current thread (fp.get() and
+ // vars.get())
fp.get().resize(this->n_components);
vars.get().resize(var_names.size());
for (unsigned int component=0; component<this->n_components; ++component)
else
n_vars = dim;
- init_muparser();
+ // create a parser object for the current thread we can then query
+ // in value() and vector_value(). this is not strictly necessary
+ // because a user may never call these functions on the current
+ // thread, but it gets us error messages about wrong formulas right
+ // away
+ init_muparser ();
- // Now set the initialization bit.
+ // finally set the initialization bit
initialized = true;
}
Assert (component < this->n_components,
ExcIndexRange(component, 0, this->n_components));
- // initialize if not done so on this thread yet:
- init_muparser();
+ // initialize the parser if that hasn't happened yet on the current thread
+ if (fp.get().size() == 0)
+ init_muparser();
for (unsigned int i=0; i<dim; ++i)
vars.get()[i] = p(i);
ExcDimensionMismatch (values.size(), this->n_components));
- // initialize if not done so on this thread yet:
- init_muparser();
+ // initialize the parser if that hasn't happened yet on the current thread
+ if (fp.get().size() == 0)
+ init_muparser();
for (unsigned int i=0; i<dim; ++i)
vars.get()[i] = p(i);