From: David Wells Date: Sun, 29 Jul 2018 16:25:40 +0000 (-0400) Subject: Refactor the minimal vertex distance in GridGenerator. X-Git-Tag: v9.1.0-rc1~801^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0993626bb6f9bfe2fc2bfe3df9bd00b0182055bc;p=dealii.git Refactor the minimal vertex distance in GridGenerator. This is useful in a few other GridGenerator functions. --- diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 32242fe706..c995c39781 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -1941,6 +1941,23 @@ namespace GridGenerator return (std::abs(p[0] - c[0]) < radius) && (std::abs(p[1] - c[1]) < radius); } + + + + // Find the minimal distance between two vertices. This is useful for + // computing a tolerance for merging vertices in + // GridTools::merge_triangulations. + template + double + minimal_vertex_distance(const Triangulation &triangulation) + { + double length = std::numeric_limits::max(); + for (const auto &cell : triangulation.active_cell_iterators()) + for (unsigned int n = 0; n < GeometryInfo::lines_per_cell; ++n) + length = std::min(length, cell->line(n)->diameter()); + return length; + } + } // namespace internal template <> @@ -4798,14 +4815,6 @@ namespace GridGenerator std::tanh(skewness))); radii.push_back(outer_radius); - auto min_line_length = [](const Triangulation &tria) -> double { - 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) - length = std::min(length, cell->line(n)->diameter()); - return length; - }; - double grid_vertex_tolerance = 0.0; for (unsigned int shell_n = 0; shell_n < radii.size() - 1; ++shell_n) { @@ -4820,7 +4829,8 @@ namespace GridGenerator // The innermost shell has the smallest cells: use that to set the // vertex merging tolerance if (grid_vertex_tolerance == 0.0) - grid_vertex_tolerance = 0.5 * min_line_length(current_shell); + grid_vertex_tolerance = + 0.5 * internal::minimal_vertex_distance(current_shell); Triangulation temp(std::move(triangulation)); triangulation.clear();