From: Jonathan Perry-Houts Date: Mon, 2 Nov 2015 21:14:44 +0000 (-0800) Subject: Added muparser erfc test. X-Git-Tag: v8.4.0-rc2~255^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81f4f5147ab10470b42d8ad305c009a93a6fb686;p=dealii.git Added muparser erfc test. --- diff --git a/tests/base/function_parser_08.cc b/tests/base/function_parser_08.cc new file mode 100644 index 0000000000..93649e9335 --- /dev/null +++ b/tests/base/function_parser_08.cc @@ -0,0 +1,87 @@ +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +// simple function parser test for erfc functionality. + +void test1() +{ + // set up problem: + std::string variables = "x,y"; + std::string expression = "erfc(x)+erfc(y)"; + std::map constants; + + // FunctionParser with 2 variables and 1 component: + FunctionParser<2> fp(1); + fp.initialize(variables, + expression, + constants); + + // Point at which we want to evaluate the function + Point<2> point(0.1, -0.7); + + // evaluate the expression at 'point': + double result = fp.value(point); + + deallog << "Function '" << expression << "'" + << " @ " << point + << " is " << result << std::endl; +} + + +void test2() +{ + // Define some constants that will be used by the function parser + std::map constants; + constants["pi"] = numbers::PI; + + // Define the variables that will be used inside the expressions + std::string variables = "x,y,z"; + + // Define the expressions of the individual components of a + // vector valued function with two components: + std::vector expressions(2); + expressions[0] = "erfc(pi*z)"; + expressions[1] = "sin(2*pi*y)*erfc(x^2)"; + + // function parser with 3 variables and 2 components + FunctionParser<3> vector_function(2); + + // And populate it with the newly created objects. + vector_function.initialize(variables, + expressions, + constants); + + // Point at which we want to evaluate the function + Point<3> point(0.0, 1.0, 1.0); + + // This Vector will store the result + Vector result(2); + + // Fill 'result' by evaluating the function + vector_function.vector_value(point, result); + + // We can also only evaluate the 2nd component: + double c = vector_function.value(point, 1); + + Assert(c == result[1], ExcInternalError()); + + // Output the evaluated function + deallog << "Function '" << expressions[0] << "," << expressions[1] << "'" + << " @ " << point + << " is " << result << std::endl; +} + + +int main() +{ + initlog(); + + test1(); + test2(); +} diff --git a/tests/base/function_parser_08.with_muparser=true.output b/tests/base/function_parser_08.with_muparser=true.output new file mode 100644 index 0000000000..820b125fd2 --- /dev/null +++ b/tests/base/function_parser_08.with_muparser=true.output @@ -0,0 +1,4 @@ + +DEAL::Function 'erfc(x)+erfc(y)' @ 0.100000 -0.700000 is 2.56534 +DEAL::Function 'erfc(pi*z),sin(2*pi*y)*erfc(x^2)' @ 0.00000 1.00000 1.00000 is 8.87615e-06 -2.44929e-16 +DEAL::