From: heister Date: Thu, 1 Nov 2012 18:57:32 +0000 (+0000) Subject: add test showing bug in NumberCache after clear() X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1619d5a2b33e48b090d70c60cb531ddc13a6914;p=dealii-svn.git add test showing bug in NumberCache after clear() git-svn-id: https://svn.dealii.org/trunk@27290 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/deal.II/dof_handler_number_cache_02.cc b/tests/deal.II/dof_handler_number_cache_02.cc new file mode 100644 index 0000000000..6826a027a1 --- /dev/null +++ b/tests/deal.II/dof_handler_number_cache_02.cc @@ -0,0 +1,128 @@ +//--------------------------------------------------------------------------- +// $Id: dof_handler_number_cache.cc 24924 2012-01-25 12:35:17Z kormann $ +// Version: $Name$ +// +// Copyright (C) 2008, 2010 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. +// +//--------------------------------------------------------------------------- + + +// Check that DoFHandler::clear() clears the numbercache (a bug right now) + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + FESystem fe (FE_Q(3),2, + FE_DGQ(1),1); + + DoFHandler dof_handler (triangulation); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (2); + + const unsigned int n_refinements[] = { 0, 4, 3, 2 }; + for (unsigned int i=0; i flags (triangulation.n_active_cells(), false); + for (unsigned int k=0; k::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + if (flags[index]) + cell->set_refine_flag(); + Assert (index == triangulation.n_active_cells(), ExcInternalError()); + + // flag all other cells for coarsening + // (this should ensure that at least + // some of them will actually be + // coarsened) + index=0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + if (!flags[index]) + cell->set_coarsen_flag(); + + triangulation.execute_coarsening_and_refinement (); + dof_handler.distribute_dofs (fe); + + const unsigned int N = dof_handler.n_dofs(); + deallog << N << std::endl; + + IndexSet all (N); + all.add_range (0, N); + + Assert (dof_handler.n_locally_owned_dofs() == N, + ExcInternalError()); + Assert (dof_handler.locally_owned_dofs() == all, + ExcInternalError()); + Assert (dof_handler.n_locally_owned_dofs_per_processor() == + std::vector (1,N), + ExcInternalError()); + Assert (dof_handler.locally_owned_dofs_per_processor() == + std::vector(1,all), + ExcInternalError()); + + dof_handler.clear(); + deallog << "those should be zero: " + << dof_handler.n_locally_owned_dofs() + << " " << dof_handler.n_locally_owned_dofs_per_processor().size() + << " " << dof_handler.n_dofs() + << std::endl; + } +} + + +int main() +{ + std::ofstream logfile(JobIdentifier::base_name(__FILE__)+"/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("1d"); + test<1>(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/deal.II/dof_handler_number_cache_02/cmp/generic b/tests/deal.II/dof_handler_number_cache_02/cmp/generic new file mode 100644 index 0000000000..789cd00565 --- /dev/null +++ b/tests/deal.II/dof_handler_number_cache_02/cmp/generic @@ -0,0 +1,10 @@ + +DEAL:1d::50 +DEAL:1d::82 +DEAL:1d::90 +DEAL:1d::90 +DEAL:2d::816 +DEAL:2d::1264 +DEAL:2d::2192 +DEAL:3d::13524 +DEAL:3d::42768