]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 22 Aug 2011 15:37:53 +0000 (15:37 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 22 Aug 2011 15:37:53 +0000 (15:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@24166 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/p4est_3d_refine_04.cc [new file with mode: 0644]
tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic [new file with mode: 0644]
tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic [new file with mode: 0644]
tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic [new file with mode: 0644]
tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/p4est_3d_refine_04.cc b/tests/mpi/p4est_3d_refine_04.cc
new file mode 100644 (file)
index 0000000..e5e63c1
--- /dev/null
@@ -0,0 +1,146 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009, 2010, 2011 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.
+//
+//---------------------------------------------------------------------------
+
+
+// create a relatively simple 3d mesh and refine a few cells. this
+// should produce the same output regardless of the number of
+// processors
+//
+// this test is extracted from step-32 while searching for some
+// apparently rather subtle and indeed pretty frustrating bug...
+
+#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/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/base/utilities.h>
+
+#include <fstream>
+#include <ostream>
+
+
+template<int dim>
+void test()
+{
+  unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
+
+  if (true)
+    {
+      parallel::distributed::Triangulation<dim>
+       triangulation(MPI_COMM_WORLD);
+
+                                      // create a mesh for the
+                                      // hypershell and refine it
+                                      // twice globally
+      const double R0 = 6371000.-2890000.;
+      const double R1 = 6371000.-  35000.;
+      GridGenerator::hyper_shell (triangulation,
+                                 Point<dim>(),
+                                 R0,
+                                 R1,
+                                 (dim==3) ? 96 : 12,
+                                 true);
+      triangulation.refine_global (2);
+
+                                      // then flag all cells for
+                                      // refinement that are close to
+                                      // the north pole
+      unsigned int x_flagged_cells = 0;
+      for (typename Triangulation<dim>::active_cell_iterator
+            cell = triangulation.begin_active();
+          cell != triangulation.end(); ++cell)
+       if (!cell->is_ghost() && !cell->is_artificial())
+         if (cell->center()[2] > R1*0.75)
+           {
+             ++x_flagged_cells;
+             cell->set_refine_flag();
+           }
+
+                                      // count how many cells
+                                      // actually have the refinement
+                                      // flag after preparing for
+                                      // refinement, and ensure that
+                                      // this number is still the
+                                      // same as before
+      triangulation.prepare_coarsening_and_refinement ();
+      {
+       unsigned int n_flagged_cells = 0;
+       for (typename Triangulation<dim>::active_cell_iterator
+              cell = triangulation.begin_active();
+            cell != triangulation.end(); ++cell)
+         if (!cell->is_ghost() && !cell->is_artificial())
+           if (cell->refine_flag_set())
+             ++n_flagged_cells;
+
+       Assert (n_flagged_cells == x_flagged_cells,
+               ExcInternalError());
+
+       unsigned int global_f_c = 0;
+       MPI_Allreduce (&n_flagged_cells, &global_f_c, 1, MPI_UNSIGNED,
+                      MPI_SUM, MPI_COMM_WORLD);
+
+       if (myid == 0)
+         deallog << "# flagged cells = " << global_f_c << std::endl;
+      }
+
+      triangulation.execute_coarsening_and_refinement ();
+
+      if (myid == 0)
+       deallog << "#cells = " << triangulation.n_global_active_cells()
+               << std::endl;
+    }
+
+  if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0)
+    deallog << "OK" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+  MPI_Init (&argc,&argv);
+#else
+  (void)argc;
+  (void)argv;
+#endif
+
+  unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
+
+
+  deallog.push(Utilities::int_to_string(myid));
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("p4est_3d_refine_04").c_str());
+      deallog.attach(logfile);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      deallog.push("3d");
+      test<3>();
+      deallog.pop();
+    }
+  else
+    test<3>();
+
+
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+  MPI_Finalize();
+#endif
+}
diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..855fb18
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL:0:3d::# flagged cells = 120
+DEAL:0:3d::#cells = 6984
+DEAL:0:3d::OK
diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..855fb18
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL:0:3d::# flagged cells = 120
+DEAL:0:3d::#cells = 6984
+DEAL:0:3d::OK
diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_24/cmp/generic
new file mode 100644 (file)
index 0000000..855fb18
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL:0:3d::# flagged cells = 120
+DEAL:0:3d::#cells = 6984
+DEAL:0:3d::OK
diff --git a/tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic b/tests/mpi/p4est_3d_refine_04/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..855fb18
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL:0:3d::# flagged cells = 120
+DEAL:0:3d::#cells = 6984
+DEAL:0:3d::OK

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.