From: Luca Heltai Date: Sun, 20 Mar 2016 11:55:48 +0000 (+0100) Subject: Addressed comments by @wolfgang X-Git-Tag: v8.5.0-rc1~1191^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c9a93022c527499472d8b718f505b65227dbd83;p=dealii.git Addressed comments by @wolfgang --- diff --git a/include/deal.II/base/function_parser.h b/include/deal.II/base/function_parser.h index 3fe91a0c4e..a271c0a256 100644 --- a/include/deal.II/base/function_parser.h +++ b/include/deal.II/base/function_parser.h @@ -181,14 +181,17 @@ class FunctionParser : public AutoDerivativeFunction { 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. + * Constructor for Parsed functions. Its arguments are the same of + * the base class Function, with the additional parameter @p h, used + * for the computation of gradients using finite differences. This + * object needs to be initialized with the 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); + const double initial_time = 0.0, + const double h = 1e-8); /** * Destructor. Explicitly delete the FunctionParser objects (there is one diff --git a/include/deal.II/grid/manifold_lib.h b/include/deal.II/grid/manifold_lib.h index 15b3d7e4dc..04b75b8ee0 100644 --- a/include/deal.II/grid/manifold_lib.h +++ b/include/deal.II/grid/manifold_lib.h @@ -250,7 +250,8 @@ public: const typename FunctionParser::ConstMap = typename FunctionParser::ConstMap(), const std::string chart_vars=FunctionParser::default_variable_names(), const std::string space_vars=FunctionParser::default_variable_names(), - const double tolerance=1e-10); + const double tolerance=1e-10, + const double h=1e-8); /** * If needed, we delete the pointers we own. @@ -273,7 +274,15 @@ public: * $\text{spacedim}\times\text{chartdim}$. * * This function is used in the computations required by the - * get_tangent_vector() function. + * get_tangent_vector() function. The default implementation calls + * the get_gradient() method of the + * FunctionManifold::push_forward_function() member class. If you + * construct this object using the constructor that takes two string + * expression, then the default implementation of this method uses a + * finite difference scheme to compute the gradients(see the + * AutoDerivativeFunction() class for details), and you can specify + * the size of the spatial step size at construction time with the + * @p h parameter. * * Refer to the general documentation of this class for more information. */ diff --git a/source/base/function_parser.cc b/source/base/function_parser.cc index 094869b40f..e00dddadf8 100644 --- a/source/base/function_parser.cc +++ b/source/base/function_parser.cc @@ -46,9 +46,10 @@ DEAL_II_NAMESPACE_OPEN template FunctionParser::FunctionParser(const unsigned int n_components, - const double initial_time) + const double initial_time, + const double h) : - AutoDerivativeFunction(1e-8, n_components, initial_time) + AutoDerivativeFunction(h, n_components, initial_time) {} diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index 0d039f8c86..e889eadd38 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -267,14 +267,15 @@ FunctionManifold::FunctionManifold const typename FunctionParser::ConstMap const_map, const std::string chart_vars, const std::string space_vars, - const double tolerance) : + const double tolerance, + const double h) : ChartManifold(periodicity), const_map(const_map), tolerance(tolerance), owns_pointers(true) { - FunctionParser *pf = new FunctionParser(spacedim); - FunctionParser *pb = new FunctionParser(chartdim); + FunctionParser *pf = new FunctionParser(spacedim, 0.0, h); + FunctionParser *pb = new FunctionParser(chartdim, 0.0, h); pf->initialize(chart_vars, push_forward_expression, const_map); pb->initialize(space_vars, pull_back_expression, const_map); push_forward_function = pf;