From: Niklas Fehn Date: Wed, 17 Jun 2020 07:56:51 +0000 (+0200) Subject: fix bug in fast version of GridTools::find_active_cell_around_point() X-Git-Tag: v9.3.0-rc1~1315^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e04675459a4f0915cfb235e2861cbd6080fbc2f;p=dealii.git fix bug in fast version of GridTools::find_active_cell_around_point() --- diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 535e1d4392..502111f4d0 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -1682,27 +1682,32 @@ namespace GridTools { auto cell = vertex_to_cells[closest_vertex_index].begin(); std::advance(cell, neighbor_permutation[i]); - const Point p_unit = - mapping.transform_real_to_unit_cell(*cell, p); - if (GeometryInfo::is_inside_unit_cell(p_unit, tolerance)) + if (!(*cell)->is_artificial()) { - cell_and_position.first = *cell; - cell_and_position.second = p_unit; - found_cell = true; - approx_cell = false; - break; - } - // The point is not inside this cell: checking how far outside - // it is and whether we want to use this cell as a backup if we - // can't find a cell within which the point lies. - const double dist = - GeometryInfo::distance_to_unit_cell(p_unit); - if (dist < best_distance) - { - best_distance = dist; - cell_and_position_approx.first = *cell; - cell_and_position_approx.second = p_unit; - approx_cell = true; + const Point p_unit = + mapping.transform_real_to_unit_cell(*cell, p); + if (GeometryInfo::is_inside_unit_cell(p_unit, + tolerance)) + { + cell_and_position.first = *cell; + cell_and_position.second = p_unit; + found_cell = true; + approx_cell = false; + break; + } + // The point is not inside this cell: checking how far + // outside it is and whether we want to use this cell as a + // backup if we can't find a cell within which the point + // lies. + const double dist = + GeometryInfo::distance_to_unit_cell(p_unit); + if (dist < best_distance) + { + best_distance = dist; + cell_and_position_approx.first = *cell; + cell_and_position_approx.second = p_unit; + approx_cell = true; + } } } catch (typename Mapping::ExcTransformationFailed &)