From: Luca Heltai Date: Tue, 11 May 2021 16:49:50 +0000 (+0200) Subject: Apply suggestions from code review X-Git-Tag: v9.3.0-rc1~88^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11276%2Fhead;p=dealii.git Apply suggestions from code review Co-authored-by: Martin Kronbichler --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 25e94b1bd2..38e746cd67 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -1320,7 +1320,8 @@ namespace GridTools * * If the point requested does not lie in a locally-owned or ghost cell, * then this function will return the (invalid) MeshType::end() - * iterator. + * iterator. This case can be handled similarly to the various `std::find()` + * and `std::lower_bound()` functions. * * @param mapping The mapping used to determine whether the given point is * inside a given cell. @@ -1445,7 +1446,8 @@ namespace GridTools * auto cell_and_ref_point = GridTools::find_active_cell_around_point( * cache, p, cell_hint, marked_vertices, tolerance); * - * if(cell_and_ref_point.first != triangulation.end()) { + * if (cell_and_ref_point.first != triangulation.end()) + * { * // use current cell as hint for the next point * cell_hint = cell_and_ref_point.first; * // do something with cell_and_ref_point diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index aa66cd938a..ab4afa55e2 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -450,6 +450,9 @@ namespace GridTools int best_level = -1; std::pair> best_cell; + // Initialize best_cell.first to the end iterator + best_cell.first = mesh.end(); + // Find closest vertex and determine // all adjacent cells std::vector adjacent_cells_tmp = @@ -574,7 +577,7 @@ namespace GridTools const auto cell_and_point = find_active_cell_around_point( mapping, mesh, p, marked_vertices, tolerance); - if (cell_and_point.first.state() != IteratorState::valid) + if (cell_and_point.first == mesh.end()) return {}; return find_all_active_cells_around_point( @@ -609,7 +612,7 @@ namespace GridTools // insert the fist cell and point into the vector cells_and_points.push_back(first_cell); - // check if the given point is on the surface of the unit cell. if yes, + // check if the given point is on the surface of the unit cell. If yes, // need to find all neighbors const Point unit_point = cells_and_points.front().second; const auto my_cell = cells_and_points.front().first;