#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/thread_local_storage.h>
+#include <deal.II/base/mu_parser_internal.h>
#include <map>
#include <memory>
class Vector;
#endif
-namespace internal
-{
- /**
- * deal.II uses muParser as a purely internal dependency. To this end, we do
- * not include any muParser headers in this file (and the bundled version of
- * the dependency does not install its headers or compile a separate muparser
- * library). Hence, to interface with muParser, we use the PIMPL idiom here to
- * wrap a pointer to mu::Parser objects.
- */
- class muParserBase
- {
- public:
- virtual ~muParserBase() = default;
- };
-} // namespace internal
-
/**
* This class implements a function object that gets its value by parsing a
* string describing this function. It is a wrapper class for the muparser
//@}
private:
- /**
- * Class containing the mutable state required by muParser.
- *
- * @note For performance reasons it is best to put all mutable state in a
- * single object so that, for each function call, we only need to get
- * thread-local data exactly once.
- */
- struct ParserData
- {
- /**
- * Default constructor. Threads::ThreadLocalStorage requires that objects be
- * either default- or copy-constructible: make sure we satisfy the first
- * case by declaring it here.
- */
- ParserData() = default;
-
- /**
- * std::is_copy_constructible gives the wrong answer for containers with
- * non-copy constructible types (e.g., std::vector<std::unique_ptr<int>>) -
- * for more information, see the documentation of
- * Threads::ThreadLocalStorage. Hence, to avoid compilation failures, just
- * delete the copy constructor completely.
- */
- ParserData(const ParserData &) = delete;
-
- /**
- * Scratch array used to set independent variables (i.e., x, y, and t)
- * before each muParser call.
- */
- std::vector<double> vars;
-
- /**
- * The actual muParser parser objects (hidden with PIMPL).
- */
- std::vector<std::unique_ptr<internal::muParserBase>> parsers;
- };
-
/**
* The muParser objects (hidden with the PIMPL idiom) for each thread (and one
* for each component).
*/
- mutable Threads::ThreadLocalStorage<ParserData> parser_data;
+ mutable Threads::ThreadLocalStorage<internal::FunctionParser::ParserData>
+ parser_data;
/**
* An array to keep track of all the constants, required to initialize fp in
{
namespace FunctionParser
{
+ /**
+ * deal.II uses muParser as a purely internal dependency. To this end, we do
+ * not include any muParser headers in our own headers (and the bundled
+ * version of the dependency does not install its headers or compile a
+ * separate muparser library). Hence, to interface with muParser, we use the
+ * PIMPL idiom here to wrap a pointer to mu::Parser objects.
+ */
+ class muParserBase
+ {
+ public:
+ virtual ~muParserBase() = default;
+ };
+
+ /**
+ * Class containing the mutable state required by muParser.
+ *
+ * @note For performance reasons it is best to put all mutable state in a
+ * single object so that, for each function call, we only need to get
+ * thread-local data exactly once.
+ */
+ struct ParserData
+ {
+ /**
+ * Default constructor. Threads::ThreadLocalStorage requires that objects
+ * be either default- or copy-constructible: make sure we satisfy the
+ * first case by declaring it here.
+ */
+ ParserData() = default;
+
+ /**
+ * std::is_copy_constructible gives the wrong answer for containers with
+ * non-copy constructible types (e.g., std::vector<std::unique_ptr<int>>)
+ * - for more information, see the documentation of
+ * Threads::ThreadLocalStorage. Hence, to avoid compilation failures, just
+ * delete the copy constructor completely.
+ */
+ ParserData(const ParserData &) = delete;
+
+ /**
+ * Scratch array used to set independent variables (i.e., x, y, and t)
+ * before each muParser call.
+ */
+ std::vector<double> vars;
+
+ /**
+ * The actual muParser parser objects (hidden with PIMPL).
+ */
+ std::vector<std::unique_ptr<muParserBase>> parsers;
+ };
+
int
mu_round(double val);
#include <deal.II/base/tensor.h>
#include <deal.II/base/tensor_function.h>
#include <deal.II/base/thread_local_storage.h>
+#include <deal.II/base/mu_parser_internal.h>
#include <map>
#include <memory>
//@}
private:
- /**
- * Class containing the mutable state required by muParser.
- *
- * @note For performance reasons it is best to put all mutable state in a
- * single object so that, for each function call, we only need to get
- * thread-local data exactly once.
- */
- struct ParserData
- {
- /**
- * Default constructor. Threads::ThreadLocalStorage requires that objects be
- * either default- or copy-constructible: make sure we satisfy the first
- * case by declaring it here.
- */
- ParserData() = default;
-
- /**
- * std::is_copy_constructible gives the wrong answer for containers with
- * non-copy constructible types (e.g., std::vector<std::unique_ptr<int>>) -
- * for more information, see the documentation of
- * Threads::ThreadLocalStorage. Hence, to avoid compilation failures, just
- * delete the copy constructor completely.
- */
- ParserData(const ParserData &) = delete;
-
- /**
- * Scratch array used to set independent variables (i.e., x, y, and t)
- * before each muParser call.
- */
- std::vector<double> vars;
-
- /**
- * The actual muParser parser objects (hidden with PIMPL).
- */
- std::vector<std::unique_ptr<internal::muParserBase>> parsers;
- };
-
/**
* The muParser objects (hidden with the PIMPL idiom) for each thread (and one
* for each component).
*/
- mutable Threads::ThreadLocalStorage<ParserData> parser_data;
+ mutable Threads::ThreadLocalStorage<internal::FunctionParser::ParserData>
+ parser_data;
/**
* An array to keep track of all the constants, required to initialize tfp in
/**
* PIMPL for mu::Parser.
*/
- class Parser : public internal::muParserBase
+ class Parser : public internal::FunctionParser::muParserBase
{
public:
operator mu::Parser &()
// 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
- ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = parser_data.get();
Assert(data.parsers.size() == 0 && data.vars.size() == 0, ExcInternalError());
// initialize the objects for the current thread
AssertIndexRange(component, this->n_components);
// initialize the parser if that hasn't happened yet on the current thread
- ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = parser_data.get();
if (data.vars.size() == 0)
init_muparser();
// initialize the parser if that hasn't happened yet on the current thread
- ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = parser_data.get();
if (data.vars.size() == 0)
init_muparser();
/**
* PIMPL for mu::Parser.
*/
- class Parser : public internal::muParserBase
+ class Parser : public internal::FunctionParser::muParserBase
{
public:
operator mu::Parser &()
// 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
- ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = parser_data.get();
Assert(data.parsers.size() == 0 && data.vars.size() == 0, ExcInternalError());
// initialize the objects for the current thread
Assert(initialized == true, ExcNotInitialized());
// initialize the parser if that hasn't happened yet on the current thread
- ParserData &data = parser_data.get();
+ internal::FunctionParser::ParserData &data = parser_data.get();
if (data.vars.size() == 0)
init_muparser();