]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Patch by Martin Steigemann: implement parallel::distributed::Triangulation::copy_tria...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Jul 2013 15:29:20 +0000 (15:29 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 2 Jul 2013 15:29:20 +0000 (15:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@29910 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/tria_copy_triangulation.cc [new file with mode: 0644]
tests/mpi/tria_copy_triangulation/ncpu_1/cmp/generic [new file with mode: 0644]
tests/mpi/tria_copy_triangulation/ncpu_2/cmp/generic [new file with mode: 0644]
tests/mpi/tria_copy_triangulation/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/tria_copy_triangulation.cc b/tests/mpi/tria_copy_triangulation.cc
new file mode 100644 (file)
index 0000000..49aff9d
--- /dev/null
@@ -0,0 +1,140 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2008, 2009 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.
+//
+//---------------------------------------------------------------------------
+
+
+// Test interaction with p4est with a simple grid in 2d. here, we test
+// that refining a mesh actually works, where we refine several times
+// more or less randomly by choosing a single cell for refinement
+
+// in addition to just refining, have a parallel triangulation that should
+// look the same but isn't attached to a distribution manager, and compare
+// with it in each step
+
+// note that due to the way we set up triangulations in parallel, we
+// can't expect that cells on the two meshes have the same numbers (or
+// are in the same order, for that matter). we therefore use an
+// IntergridMap. there should be matching cells, however
+
+// note that p4est refines meshes in a way that is equivalent to
+// specifying Triangulation<dim>::limit_level_difference_at_vertices,
+// so this is what we also give as argument to the mesh with which we
+// compare
+
+#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 <fstream>
+#include <cstdlib>
+
+
+template<int dim>
+void test()
+{
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD);
+
+  GridGenerator::subdivided_hyper_cube(tr, 6-dim);
+
+  parallel::distributed::Triangulation<dim> new_tr(MPI_COMM_WORLD);
+
+  new_tr.copy_triangulation (tr);
+
+  typename Triangulation<dim,dim>::active_cell_iterator cell1, cell2;
+
+  for (cell1 = tr.begin_active(), cell2 = new_tr.begin_active();
+       cell1 != tr.end(), cell2 != new_tr.end();
+       ++cell1, ++cell2)
+    {
+      if (cell1->is_locally_owned ())
+        {
+          if (myid == 0)
+            {
+              deallog << "triangulation::cell     " << cell1 << ": locally owned, subdomain_id = " << cell1->subdomain_id () << std::endl;
+              deallog << "new_triangulation::cell " << cell2 << ": locally owned, subdomain_id = " << cell2->subdomain_id () << std::endl;
+            };
+
+          Assert (cell2->is_locally_owned (), ExcInternalError());
+          Assert (cell1->subdomain_id () == cell2->subdomain_id (), ExcInternalError());
+
+          for (unsigned int vertex=0;
+               vertex<GeometryInfo<dim>::vertices_per_cell;
+               ++vertex)
+            {
+              Assert (cell1->vertex(vertex).distance (cell2->vertex(vertex)) < 1.e-14, ExcInternalError());
+
+              if (myid == 0)
+                deallog << "  vertices " << vertex << " coincide" << std::endl;
+            };
+        }
+      else if (cell1->is_ghost())
+        {
+          if (myid == 0)
+            {
+              deallog << "triangulation::cell     " << cell1 << ": ghost, subdomain_id = " << cell1->subdomain_id () << std::endl;
+              deallog << "new_triangulation::cell " << cell2 << ": ghost, subdomain_id = " << cell2->subdomain_id () << std::endl;
+            };
+
+          Assert (cell2->is_ghost (), ExcInternalError());
+        }
+      else if (cell1->is_artificial())
+        {
+          if (myid == 0)
+            {
+              deallog << "triangulation::cell     " << cell1 << ": artificial" << std::endl;
+              deallog << "new_triangulation::cell " << cell2 << ": artificial" << std::endl;
+            };
+
+          Assert (cell2->is_artificial (), ExcInternalError());
+        }
+      else
+        Assert (false, ExcInternalError());
+    };
+
+//   assert_tria_equal("tria_copy_triangulation", tr, new_tr);
+
+  Assert (tr.n_active_cells() == new_tr.n_active_cells(), ExcInternalError());
+  Assert (tr.n_levels() == new_tr.n_levels(), ExcInternalError());
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+  deallog.push(Utilities::int_to_string(myid));
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("tria_copy_triangulation").c_str());
+      deallog.attach(logfile);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      deallog.push("2d");
+      test<2>();
+      deallog.pop();
+    }
+  else
+    test<2>();
+
+}
diff --git a/tests/mpi/tria_copy_triangulation/ncpu_1/cmp/generic b/tests/mpi/tria_copy_triangulation/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..92494a7
--- /dev/null
@@ -0,0 +1,97 @@
+
+DEAL:0:2d::triangulation::cell     0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.3: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.3: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.5: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.5: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.6: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.6: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.7: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.7: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.8: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.8: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.9: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.9: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.10: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.10: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.11: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.11: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.12: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.12: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.13: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.13: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.14: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.14: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.15: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.15: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
diff --git a/tests/mpi/tria_copy_triangulation/ncpu_2/cmp/generic b/tests/mpi/tria_copy_triangulation/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..db8a187
--- /dev/null
@@ -0,0 +1,65 @@
+
+DEAL:0:2d::triangulation::cell     0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.3: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.3: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.5: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.5: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.6: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.6: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.7: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.7: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.8: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.8: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.9: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.9: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.10: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.10: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.11: artificial
+DEAL:0:2d::new_triangulation::cell 0.11: artificial
+DEAL:0:2d::triangulation::cell     0.12: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.12: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.13: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.13: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.14: artificial
+DEAL:0:2d::new_triangulation::cell 0.14: artificial
+DEAL:0:2d::triangulation::cell     0.15: artificial
+DEAL:0:2d::new_triangulation::cell 0.15: artificial
diff --git a/tests/mpi/tria_copy_triangulation/ncpu_4/cmp/generic b/tests/mpi/tria_copy_triangulation/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..398dcc4
--- /dev/null
@@ -0,0 +1,49 @@
+
+DEAL:0:2d::triangulation::cell     0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.0: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.1: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.2: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.3: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.3: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::new_triangulation::cell 0.4: locally owned, subdomain_id = 0
+DEAL:0:2d::  vertices 0 coincide
+DEAL:0:2d::  vertices 1 coincide
+DEAL:0:2d::  vertices 2 coincide
+DEAL:0:2d::  vertices 3 coincide
+DEAL:0:2d::triangulation::cell     0.5: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.5: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.6: ghost, subdomain_id = 2
+DEAL:0:2d::new_triangulation::cell 0.6: ghost, subdomain_id = 2
+DEAL:0:2d::triangulation::cell     0.7: ghost, subdomain_id = 2
+DEAL:0:2d::new_triangulation::cell 0.7: ghost, subdomain_id = 2
+DEAL:0:2d::triangulation::cell     0.8: ghost, subdomain_id = 1
+DEAL:0:2d::new_triangulation::cell 0.8: ghost, subdomain_id = 1
+DEAL:0:2d::triangulation::cell     0.9: ghost, subdomain_id = 2
+DEAL:0:2d::new_triangulation::cell 0.9: ghost, subdomain_id = 2
+DEAL:0:2d::triangulation::cell     0.10: artificial
+DEAL:0:2d::new_triangulation::cell 0.10: artificial
+DEAL:0:2d::triangulation::cell     0.11: artificial
+DEAL:0:2d::new_triangulation::cell 0.11: artificial
+DEAL:0:2d::triangulation::cell     0.12: artificial
+DEAL:0:2d::new_triangulation::cell 0.12: artificial
+DEAL:0:2d::triangulation::cell     0.13: artificial
+DEAL:0:2d::new_triangulation::cell 0.13: artificial
+DEAL:0:2d::triangulation::cell     0.14: artificial
+DEAL:0:2d::new_triangulation::cell 0.14: artificial
+DEAL:0:2d::triangulation::cell     0.15: artificial
+DEAL:0:2d::new_triangulation::cell 0.15: artificial

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.