From: Peter Munch Date: Fri, 1 Jul 2022 20:38:44 +0000 (+0200) Subject: Be explicit regarding zero tolerance in merge_triangulations X-Git-Tag: v9.5.0-rc1~1120^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14084%2Fhead;p=dealii.git Be explicit regarding zero tolerance in merge_triangulations --- diff --git a/include/deal.II/grid/grid_generator.h b/include/deal.II/grid/grid_generator.h index a0f20e4c7a..d6de5006ab 100644 --- a/include/deal.II/grid/grid_generator.h +++ b/include/deal.II/grid/grid_generator.h @@ -1864,7 +1864,7 @@ namespace GridGenerator * { * double length = std::numeric_limits::max(); * for (const auto &cell : tria.active_cell_iterators()) - * for (unsigned int n = 0; n < GeometryInfo::lines_per_cell; ++n) + * for (const auto n : cell->line_indices()) * length = std::min(length, (cell->line(n)->vertex(0) - * cell->line(n)->vertex(1)).norm()); * return length; @@ -1875,7 +1875,7 @@ namespace GridGenerator * @endcode * * This will merge any vertices that are closer than any pair of vertices on - * the input meshes. + * the input meshes. If the tolerance is set to zero, vertices are not merged. * * @note The two input triangulations must be * @ref GlossCoarseMesh "coarse meshes", diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 4ba5992256..5a0d816229 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -439,7 +439,8 @@ namespace GridTools * vertices. * * Two vertices are considered equal if their difference in each coordinate - * direction is less than @p tol. + * direction is less than @p tol. This implies that nothing happens if + * the tolerance is set to zero. */ template void diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index ebaaae4f0b..41fa3a00f4 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -6544,6 +6544,10 @@ namespace GridGenerator GridTools::consistently_order_cells(cells); result.clear(); result.create_triangulation(vertices, cells, subcell_data); + + Assert(duplicated_vertex_tolerance > 0.0 || + n_accumulated_vertices == result.n_vertices(), + ExcInternalError()); } diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index d8c3279452..f4549dfb95 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -744,6 +744,9 @@ namespace GridTools std::vector & considered_vertices, const double tol) { + if (tol == 0.0) + return; // nothing to do per definition + AssertIndexRange(2, vertices.size()); std::vector new_vertex_numbers(vertices.size()); std::iota(new_vertex_numbers.begin(), new_vertex_numbers.end(), 0);