From: Daniel Arndt Date: Fri, 14 May 2021 15:29:09 +0000 (-0400) Subject: Check return value of GridTools::find_active_cell_Around_point X-Git-Tag: v9.3.0-rc1~74^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12203%2Fhead;p=dealii.git Check return value of GridTools::find_active_cell_Around_point --- diff --git a/include/deal.II/numerics/fe_field_function.templates.h b/include/deal.II/numerics/fe_field_function.templates.h index d659f1e89a..90dc040011 100644 --- a/include/deal.II/numerics/fe_field_function.templates.h +++ b/include/deal.II/numerics/fe_field_function.templates.h @@ -88,7 +88,8 @@ namespace Functions ActiveCellIterator::type, Point> my_pair = GridTools::find_active_cell_around_point(mapping, *dh, p); - AssertThrow(!my_pair.first->is_artificial(), + AssertThrow(my_pair.first.state() == IteratorState::valid && + !my_pair.first->is_artificial(), VectorTools::ExcPointNotAvailableHere()); cell = my_pair.first; @@ -147,7 +148,8 @@ namespace Functions ActiveCellIterator::type, Point> my_pair = GridTools::find_active_cell_around_point(mapping, *dh, p); - AssertThrow(!my_pair.first->is_artificial(), + AssertThrow(my_pair.first.state() == IteratorState::valid && + !my_pair.first->is_artificial(), VectorTools::ExcPointNotAvailableHere()); cell = my_pair.first; @@ -220,7 +222,8 @@ namespace Functions ActiveCellIterator::type, Point> my_pair = GridTools::find_active_cell_around_point(mapping, *dh, p); - AssertThrow(!my_pair.first->is_artificial(), + AssertThrow(my_pair.first.state() == IteratorState::valid && + !my_pair.first->is_artificial(), VectorTools::ExcPointNotAvailableHere()); cell = my_pair.first; diff --git a/include/deal.II/numerics/vector_tools_point_gradient.templates.h b/include/deal.II/numerics/vector_tools_point_gradient.templates.h index 01c9e0fe7a..b3fe37b385 100644 --- a/include/deal.II/numerics/vector_tools_point_gradient.templates.h +++ b/include/deal.II/numerics/vector_tools_point_gradient.templates.h @@ -105,7 +105,8 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof, point); - AssertThrow(cell_point.first->is_locally_owned(), + AssertThrow(cell_point.first.state() == IteratorState::valid && + cell_point.first->is_locally_owned(), ExcPointNotAvailableHere()); Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); @@ -150,7 +151,8 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof, point); - AssertThrow(cell_point.first->is_locally_owned(), + AssertThrow(cell_point.first.state() == IteratorState::valid && + cell_point.first->is_locally_owned(), ExcPointNotAvailableHere()); Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); diff --git a/include/deal.II/numerics/vector_tools_point_value.templates.h b/include/deal.II/numerics/vector_tools_point_value.templates.h index 38050b11dc..5a1d9a4dd7 100644 --- a/include/deal.II/numerics/vector_tools_point_value.templates.h +++ b/include/deal.II/numerics/vector_tools_point_value.templates.h @@ -103,7 +103,8 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof, point); - AssertThrow(cell_point.first->is_locally_owned(), + AssertThrow(cell_point.first.state() == IteratorState::valid && + cell_point.first->is_locally_owned(), ExcPointNotAvailableHere()); Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); @@ -145,7 +146,8 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof, point); - AssertThrow(cell_point.first->is_locally_owned(), + AssertThrow(cell_point.first.state() == IteratorState::valid && + cell_point.first->is_locally_owned(), ExcPointNotAvailableHere()); Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); @@ -247,7 +249,8 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof, point); - AssertThrow(cell_point.first->is_locally_owned(), + AssertThrow(cell_point.first.state() == IteratorState::valid && + cell_point.first->is_locally_owned(), ExcPointNotAvailableHere()); Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); @@ -290,6 +293,9 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof_handler, p); + AssertThrow(cell_point.first.state() == IteratorState::valid, + ExcPointNotAvailableHere()); + Quadrature q( GeometryInfo::project_to_unit_cell(cell_point.second)); @@ -351,6 +357,9 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof_handler, p); + AssertThrow(cell_point.first.state() == IteratorState::valid, + ExcPointNotAvailableHere()); + Quadrature q( GeometryInfo::project_to_unit_cell(cell_point.second)); @@ -393,6 +402,9 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof_handler, p); + AssertThrow(cell_point.first.state() == IteratorState::valid, + ExcPointNotAvailableHere()); + const Quadrature q( GeometryInfo::project_to_unit_cell(cell_point.second)); @@ -461,6 +473,9 @@ namespace VectorTools cell_point = GridTools::find_active_cell_around_point(mapping, dof_handler, p); + AssertThrow(cell_point.first.state() == IteratorState::valid, + ExcPointNotAvailableHere()); + Quadrature q( GeometryInfo::project_to_unit_cell(cell_point.second)); diff --git a/tests/mpi/muelu_periodicity.cc b/tests/mpi/muelu_periodicity.cc index 8342b37d5d..bf59f64eec 100644 --- a/tests/mpi/muelu_periodicity.cc +++ b/tests/mpi/muelu_periodicity.cc @@ -584,16 +584,11 @@ namespace Step22 const int proc, Vector & value) const { - try - { - typename DoFHandler::active_cell_iterator cell = - GridTools::find_active_cell_around_point(dof_handler, point); + typename DoFHandler::active_cell_iterator cell = + GridTools::find_active_cell_around_point(dof_handler, point); - if (cell->is_locally_owned()) - VectorTools::point_value(dof_handler, solution, point, value); - } - catch (GridTools::ExcPointNotFound &p) - {} + if (cell.state() == IteratorState::valid && cell->is_locally_owned()) + VectorTools::point_value(dof_handler, solution, point, value); std::vector tmp(value.size()); for (unsigned int i = 0; i < value.size(); ++i) diff --git a/tests/mpi/periodicity_01.cc b/tests/mpi/periodicity_01.cc index 720c3f7944..41672c0352 100644 --- a/tests/mpi/periodicity_01.cc +++ b/tests/mpi/periodicity_01.cc @@ -325,19 +325,14 @@ namespace Step40 const int proc, Vector &value) const { - try - { - typename DoFHandler::active_cell_iterator cell = - GridTools::find_active_cell_around_point(dof_handler, point); - - if (cell->is_locally_owned()) - VectorTools::point_value(dof_handler, - locally_relevant_solution, - point, - value); - } - catch (GridTools::ExcPointNotFound &p) - {} + typename DoFHandler::active_cell_iterator cell = + GridTools::find_active_cell_around_point(dof_handler, point); + + if (cell.state() == IteratorState::valid && cell->is_locally_owned()) + VectorTools::point_value(dof_handler, + locally_relevant_solution, + point, + value); std::vector tmp(value.size()); std::vector tmp2(value.size()); diff --git a/tests/mpi/periodicity_02.cc b/tests/mpi/periodicity_02.cc index 4d51fdb634..491810684c 100644 --- a/tests/mpi/periodicity_02.cc +++ b/tests/mpi/periodicity_02.cc @@ -598,16 +598,11 @@ namespace Step22 const int proc, Vector & value) const { - try - { - typename DoFHandler::active_cell_iterator cell = - GridTools::find_active_cell_around_point(dof_handler, point); + typename DoFHandler::active_cell_iterator cell = + GridTools::find_active_cell_around_point(dof_handler, point); - if (cell->is_locally_owned()) - VectorTools::point_value(dof_handler, solution, point, value); - } - catch (GridTools::ExcPointNotFound &p) - {} + if (cell.state() == IteratorState::valid && cell->is_locally_owned()) + VectorTools::point_value(dof_handler, solution, point, value); std::vector tmp(value.size()); for (unsigned int i = 0; i < value.size(); ++i) diff --git a/tests/mpi/periodicity_03.cc b/tests/mpi/periodicity_03.cc index 8d545e6033..01863565f6 100644 --- a/tests/mpi/periodicity_03.cc +++ b/tests/mpi/periodicity_03.cc @@ -509,20 +509,17 @@ namespace Step22 const int proc, Vector & value) const { - try - { - const typename DoFHandler::active_cell_iterator cell = - GridTools::find_active_cell_around_point(dof_handler, point); + const typename DoFHandler::active_cell_iterator cell = + GridTools::find_active_cell_around_point(dof_handler, point); + if (cell.state() == IteratorState::valid) + { if (cell->is_locally_owned()) VectorTools::point_value(dof_handler, solution, point, value); } - catch (GridTools::ExcPointNotFound &p) - { - pcout << "Point: " << point << " is not inside a non-artificial cell!" - << std::endl; - } - + else + pcout << "Point: " << point << " is not inside a non-artificial cell!" + << std::endl; std::vector tmp(value.size()); for (unsigned int i = 0; i < value.size(); ++i)