From: Guido Kanschat Date: Fri, 8 Apr 2005 10:03:23 +0000 (+0000) Subject: optionally disable parser X-Git-Tag: v8.0.0~14118 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=030b548a0183b96dfa4636af1e5f070ba1051e39;p=dealii.git optionally disable parser git-svn-id: https://svn.dealii.org/trunk@10429 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/function_parser.h b/deal.II/base/include/base/function_parser.h index ebb308b8e0..ae308ab42c 100644 --- a/deal.II/base/include/base/function_parser.h +++ b/deal.II/base/include/base/function_parser.h @@ -20,7 +20,21 @@ #include #include #include + +#ifndef DEAL_II_DISABLE_PARSER #include +#else +namespace fparser +{ + /** + * Dummy definition if + * FunctionParser is not used. + */ + class FunctionParser {}; + +}; + +#endif template class Point; template class Tensor; @@ -94,24 +108,44 @@ template class FunctionParser : public Function { public: - /** Constructor for Parsed functions. Its arguments are the same of - the base class Function. The only difference is that this object - needs to be initialized with initialize() method before you can - use it. If an attempt to use this function is made before the - initialize() method has been called, then an exception is - thrown. */ - FunctionParser (const unsigned int n_components = 1, - const double initial_time = 0.0); + /** + * Constructor for Parsed + * functions. Its arguments are + * the same of the base class + * Function. The only difference + * is that this object needs to + * be initialized with + * initialize() method before you + * can use it. If an attempt to + * use this function is made + * before the initialize() method + * has been called, then an + * exception is thrown. + */ + FunctionParser (const unsigned int n_components = 1, + const double initial_time = 0.0); - /** Destructor. Explicitly delete the FunctionParser objects (there - is one for each component of the function). */ - ~FunctionParser(); - - /** Type for the constant map. Used by the initialize() method. */ - typedef std::map ConstMap; - - /** Iterator for the constants map. Used by the initialize() method. */ - typedef ConstMap::iterator ConstMapIterator; + /** + * Destructor. Explicitly delete + * the FunctionParser objects + * (there is one for each + * component of the function). + */ + ~FunctionParser(); + + /** + * Type for the constant + * map. Used by the initialize() + * method. + */ + typedef std::map ConstMap; + + /** + * Iterator for the constants + * map. Used by the initialize() + * method. + */ + typedef ConstMap::iterator ConstMapIterator; /** Initialize the function. From the fparser.txt file: @verbatim @@ -248,11 +282,11 @@ class FunctionParser : public Function */ - void initialize(const std::string vars, - const std::vector expressions, - const ConstMap constants, - bool time_dependent = false, - bool use_degrees = false); + void initialize(const std::string vars, + const std::vector expressions, + const ConstMap constants, + bool time_dependent = false, + bool use_degrees = false); /** Initialize the function. Same as above, but accepts a string rather than a vector of strings. If this is a vector valued @@ -311,29 +345,36 @@ class FunctionParser : public Function @endverbatim */ - void initialize(const std::string vars, - const std::string expression, - const ConstMap constants, - bool time_dependent = false, - bool use_degrees = false); + void initialize(const std::string vars, + const std::string expression, + const ConstMap constants, + bool time_dependent = false, + bool use_degrees = false); - /** - * Return the value of the function at the given point. Unless there - * is only one component (i.e. the function is scalar), you should - * state the component you want to have evaluated; it defaults to - * zero, i.e. the first component. */ + /** + * Return the value of the + * function at the given + * point. Unless there is only + * one component (i.e. the + * function is scalar), you + * should state the component you + * want to have evaluated; it + * defaults to zero, i.e. the + * first component. + */ virtual double value (const Point &p, const unsigned int component = 0) const; - /** - * Return all components of a vector-valued function at a given - * point. - * - * values shall have the - * right size beforehand, - * i.e. #n_components. - */ + /** + * Return all components of a + * vector-valued function at a + * given point. + * + * values shall have the + * right size beforehand, + * i.e. #n_components. + */ virtual void vector_value (const Point &p, Vector &values) const; @@ -351,23 +392,37 @@ class FunctionParser : public Function << arg2 << ")."); //@} - private: - /** A pointer to the actual function parsers. */ - fparser::FunctionParser * fp; + private: + /** + * A pointer to the actual + * function parsers. + */ + fparser::FunctionParser * fp; - /** State of usability. This variable is checked every time the - function is called for evaluation. It's set to true in the - initialize() methods.*/ - bool initialized; + /** + * State of usability. This + * variable is checked every time + * the function is called for + * evaluation. It's set to true + * in the initialize() methods. + */ + bool initialized; - /** Number of variables. If this is also a function of time, then the - number of variables is dim+1, otherwhise it is dim. In the case - that this is a time dependent function, the time is supposed to - be the last variable. If #n_vars is not identical to the number - of the variables parsed by the initialize() method, then an - exception is thrown. - */ - unsigned int n_vars; + /** + * Number of variables. If this + * is also a function of time, + * then the number of variables + * is dim+1, otherwhise it is + * dim. In the case that this is + * a time dependent function, the + * time is supposed to be the + * last variable. If #n_vars is + * not identical to the number of + * the variables parsed by the + * initialize() method, then an + * exception is thrown. + */ + unsigned int n_vars; }; diff --git a/deal.II/base/source/function_parser.cc b/deal.II/base/source/function_parser.cc index a5390533e3..feb7068a49 100644 --- a/deal.II/base/source/function_parser.cc +++ b/deal.II/base/source/function_parser.cc @@ -16,6 +16,7 @@ #include // Utility to split a string given a delimiter. + unsigned int SplitString(const std::string& input, const std::string& delimiter, std::vector& results) @@ -82,6 +83,8 @@ FunctionParser::~FunctionParser() { delete[] fp; } +#ifndef DEAL_II_DISABLE_PARSER + template void FunctionParser::initialize(const std::string variables, const std::vector expressions, @@ -158,7 +161,6 @@ void FunctionParser::initialize(const std::string variables, } template -inline double FunctionParser::value (const Point &p, unsigned int component) const { @@ -186,7 +188,6 @@ double FunctionParser::value (const Point &p, template -inline void FunctionParser::vector_value (const Point &p, Vector &values) const { @@ -213,6 +214,46 @@ void FunctionParser::vector_value (const Point &p, } } +#else + + +template +void FunctionParser::initialize( + const std::string, const std::vector, + std::map, bool, bool) +{ + Assert(false, ExcDisabled("parser")); +} + + +template +void FunctionParser::initialize( + const std::string, const std::string, + std::map, bool, bool) +{ + Assert(false, ExcDisabled("parser")); +} + + +template +double FunctionParser::value ( + const Point &, unsigned int) const +{ + Assert(false, ExcDisabled("parser")); + return 0.; +} + + +template +void FunctionParser::vector_value ( + const Point&, Vector&) const +{ + Assert(false, ExcDisabled("parser")); +} + + +#endif + // Explicit Instantiations. template class FunctionParser<1>;