]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Check return value of GridTools::find_active_cell_Around_point 12203/head
authorDaniel Arndt <arndtd@ornl.gov>
Fri, 14 May 2021 15:29:09 +0000 (11:29 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Fri, 14 May 2021 15:29:21 +0000 (11:29 -0400)
include/deal.II/numerics/fe_field_function.templates.h
include/deal.II/numerics/vector_tools_point_gradient.templates.h
include/deal.II/numerics/vector_tools_point_value.templates.h
tests/mpi/muelu_periodicity.cc
tests/mpi/periodicity_01.cc
tests/mpi/periodicity_02.cc
tests/mpi/periodicity_03.cc

index d659f1e89ac76fae01ff0425f42f018c9d5c1ef3..90dc040011fd2bf3ecc74e4c00d0c841c839a6ad 100644 (file)
@@ -88,7 +88,8 @@ namespace Functions
                           ActiveCellIterator<dim, dim, DoFHandlerType>::type,
                         Point<dim>>
           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<dim, dim, DoFHandlerType>::type,
                         Point<dim>>
           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<dim, dim, DoFHandlerType>::type,
                         Point<dim>>
           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;
index 01c9e0fe7a5a89d6f268b05c011b7d69e786e632..b3fe37b385260507268809188f815b6bcdacff78 100644 (file)
@@ -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<dim>::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<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
            ExcInternalError());
index 38050b11dc1a298ca2013bdfedd83e0106601563..5a1d9a4dd729d67863286391c3995c211d56841b 100644 (file)
@@ -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<dim>::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<dim>::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<dim>::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<dim> q(
       GeometryInfo<dim>::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<dim> q(
       GeometryInfo<dim>::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<dim> q(
       GeometryInfo<dim>::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<dim> q(
       GeometryInfo<dim>::project_to_unit_cell(cell_point.second));
 
index 8342b37d5d280311be8bb7dddffed41a2f766c0d..bf59f64eec8a21f2628f6cb6480978595aa53187 100644 (file)
@@ -584,16 +584,11 @@ namespace Step22
                                       const int        proc,
                                       Vector<double> & value) const
   {
-    try
-      {
-        typename DoFHandler<dim>::active_cell_iterator cell =
-          GridTools::find_active_cell_around_point(dof_handler, point);
+    typename DoFHandler<dim>::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<dim> &p)
-      {}
+    if (cell.state() == IteratorState::valid && cell->is_locally_owned())
+      VectorTools::point_value(dof_handler, solution, point, value);
 
     std::vector<double> tmp(value.size());
     for (unsigned int i = 0; i < value.size(); ++i)
index 720c3f79445f59a15bda1d2a870286abc6d1a24f..41672c035289b498725f2208ab3f5f4ac9c23420 100644 (file)
@@ -325,19 +325,14 @@ namespace Step40
                                        const int            proc,
                                        Vector<PetscScalar> &value) const
   {
-    try
-      {
-        typename DoFHandler<dim>::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<dim> &p)
-      {}
+    typename DoFHandler<dim>::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<double> tmp(value.size());
     std::vector<double> tmp2(value.size());
index 4d51fdb6348c21b4c9d3a877ad4d284d506bc927..491810684ce71c136ef8514115739d82cd8c2a23 100644 (file)
@@ -598,16 +598,11 @@ namespace Step22
                                       const int        proc,
                                       Vector<double> & value) const
   {
-    try
-      {
-        typename DoFHandler<dim>::active_cell_iterator cell =
-          GridTools::find_active_cell_around_point(dof_handler, point);
+    typename DoFHandler<dim>::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<dim> &p)
-      {}
+    if (cell.state() == IteratorState::valid && cell->is_locally_owned())
+      VectorTools::point_value(dof_handler, solution, point, value);
 
     std::vector<double> tmp(value.size());
     for (unsigned int i = 0; i < value.size(); ++i)
index 8d545e603375c1807464a494415589db71c1ba65..01863565f66d50f58459d611a81712c52be1c429 100644 (file)
@@ -509,20 +509,17 @@ namespace Step22
                                       const int        proc,
                                       Vector<double> & value) const
   {
-    try
-      {
-        const typename DoFHandler<dim>::active_cell_iterator cell =
-          GridTools::find_active_cell_around_point(dof_handler, point);
+    const typename DoFHandler<dim>::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<dim> &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<double> tmp(value.size());
     for (unsigned int i = 0; i < value.size(); ++i)

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.