From 9b9518525078b3cff8be0aed225b6fb6ae921570 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 1 Jul 2005 13:20:07 +0000 Subject: [PATCH] More doc changes. Move the include directive into the .cc file. git-svn-id: https://svn.dealii.org/trunk@11035 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/function_parser.h | 157 ++++++++++---------- deal.II/base/source/function_parser.cc | 6 + 2 files changed, 85 insertions(+), 78 deletions(-) diff --git a/deal.II/base/include/base/function_parser.h b/deal.II/base/include/base/function_parser.h index 6f153a3bf1..d96b0da535 100644 --- a/deal.II/base/include/base/function_parser.h +++ b/deal.II/base/include/base/function_parser.h @@ -21,19 +21,11 @@ #include #include -#ifndef DEAL_II_DISABLE_PARSER -#include -#else namespace fparser { - /** - * Dummy definition if - * FunctionParser is not used. - */ - class FunctionParser {}; -}; + class FunctionParser; +} -#endif template class Point; template class Tensor; @@ -107,7 +99,7 @@ template class Vector; * * The syntax to describe a function follows usual programming practice, * and is explained in this snippet from the fparser.txt file: - @verbatim + @verbatim The function string understood by the class is very similar to the C-syntax. Arithmetic float expressions can be created from float literals, variables or functions using the following operators in this order of precedence: @@ -200,6 +192,60 @@ template class Vector; will make the program eventually run out of memory). @endverbatim * + * Vector-valued functions can either be declared using strings where the + * function components are separated by semicolons, or using a vector of + * strings each defining one vector component. + * + * An example of time dependent scalar function is the following: + @verbatim + + // Empty constants object + std::map constants; + + // Variables that will be used inside the expressions + std::string variables = "x,y,t"; + + // Define the expression of the scalar time dependent function. + std::string expression = "exp(y*x)*exp(-t)"; + + // Generate an empty scalar function + FunctionParser<2> function; + + // And populate it with the newly created objects. + function.initialize(variables, + expression, + constants, + true); // This tells the parser that + // it is a time-dependent function + // and there is another variable + // to be taken into account (t). + + @endverbatim + + * The following is another example of how to instantiate a + * vector valued function by using a single string: + @verbatim + + // Empty constants object + std::map constants; + + // Variables that will be used inside the expressions + std::string variables = "x,y"; + + // Define the expression of the vector valued function. + std::string expression = "cos(2*pi*x)*y^2; sin(2*pi*x)*exp(y)"; + + // Generate an empty vector valued function + FunctionParser<2> function(2); + + // And populate it with the newly created objects. + function.initialize(variables, + expression, + constants); + + @endverbatim + * + * * @author Luca Heltai, 2005 */ template @@ -311,74 +357,29 @@ class FunctionParser : public Function * default for this parameter is false, * i.e. use radians and not degrees. */ - 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, + const bool time_dependent = false, + const 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 - function, its componenents are expected to be separated by a - semicolon. An exception is thrown if this method is called and - the number of components successfully parsed does not match the - number of components of the base function. - - An example of time dependent scalar function is the following: - @verbatim - - // Empty constants object - std::map constants; - - // Variables that will be used inside the expressions - std::string variables = "x,y,t"; - - // Define the expression of the scalar time dependent function. - std::string expression = "exp(y*x)*exp(-t)"; - - // Generate an empty scalar function - FunctionParser<2> function; - - // And populate it with the newly created objects. - function.initialize(variables, - expression, - constants, - true); // This tells the parser that - // it is a time-dependent function - // and there is another variable - // to be taken into account (t). - - @endverbatim - - The following is yet another example of how to instantiate a - vector valued function by using a single string: - @verbatim - - // Empty constants object - std::map constants; - - // Variables that will be used inside the expressions - std::string variables = "x,y"; - - // Define the expression of the vector valued function. - std::string expression = "cos(2*pi*x)*y^2; sin(2*pi*x)*exp(y)"; - - // Generate an empty vector valued function - FunctionParser<2> function(2); - - // And populate it with the newly created objects. - function.initialize(variables, - expression, - constants); - - @endverbatim - - */ - void initialize(const std::string vars, - const std::string expression, - 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 function, its + * componenents are expected to be + * separated by a semicolon. An exception + * is thrown if this method is called and + * the number of components successfully + * parsed does not match the number of + * components of the base function. + */ + void initialize (const std::string vars, + const std::string expression, + const ConstMap constants, + const bool time_dependent = false, + const bool use_degrees = false); /** diff --git a/deal.II/base/source/function_parser.cc b/deal.II/base/source/function_parser.cc index 5e851707e2..a994810a76 100644 --- a/deal.II/base/source/function_parser.cc +++ b/deal.II/base/source/function_parser.cc @@ -15,6 +15,12 @@ #include #include +#ifndef DEAL_II_DISABLE_PARSER +#include +#endif + + + // Utility to split a string given a delimiter. unsigned int SplitString(const std::string& input, -- 2.39.5