From 98fd551d15271242db3fa26b21ee0bf3d0908be2 Mon Sep 17 00:00:00 2001 From: heister Date: Thu, 6 Feb 2014 14:51:04 +0000 Subject: [PATCH] add another test for FunctionParser git-svn-id: https://svn.dealii.org/trunk@32418 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/function_parser_03.cc | 59 +++++++++++++++++++ ..._parser_03.with_functionparser=true.output | 1 + 2 files changed, 60 insertions(+) create mode 100644 tests/base/function_parser_03.cc create mode 100644 tests/base/function_parser_03.with_functionparser=true.output diff --git a/tests/base/function_parser_03.cc b/tests/base/function_parser_03.cc new file mode 100644 index 0000000000..7e8250f89d --- /dev/null +++ b/tests/base/function_parser_03.cc @@ -0,0 +1,59 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2005 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// functionparser: check if you can change the expression in an existing object + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + + +int main () +{ + initlog(); + + // 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 = "s,t"; + + FunctionParser<2> fp; + fp.initialize("s,t", "s*t+1", constants); + + double value = fp.value(Point<2>(2.0,2.5)); + Assert(abs(1.0+2.0*2.5 - value) < 1e-10, ExcMessage("wrong value")); + + std::vector expressions; + expressions.push_back("sin(2*mypi*x)+y"); + constants["mypi"] = numbers::PI; + fp.initialize("x,y", expressions, constants); + double value1 = fp.value(Point<2>(1.0,2.5), 0); + Assert(abs(2.5 - value1) < 1e-10, ExcMessage("wrong value")); + +} + + + + diff --git a/tests/base/function_parser_03.with_functionparser=true.output b/tests/base/function_parser_03.with_functionparser=true.output new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/tests/base/function_parser_03.with_functionparser=true.output @@ -0,0 +1 @@ + -- 2.39.5