]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix an omission in parallel::distributed::Triangulation<dim>::clear.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Feb 2012 11:38:53 +0000 (11:38 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 20 Feb 2012 11:38:53 +0000 (11:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@25123 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/distributed/tria.cc
tests/distributed_grids/update_number_cache_01.cc [new file with mode: 0644]
tests/distributed_grids/update_number_cache_01/cmp/generic [new file with mode: 0644]

index f482318c6c28be75eef07e45f69291fba77802b6..fe741c7f9fcec441d8307bb055b78a06e9e1c621 100644 (file)
@@ -118,7 +118,15 @@ enabled due to a missing include file in file
 <h3>Specific improvements</h3>
 
 <ol>
-<li> Improved: FEFieldFunction allows now for the computation of laplacians.
+<li> 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();
+<br>
+(Wolfgang Bangerth, 2012/02/20)
+
+<ol>
+<li> Improved: FEFieldFunction allows now for the computation of Laplacians.
 <br>
 (Christian Goll, 2012/02/16)
 
index af2c4bc818ba22a638d5c411ff410a8bf60eef1f..fcf56b7d5bc413443e901a3d7e7ae341678c7e2b 100644 (file)
@@ -1919,6 +1919,8 @@ namespace parallel
       p4est_tree_to_coarse_cell_permutation.resize (0);
 
       dealii::Triangulation<dim,spacedim>::clear ();
+
+      update_number_cache ();
     }
 
 
@@ -2793,11 +2795,12 @@ namespace parallel
                 number_cache.n_locally_owned_active_cells.end(),
                 0);
 
-      for (typename Triangulation<dim,spacedim>::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<dim,spacedim>::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 (file)
index 0000000..0933762
--- /dev/null
@@ -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<dim>::clear forgot to
+// update the number cache. check that this is fixed now.
+
+#include "../tests.h"
+#include "coarse_grid_common.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+
+#include <fstream>
+
+
+
+template<int dim>
+void test()
+{
+  parallel::distributed::Triangulation<dim> 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 (file)
index 0000000..c637b08
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL:2d::4
+DEAL:2d::0

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.