From: Timo Heister Date: Wed, 30 Sep 2015 17:39:35 +0000 (-0400) Subject: add support for pow(a,b) in FunctionParser X-Git-Tag: v8.4.0-rc2~356^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1695%2Fhead;p=dealii.git add support for pow(a,b) in FunctionParser it turns out muparser only supports "a^b" out of the box, so we add "pow(a,b)" as a custom function. --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 4763589e90..3ad05671c4 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -159,6 +159,11 @@ inconvenience this causes.

General

    +
  1. New: FunctionParser now supports pow(a,b). +
    + (Timo Heister, 2015/09/30) +
  2. +
  3. New: MGTransferPrebuilt can now be used with parallel::distributed::Vector and TrilinosWrappers::SparseMatrix as a transfer matrix.
    diff --git a/source/base/function_parser.cc b/source/base/function_parser.cc index 61aef60acf..25ffd17e81 100644 --- a/source/base/function_parser.cc +++ b/source/base/function_parser.cc @@ -165,6 +165,11 @@ namespace internal { return log(value); } + + double mu_pow(double a, double b) + { + return std::pow(a, b); + } } @@ -202,6 +207,7 @@ void FunctionParser:: init_muparser() const fp.get()[component].DefineFun("floor", internal::mu_floor, true); fp.get()[component].DefineFun("sec", internal::mu_sec, true); fp.get()[component].DefineFun("log", internal::mu_log, true); + fp.get()[component].DefineFun("pow", internal::mu_pow, true); try { @@ -250,7 +256,8 @@ void FunctionParser:: init_muparser() const "cot", "csc", "floor", - "sec" + "sec", + "pow" }; for (unsigned int f=0; f(0,0), sqrt(0.5)); eval("tan(0.5)",Point<2>(0,0), tan(0.5)); eval("tanh(0.5)",Point<2>(0,0), tanh(0.5)); + eval("pow (9.0, 0.5)",Point<2>(0,0), 3.0); } diff --git a/tests/base/function_parser_06.with_muparser=true.output b/tests/base/function_parser_06.with_muparser=true.output index 2ec9e6652b..41caadd752 100644 --- a/tests/base/function_parser_06.with_muparser=true.output +++ b/tests/base/function_parser_06.with_muparser=true.output @@ -35,3 +35,4 @@ DEAL::'sinh(0.5)' @ 0.00000 0.00000 is 0.521095 ( expected 0.521095 ) DEAL::'sqrt(0.5)' @ 0.00000 0.00000 is 0.707107 ( expected 0.707107 ) DEAL::'tan(0.5)' @ 0.00000 0.00000 is 0.546302 ( expected 0.546302 ) DEAL::'tanh(0.5)' @ 0.00000 0.00000 is 0.462117 ( expected 0.462117 ) +DEAL::'pow (9.0, 0.5)' @ 0.00000 0.00000 is 3.00000 ( expected 3.00000 )