]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Apply suggestions from code review 11276/head
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 11 May 2021 16:49:50 +0000 (18:49 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Tue, 11 May 2021 17:07:16 +0000 (19:07 +0200)
Co-authored-by: Martin Kronbichler <kronbichler@lnm.mw.tum.de>
include/deal.II/grid/grid_tools.h
source/grid/grid_tools_dof_handlers.cc

index 25e94b1bd252bf26ca3ca988adf5fdaeefa84df2..38e746cd6755425d4050ab710e54e41c55c41606 100644 (file)
@@ -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<dim, spacedim>::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
index aa66cd938a0aa7c47104205fe7a3d2a1a6744d86..ab4afa55e2a716a82569de95c35986258ffd5aa8 100644 (file)
@@ -450,6 +450,9 @@ namespace GridTools
     int                                         best_level    = -1;
     std::pair<active_cell_iterator, Point<dim>> 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<active_cell_iterator> 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<dim> unit_point = cells_and_points.front().second;
     const auto       my_cell    = cells_and_points.front().first;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.