From: bangerth Date: Mon, 20 Feb 2012 11:38:53 +0000 (+0000) Subject: Fix an omission in parallel::distributed::Triangulation::clear. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=517eec7d6487eeb8207be2a50c5e4ec75da3af7a;p=dealii-svn.git Fix an omission in parallel::distributed::Triangulation::clear. git-svn-id: https://svn.dealii.org/trunk@25123 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index f482318c6c..fe741c7f9f 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -118,7 +118,15 @@ enabled due to a missing include file in file

Specific improvements

    -
  1. Improved: FEFieldFunction allows now for the computation of laplacians. +
  2. Fixed: parallel::distributed::Triangulation::clear() forgot +to update the number cache of this class, leading to wrong results +when calling functions like +parallel::distributed::Triangulation::n_global_active_cells(); +
    +(Wolfgang Bangerth, 2012/02/20) + +
      +
    1. Improved: FEFieldFunction allows now for the computation of Laplacians.
      (Christian Goll, 2012/02/16) diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index af2c4bc818..fcf56b7d5b 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -1919,6 +1919,8 @@ namespace parallel p4est_tree_to_coarse_cell_permutation.resize (0); dealii::Triangulation::clear (); + + update_number_cache (); } @@ -2793,11 +2795,12 @@ namespace parallel number_cache.n_locally_owned_active_cells.end(), 0); - for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - if (cell->subdomain_id() == my_subdomain) - ++number_cache.n_locally_owned_active_cells[my_subdomain]; + if (this->n_levels() > 0) + for (typename Triangulation::active_cell_iterator + cell = this->begin_active(); + cell != this->end(); ++cell) + if (cell->subdomain_id() == my_subdomain) + ++number_cache.n_locally_owned_active_cells[my_subdomain]; unsigned int send_value = number_cache.n_locally_owned_active_cells[my_subdomain]; diff --git a/tests/distributed_grids/update_number_cache_01.cc b/tests/distributed_grids/update_number_cache_01.cc new file mode 100644 index 0000000000..093376203b --- /dev/null +++ b/tests/distributed_grids/update_number_cache_01.cc @@ -0,0 +1,68 @@ +//--------------------------------------------------------------------------- +// $Id: 2d_coarsening_01.cc 23710 2011-05-17 04:50:10Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 2008, 2009, 2012 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. +// +//--------------------------------------------------------------------------- + + +// parallel::distributed::Triangulation::clear forgot to +// update the number cache. check that this is fixed now. + +#include "../tests.h" +#include "coarse_grid_common.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void test() +{ + parallel::distributed::Triangulation tr (MPI_COMM_WORLD); + + GridGenerator::hyper_cube(tr); + tr.refine_global(1); + deallog << tr.n_global_active_cells() << std::endl; + + tr.clear (); + deallog << tr.n_global_active_cells() << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Init (&argc,&argv); +#else + (void)argc; + (void)argv; +#endif + + std::ofstream logfile("update_number_cache_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + MPI_Finalize(); +#endif +} diff --git a/tests/distributed_grids/update_number_cache_01/cmp/generic b/tests/distributed_grids/update_number_cache_01/cmp/generic new file mode 100644 index 0000000000..c637b08637 --- /dev/null +++ b/tests/distributed_grids/update_number_cache_01/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:2d::4 +DEAL:2d::0