Skip to content

Commit

Permalink
Clean up the internal parser class a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
drwells committed May 21, 2022
1 parent b5e89b3 commit d10f56d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
37 changes: 27 additions & 10 deletions include/deal.II/base/mu_parser_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions source/base/mu_parser_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ namespace internal
};
#endif

template <int dim, typename Number>
ParserImplementation<dim, Number>::ParserImplementation()
: initialized(false)
, n_vars(0)
{}



Expand Down

0 comments on commit d10f56d

Please sign in to comment.