From: blaisb Date: Fri, 15 Nov 2019 11:53:11 +0000 (-0500) Subject: - Fixed a bug in grid_tools compute_mesh_predicate_bounding_box that X-Git-Tag: v9.2.0-rc1~803^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9053%2Fhead;p=dealii.git - Fixed a bug in grid_tools compute_mesh_predicate_bounding_box that lead to a crash when the triangulation was with dim < spacedim (e.g. <2,3>). - Adapted the tests to have the right template parameters for all classes NOTE: The commented parts in the test will still crash if you have dim) AND if the maxbbox < number of cell in the refinement level. This is because the bounding box merge does not work when the cells are part of a Triangulation with dim!=spacedim. This part should be further investigated. --- diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index a328fcfe64..d75bda3261 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -2021,7 +2021,7 @@ namespace GridTools for (; i < active_cells.size(); ++i) if (predicate(active_cells[i])) for (unsigned int v = 0; - v < GeometryInfo::vertices_per_cell; + v < GeometryInfo::vertices_per_cell; ++v) for (unsigned int d = 0; d < spacedim; ++d) { diff --git a/tests/grid/grid_tools_compute_mesh_predicate_bounding_box_1.cc b/tests/grid/grid_tools_compute_mesh_predicate_bounding_box_1.cc index 1376f748ee..fb85be1dcf 100644 --- a/tests/grid/grid_tools_compute_mesh_predicate_bounding_box_1.cc +++ b/tests/grid/grid_tools_compute_mesh_predicate_bounding_box_1.cc @@ -35,11 +35,10 @@ #include "../tests.h" // predicate: test if the cell is locally owned -template +template bool -pred_locally_owned( - const typename parallel::distributed::Triangulation::cell_iterator - &cell) +pred_locally_owned(const typename parallel::distributed:: + Triangulation::cell_iterator &cell) { return cell->is_locally_owned(); } @@ -53,19 +52,19 @@ test_hypercube(unsigned int ref, unsigned int max_bbox) << " refinement: " << ref << " max number of boxes: " << max_bbox << std::endl; - parallel::distributed::Triangulation tria(mpi_communicator); + parallel::distributed::Triangulation tria(mpi_communicator); GridGenerator::hyper_cube(tria); tria.refine_global(4); - typedef typename parallel::distributed::Triangulation< - spacedim>::active_cell_iterator cell_iterator; + typedef typename parallel::distributed::Triangulation:: + active_cell_iterator cell_iterator; std::function predicate = - pred_locally_owned; + pred_locally_owned; std::vector> local_bbox = GridTools::compute_mesh_predicate_bounding_box< - parallel::distributed::Triangulation>( + parallel::distributed::Triangulation>( tria, predicate, ref, true, max_bbox); if (local_bbox.size() > 0) @@ -94,8 +93,7 @@ test_hypercube(unsigned int ref, unsigned int max_bbox) // Looking if every point is at least inside a bounding box for (; cell < endc; ++cell) if (cell->is_locally_owned()) - for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; - ++v) + for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; ++v) { bool inside_a_box = false; for (unsigned int i = 0; i < local_bbox.size(); ++i) @@ -126,6 +124,10 @@ main(int argc, char *argv[]) test_hypercube<2>(1, 4); test_hypercube<2>(2, 4); test_hypercube<2>(2, 2); + // test_hypercube<2, 3>(0, 4); + // test_hypercube<2, 3>(1, 4); + // test_hypercube<2, 3>(2, 4); + // test_hypercube<2, 3>(2, 2); test_hypercube<3>(0, 4); test_hypercube<3>(1, 4); test_hypercube<3>(2, 4);