From: Sebastian Stark Date: Tue, 8 Oct 2019 11:53:47 +0000 (+0200) Subject: Fix a bug in merge triangulations() X-Git-Tag: v9.2.0-rc1~990^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de582145eb28dbd728a226cb80e185def874cae6;p=dealii.git Fix a bug in merge triangulations() This patch makes sure that merge_triangulations() does not forget about where the boundary is (the problem has actually been in create_triangulation(), which assigned numbers::internal_face_boundary_id to boundary_faces) --- diff --git a/doc/news/changes/minor/20191008SebastianStark b/doc/news/changes/minor/20191008SebastianStark new file mode 100644 index 0000000000..426975d3c6 --- /dev/null +++ b/doc/news/changes/minor/20191008SebastianStark @@ -0,0 +1,6 @@ +Fixed: Make sure that merge_triangulations() does +not forget about where the boundary is (the problem has +actually been in create_triangulation(), which assigned +numbers::internal_face_boundary_id to boundary faces) +
+(Sebastian Stark, 2019/10/08) diff --git a/source/grid/tria.cc b/source/grid/tria.cc index da64da1b3a..09b6b586aa 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -3166,8 +3166,11 @@ namespace internal ExcInconsistentLineInfoOfLine(line_vertices.first, line_vertices.second, "boundary ids")); - - line->set_boundary_id_internal(subcell_line.boundary_id); + // do not use the boundary id provided in subcell_line + // if it is an internal one + if (subcell_line.boundary_id != + numbers::internal_face_boundary_id) + line->set_boundary_id_internal(subcell_line.boundary_id); } // Set manifold id if given AssertThrow(line->manifold_id() == numbers::flat_manifold_id || @@ -3317,8 +3320,11 @@ namespace internal line[2]->index(), line[3]->index(), "boundary ids")); - - quad->set_boundary_id_internal(subcell_quad.boundary_id); + // do not use the boundary id provided in subcell_quad + // if it is an invalid or internal one + if (subcell_quad.boundary_id != + numbers::internal_face_boundary_id) + quad->set_boundary_id_internal(subcell_quad.boundary_id); } // Set manifold id if given if (quad->manifold_id() != numbers::flat_manifold_id) diff --git a/tests/grid/merge_triangulations_07.cc b/tests/grid/merge_triangulations_07.cc new file mode 100644 index 0000000000..03fb15cc33 --- /dev/null +++ b/tests/grid/merge_triangulations_07.cc @@ -0,0 +1,61 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 - 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +// Test for a patch which makes sure that merge_triangulations() does +// not forget about where the boundary is (the problem has +// actually been in create_triangulation(), which assigned +// numbers::internal_face_boundary_id to boundary faces) + +#include +#include + +#include "../tests.h" + +using namespace dealii; + +int +main() +{ + initlog(); + + const unsigned int spacedim = 3; + + Triangulation tria_0, tria_1, tria_2; + + GridGenerator::hyper_cube(tria_0); + GridGenerator::hyper_cube(tria_1); + Tensor<1, spacedim> shift; + shift[0] = 1.0; + GridTools::shift(shift, tria_1); + + tria_0.set_all_manifold_ids(0); + tria_1.set_all_manifold_ids(0); + GridGenerator::merge_triangulations(tria_0, tria_1, tria_2, 1e-12, true); + + unsigned int boundary_face_count = 0; + for (const auto &cell : tria_2.active_cell_iterators()) + for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) + if (cell->face(f)->at_boundary()) + ++boundary_face_count; + + if (boundary_face_count != 10) + deallog << "Found " << boundary_face_count + << " boundary faces. However, there should be 10 of them!" + << std::endl; + else + deallog << "OK!" << std::endl; +} diff --git a/tests/grid/merge_triangulations_07.output b/tests/grid/merge_triangulations_07.output new file mode 100644 index 0000000000..5cfb783b8f --- /dev/null +++ b/tests/grid/merge_triangulations_07.output @@ -0,0 +1,2 @@ + +DEAL::OK!