]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New function GridGenerator::merge_triangulations.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Jun 2011 19:55:32 +0000 (19:55 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Jun 2011 19:55:32 +0000 (19:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@23835 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/merge_triangulations_01.cc [new file with mode: 0644]
tests/deal.II/merge_triangulations_01/cmp/generic [new file with mode: 0644]

diff --git a/tests/deal.II/merge_triangulations_01.cc b/tests/deal.II/merge_triangulations_01.cc
new file mode 100644 (file)
index 0000000..dc8363b
--- /dev/null
@@ -0,0 +1,98 @@
+//----------------------------  merge_triangulations_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2006, 2008, 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.
+//
+//----------------------------  merge_triangulations_01.cc  ---------------------------
+
+
+#include "../tests.h"
+#include <deal.II/grid/tria_boundary.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/base/logstream.h>
+#include <cmath>
+#include <cstdlib>
+
+#include <fstream>
+#include <iomanip>
+#include <cstdio>
+
+std::ofstream logfile("merge_triangulations_01/output");
+
+
+
+// testcase=0:
+// create two cubes; translate them so that no vertices overlap
+//
+// testcase=1:
+// create two cubes; translate them so that a whole face overlaps
+//
+// testcase=2:
+// create two cubes; translate them so that exactly one vertices overlaps
+template <int dim>
+void test (const int testcase)
+{
+  Triangulation<dim> tria_1, tria_2, tria_3;
+  GridGenerator::hyper_cube(tria_1);
+  GridGenerator::hyper_cube(tria_2);
+  Point<dim> shift;
+  switch (testcase)
+    {
+      case 0:
+           shift[0] = 2;
+           break;
+      case 1:
+           shift[0] = 1;
+           break;
+      case 2:
+           for (unsigned int d=0; d<dim; ++d)
+             shift[d] = 1;
+           break;
+      default:
+           Assert (false, ExcNotImplemented());
+    }
+  GridTools::shift (shift, tria_2);
+
+                                  // fill tria_3 with something, to
+                                  // make sure that the function we
+                                  // call later can deal with prior
+                                  // content
+  GridGenerator::hyper_cube(tria_3);
+
+                                  // now merge triangulations
+  GridGenerator::merge_triangulations (tria_1, tria_2, tria_3);
+
+  GridOut().write_gnuplot (tria_3, logfile);
+
+  deallog << "     Total number of cells        = " << tria_3.n_cells() << std::endl
+         << "     Total number of vertices = " << tria_3.n_used_vertices() << std::endl;
+}
+
+
+int main ()
+{
+  deallog << std::setprecision(2);
+  logfile << std::setprecision(2);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  for (unsigned int t=0; t<3; ++t)
+    {
+      test<2> (t);
+      test<3> (t);
+    }
+
+  return 0;
+}
diff --git a/tests/deal.II/merge_triangulations_01/cmp/generic b/tests/deal.II/merge_triangulations_01/cmp/generic
new file mode 100644 (file)
index 0000000..10bee8a
--- /dev/null
@@ -0,0 +1,199 @@
+
+0.0 0.0 0 0
+1.0 0.0 0 0
+1.0 1.0 0 0
+0.0 1.0 0 0
+0.0 0.0 0 0
+
+
+2.0 0.0 0 0
+3.0 0.0 0 0
+3.0 1.0 0 0
+2.0 1.0 0 0
+2.0 0.0 0 0
+
+
+DEAL::     Total number of cells        = 2
+DEAL::     Total number of vertices = 8
+0.0 0.0 0.0 0 0
+1.0 0.0 0.0 0 0
+1.0 0.0 1.0 0 0
+0.0 0.0 1.0 0 0
+0.0 0.0 0.0 0 0
+
+0.0 1.0 0.0 0 0
+1.0 1.0 0.0 0 0
+1.0 1.0 1.0 0 0
+0.0 1.0 1.0 0 0
+0.0 1.0 0.0 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0
+
+2.0 1.0 1.0 0 0
+2.0 2.0 1.0 0 0
+
+2.0 1.0 2.0 0 0
+2.0 2.0 2.0 0 0
+
+1.0 1.0 2.0 0 0
+1.0 2.0 2.0 0 0
+
+DEAL::     Total number of cells        = 2
+DEAL::     Total number of vertices = 15

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.