From: Nils Much Date: Mon, 4 Mar 2024 13:10:14 +0000 (+0100) Subject: Colorize hyper recangle with simplices X-Git-Tag: v9.6.0-rc1~492^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab2c3d5df568141ad3a86d7726fc2f208447bf90;p=dealii.git Colorize hyper recangle with simplices --- diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index cab4633112..dbd0b28e4f 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -2634,7 +2634,7 @@ namespace GridGenerator // use a large epsilon to // compare numbers to avoid // roundoff problems. - double epsilon = 10; + double epsilon = std::numeric_limits::max(); for (unsigned int i = 0; i < dim; ++i) epsilon = std::min(epsilon, 0.01 * delta[i][i]); Assert(epsilon > 0, @@ -8645,8 +8645,6 @@ namespace GridGenerator { AssertDimension(dim, spacedim); - AssertThrow(colorize == false, ExcNotImplemented()); - std::vector> vertices; std::vector> cells; @@ -8782,11 +8780,34 @@ namespace GridGenerator } else { - AssertThrow(colorize == false, ExcNotImplemented()); + AssertThrow(false, ExcNotImplemented()); } // actually create triangulation tria.create_triangulation(vertices, cells, SubCellData()); + + if (colorize) + { + // to colorize, run through all + // faces of all cells and set + // boundary indicator to the + // correct value if it was 0. + + // use a large epsilon to + // compare numbers to avoid + // roundoff problems. + double epsilon = std::numeric_limits::max(); + for (unsigned int i = 0; i < dim; ++i) + epsilon = std::min(epsilon, + 0.01 * (std::abs(p2[i] - p1[i]) / repetitions[i])); + Assert(epsilon > 0, + ExcMessage( + "The distance between corner points must be positive.")); + + // actual code is external since + // 1-D is different from 2/3d. + colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon); + } }