]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Call reorder_cells() in merge_triangulations(), though this does not help for the...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Apr 2014 19:28:01 +0000 (19:28 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Apr 2014 19:28:01 +0000 (19:28 +0000)
git-svn-id: https://svn.dealii.org/trunk@32727 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/grid/grid_generator.cc
tests/fail/merge_triangulations_02.cc [new file with mode: 0644]
tests/fail/merge_triangulations_02.output [new file with mode: 0644]

index 479e84ac1b3cf1f555b6572f16c9bb8696d3cbf4..2a466932c88e30338c4326bbeda93283ba470e0d 100644 (file)
@@ -3421,13 +3421,14 @@ namespace GridGenerator
         cells.push_back (this_cell);
       }
 
-    // throw out duplicated vertices from the two meshes
-    // and create the triangulation
+    // throw out duplicated vertices from the two meshes, reorder vertices as
+    // necessary and create the triangulation
     SubCellData subcell_data;
     std::vector<unsigned int> considered_vertices;
     GridTools::delete_duplicated_vertices (vertices, cells,
                                           subcell_data,
                                           considered_vertices);
+    GridReordering<dim,spacedim>::reorder_cells (cells);
 
     result.clear ();
     result.create_triangulation (vertices, cells, subcell_data);
diff --git a/tests/fail/merge_triangulations_02.cc b/tests/fail/merge_triangulations_02.cc
new file mode 100644 (file)
index 0000000..0dc6530
--- /dev/null
@@ -0,0 +1,115 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// GridGenerator::merge_triangulation did not call
+// GridReordering::reorder_cells, but even then it may sometimes fail.
+//
+// testcase by Carlos Galeano
+
+#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("output");
+
+template<int dim>
+void mesh_info(const Triangulation<dim> &tria)
+{
+  deallog << "Mesh info:" << std::endl
+         << " dimension: " << dim << std::endl
+         << " no. of cells: " << tria.n_active_cells() << std::endl;
+
+  // Next loop over all faces of all cells and find how often each boundary
+  // indicator is used:
+  {
+    std::map<unsigned int, unsigned int> boundary_count;
+    typename Triangulation<dim>::active_cell_iterator
+      cell = tria.begin_active(),
+      endc = tria.end();
+    for (; cell!=endc; ++cell)
+      {
+        for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+          {
+            if (cell->face(face)->at_boundary())
+              boundary_count[cell->face(face)->boundary_indicator()]++;
+          }
+      }
+
+    deallog << " boundary indicators: ";
+    for (std::map<unsigned int, unsigned int>::iterator it=boundary_count.begin();
+         it!=boundary_count.end();
+         ++it)
+      {
+        deallog << it->first << "(" << it->second << " times) ";
+      }
+    deallog << std::endl;
+  }
+
+  // Finally, produce a graphical representation of the mesh to an output
+  // file:
+  GridOut grid_out;
+  grid_out.write_gnuplot (tria, deallog.get_file_stream());
+}
+
+
+void make_grid ()
+{
+  Triangulation<2> tria1;
+  GridGenerator::hyper_cube_with_cylindrical_hole (tria1, 0.25, 1.0);
+  
+  Triangulation<2> tria3;
+  GridGenerator::hyper_cube_with_cylindrical_hole (tria3, 0.25, 1.0);
+  GridTools::shift (Point<2>(0,-2), tria3);
+  Triangulation<2> triangulation2;
+
+  mesh_info (tria1);
+  mesh_info (tria3);
+  GridGenerator::merge_triangulations (tria1, tria3, triangulation2);
+
+  mesh_info(triangulation2);
+  deallog << "Number of active cells: "
+         << triangulation2.n_active_cells()
+         << std::endl;
+  deallog << "Total number of cells: "
+         << triangulation2.n_cells()
+         << 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);
+
+  make_grid();
+}
diff --git a/tests/fail/merge_triangulations_02.output b/tests/fail/merge_triangulations_02.output
new file mode 100644 (file)
index 0000000..d871c6b
--- /dev/null
@@ -0,0 +1,121 @@
+JobId linux-sh2g.site Mon Apr  7 13:28:47 2014
+DEAL::Mesh info:
+DEAL:: dimension: 2
+DEAL:: no. of cells: 8
+DEAL:: boundary indicators: 0(8 times) 1(8 times) 
+1.0 0.0 0 0
+1.0 1.0 0 0
+0.18 0.18 0 0
+0.25 0.0 0 0
+1.0 0.0 0 0
+
+
+1.0 1.0 0 0
+6.1e-17 1.0 0 0
+1.5e-17 0.25 0 0
+0.18 0.18 0 0
+1.0 1.0 0 0
+
+
+6.1e-17 1.0 0 0
+-1.0 1.0 0 0
+-0.18 0.18 0 0
+1.5e-17 0.25 0 0
+6.1e-17 1.0 0 0
+
+
+-1.0 1.0 0 0
+-1.0 1.2e-16 0 0
+-0.25 3.1e-17 0 0
+-0.18 0.18 0 0
+-1.0 1.0 0 0
+
+
+-1.0 1.2e-16 0 0
+-1.0 -1.0 0 0
+-0.18 -0.18 0 0
+-0.25 3.1e-17 0 0
+-1.0 1.2e-16 0 0
+
+
+-1.0 -1.0 0 0
+-1.8e-16 -1.0 0 0
+-4.6e-17 -0.25 0 0
+-0.18 -0.18 0 0
+-1.0 -1.0 0 0
+
+
+-1.8e-16 -1.0 0 0
+1.0 -1.0 0 0
+0.18 -0.18 0 0
+-4.6e-17 -0.25 0 0
+-1.8e-16 -1.0 0 0
+
+
+1.0 -1.0 0 0
+1.0 0.0 0 0
+0.25 0.0 0 0
+0.18 -0.18 0 0
+1.0 -1.0 0 0
+
+
+DEAL::Mesh info:
+DEAL:: dimension: 2
+DEAL:: no. of cells: 8
+DEAL:: boundary indicators: 0(8 times) 1(8 times) 
+1.0 -2.0 0 0
+1.0 -1.0 0 0
+0.18 -1.8 0 0
+0.25 -2.0 0 0
+1.0 -2.0 0 0
+
+
+1.0 -1.0 0 0
+6.1e-17 -1.0 0 0
+1.5e-17 -1.8 0 0
+0.18 -1.8 0 0
+1.0 -1.0 0 0
+
+
+6.1e-17 -1.0 0 0
+-1.0 -1.0 0 0
+-0.18 -1.8 0 0
+1.5e-17 -1.8 0 0
+6.1e-17 -1.0 0 0
+
+
+-1.0 -1.0 0 0
+-1.0 -2.0 0 0
+-0.25 -2.0 0 0
+-0.18 -1.8 0 0
+-1.0 -1.0 0 0
+
+
+-1.0 -2.0 0 0
+-1.0 -3.0 0 0
+-0.18 -2.2 0 0
+-0.25 -2.0 0 0
+-1.0 -2.0 0 0
+
+
+-1.0 -3.0 0 0
+-1.8e-16 -3.0 0 0
+-4.6e-17 -2.2 0 0
+-0.18 -2.2 0 0
+-1.0 -3.0 0 0
+
+
+-1.8e-16 -3.0 0 0
+1.0 -3.0 0 0
+0.18 -2.2 0 0
+-4.6e-17 -2.2 0 0
+-1.8e-16 -3.0 0 0
+
+
+1.0 -3.0 0 0
+1.0 -2.0 0 0
+0.25 -2.0 0 0
+0.18 -2.2 0 0
+1.0 -3.0 0 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.