]> https://gitweb.dealii.org/ - dealii.git/commitdiff
detect inifinite loop in periodic refinement 10712/head
authorTimo Heister <timo.heister@gmail.com>
Thu, 16 Jul 2020 16:22:43 +0000 (12:22 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 16 Jul 2020 16:22:43 +0000 (12:22 -0400)
As witnessed by ASPECT, see
https://github.com/geodynamics/aspect/issues/3604 ,
we might end up in an infinite loop while trying to prepare refinement
flags in
parallel::distributed::Triangulation::prepare_coarsening_and_refinement().
Add a check and abort (instead of a hang).

source/distributed/tria.cc

index f0f395dde409ca5589213f633318ed89dc042a67..40c3148bce28ee399810648d00a2a23dba67eed3 100644 (file)
@@ -3438,7 +3438,8 @@ namespace parallel
       this->save_coarsen_flags(flags_before[0]);
       this->save_refine_flags(flags_before[1]);
 
-      bool mesh_changed = false;
+      bool         mesh_changed = false;
+      unsigned int loop_counter = 0;
       do
         {
           this->dealii::Triangulation<dim, spacedim>::
@@ -3446,6 +3447,17 @@ namespace parallel
           this->update_periodic_face_map();
           // enforce 2:1 mesh balance over periodic boundaries
           mesh_changed = enforce_mesh_balance_over_periodic_boundaries(*this);
+
+          // We can't be sure that we won't run into a situation where we can
+          // not reconcile mesh smoothing and balancing of periodic faces. As we
+          // don't know what else to do, at least abort with an error message.
+          ++loop_counter;
+          AssertThrow(
+            loop_counter < 32,
+            ExcMessage(
+              "Infinite loop in "
+              "parallel::distributed::Triangulation::prepare_coarsening_and_refinement() "
+              "for periodic boundaries detected. Aborting."));
         }
       while (mesh_changed);
 

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.