From: heister Date: Thu, 6 Feb 2014 16:17:55 +0000 (+0000) Subject: add multithreaded function_parser test X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=caa409d455351fe85b4851e23262f8aa8e1ade47;p=dealii-svn.git add multithreaded function_parser test git-svn-id: https://svn.dealii.org/trunk@32420 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/function_parser_04.cc b/tests/base/function_parser_04.cc new file mode 100644 index 0000000000..461522a561 --- /dev/null +++ b/tests/base/function_parser_04.cc @@ -0,0 +1,100 @@ +// --------------------------------------------------------------------- +// $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: TBB + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +FunctionParser<2> fp; + +struct scratch_data +{ +}; + +struct copy_data +{ + int value; + copy_data(): + value(0) + {} + +}; + + +void assemble(const std::vector::iterator &it, + scratch_data &scratch, + copy_data &data) +{ + double s = *it; + double value = fp.value(Point<2>(s, 2.5)); + Assert(abs(1.0+s*2.5 - value) < 1e-10, ExcMessage("wrong value")); + std::cout << data.value << std::endl; + + data.value = (abs(1.0+s*2.5 - value) < 1e-10)?1:0; +} + +void copy(int & value, const copy_data &data) +{ + value += data.value; +} + + +void test2() +{ + std::map constants; + constants["c"]=1.0; + fp.initialize("s,t", "s*t+c", constants); + + std::vector v(10000); + for (unsigned int i=0;i