From edce112ef2b6a4172f49ad90993fbbd94e0493a5 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 29 Jun 2013 02:19:30 +0000 Subject: [PATCH] Add test. git-svn-id: https://svn.dealii.org/trunk@29902 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/work_stream_03.cc | 157 ++++++++++++++++++++++++++ tests/base/work_stream_03/cmp/generic | 2 + 2 files changed, 159 insertions(+) create mode 100644 tests/base/work_stream_03.cc create mode 100644 tests/base/work_stream_03/cmp/generic diff --git a/tests/base/work_stream_03.cc b/tests/base/work_stream_03.cc new file mode 100644 index 0000000000..0493581e31 --- /dev/null +++ b/tests/base/work_stream_03.cc @@ -0,0 +1,157 @@ +//---------------------------- work_stream_03.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2013 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- work_stream_03.cc --------------------------- + + +// Moritz originally implemented thread local scratch objects for +// WorkStream in r24748 but it led to failures in the testsuite. what +// exactly went on was a mystery and this test is a first step in +// figuring out what happens by running a simplified version of one of +// the failing tests (deal.II/project_q_01) multiple times and +// verifying that it indeed works + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +char logname[] = "work_stream_03/output"; + + + +template +class F : public Function +{ + public: + F (const unsigned int q) + : + q(q) + {} + + virtual double value (const Point &p, + const unsigned int component) const + { + Assert (component == 0, ExcInternalError()); + double val = 0; + for (unsigned int d=0; d +void do_project (const Triangulation &triangulation, + const unsigned int p) +{ + std::cout << "Start: " << __PRETTY_FUNCTION__ << ' ' << p << std::endl; + FE_Q fe(p); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (fe); + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, + constraints); + constraints.close (); + + Vector projection (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p; ++q) + { + // project the function + VectorTools::project (dof_handler, + constraints, + QGauss(p+2), + F (q), + projection); + // just to make sure it doesn't get + // forgotten: handle hanging node + // constraints + constraints.distribute (projection); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + projection, + F (q), + error, + QGauss(std::max(p,q)+1), + VectorTools::L2_norm); + Assert (error.l2_norm() <= 1e-12*projection.l2_norm(), + ExcInternalError()); + } + std::cout << "Done: " << __PRETTY_FUNCTION__ << ' ' << p << std::endl; +} + + + + +template +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (3); + + Threads::TaskGroup<> g; + for (unsigned int p=1; p<4; ++p) + g += Threads::new_task (&do_project, triangulation, p); + g.join_all (); +} + + +int main () +{ + std::ofstream logfile(logname); + deallog << std::setprecision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); + + deallog << "OK" << std::endl; +} + diff --git a/tests/base/work_stream_03/cmp/generic b/tests/base/work_stream_03/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/base/work_stream_03/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5