From: bangerth Date: Mon, 7 Apr 2014 19:28:01 +0000 (+0000) Subject: Call reorder_cells() in merge_triangulations(), though this does not help for the... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afe9491d06e8a2ff8f780e090d98a127d8ab5d2c;p=dealii-svn.git Call reorder_cells() in merge_triangulations(), though this does not help for the current case. git-svn-id: https://svn.dealii.org/trunk@32727 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/grid/grid_generator.cc b/deal.II/source/grid/grid_generator.cc index 479e84ac1b..2a466932c8 100644 --- a/deal.II/source/grid/grid_generator.cc +++ b/deal.II/source/grid/grid_generator.cc @@ -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 considered_vertices; GridTools::delete_duplicated_vertices (vertices, cells, subcell_data, considered_vertices); + GridReordering::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 index 0000000000..0dc65307b4 --- /dev/null +++ b/tests/fail/merge_triangulations_02.cc @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +std::ofstream logfile("output"); + +template +void mesh_info(const Triangulation &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 boundary_count; + typename Triangulation::active_cell_iterator + cell = tria.begin_active(), + endc = tria.end(); + for (; cell!=endc; ++cell) + { + for (unsigned int face=0; face::faces_per_cell; ++face) + { + if (cell->face(face)->at_boundary()) + boundary_count[cell->face(face)->boundary_indicator()]++; + } + } + + deallog << " boundary indicators: "; + for (std::map::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 index 0000000000..d871c6b8ed --- /dev/null +++ b/tests/fail/merge_triangulations_02.output @@ -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 + +