From: Bruno Date: Sun, 22 Aug 2021 19:16:47 +0000 (-0400) Subject: Add tolerance to subdivided_cylinder generator X-Git-Tag: v9.4.0-rc1~1044^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12697%2Fhead;p=dealii.git Add tolerance to subdivided_cylinder generator --- diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 592a28569c..2b6f268032 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -5602,11 +5602,15 @@ namespace GridGenerator // above tria.set_all_manifold_ids_on_boundary(0); + // Tolerance is calculated using the minimal length defining + // the cylinder + const double tolerance = 1e-5 * std::min(radius, half_length); + for (const auto &cell : tria.cell_iterators()) for (unsigned int i : GeometryInfo<3>::face_indices()) if (cell->at_boundary(i)) { - if (cell->face(i)->center()(0) > half_length - 1.e-5) + if (cell->face(i)->center()(0) > half_length - tolerance) { cell->face(i)->set_boundary_id(2); cell->face(i)->set_manifold_id(numbers::flat_manifold_id); @@ -5623,7 +5627,7 @@ namespace GridGenerator numbers::flat_manifold_id); } } - else if (cell->face(i)->center()(0) < -half_length + 1.e-5) + else if (cell->face(i)->center()(0) < -half_length + tolerance) { cell->face(i)->set_boundary_id(1); cell->face(i)->set_manifold_id(numbers::flat_manifold_id);