From 88639b5c2c78dc25e3b581c70136218a77721ecf Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 26 Mar 2024 17:40:26 -0600 Subject: [PATCH] Provide a better error message. --- source/grid/tria.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 8d68212f98..6b490f2353 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -16718,8 +16720,32 @@ namespace const bool allow_anisotropic_smoothing) { Assert(cell->is_active(), ExcInternalError()); - Assert(cell->refine_flag_set() == false, ExcInternalError()); +#ifdef DEBUG + // If this is not a parallel::distributed::Triangulation, then we really + // should only get here if the cell is marked for refinement: + if (dynamic_cast + *>(&cell->get_triangulation()) == nullptr) + Assert(cell->refine_flag_set() == false, ExcInternalError()); + else + // But if this is a p::d::Triangulation, then we don't have that + // much control and we can get here because mesh smoothing is + // requested but can not be honored because p4est controls + // what gets refined. In that case, we can at least provide + // a better error message. + Assert(cell->refine_flag_set() == false, + ExcMessage( + "The triangulation is trying to avoid unrefined islands " + "during mesh refinement/coarsening, as you had requested " + " by passing the appropriate 'smoothing flags' to the " + "constructor of the triangulation. However, for objects " + "of type parallel::distributed::Triangulation, control " + "over which cells get refined rests with p4est, not the " + "deal.II triangulation, and consequently it is not " + "always possible to avoid unrefined islands in the mesh. " + "Please remove the constructor argument to the triangulation " + "object that requests mesh smoothing.")); +#endif // now we provide two algorithms. the first one is the standard // one, coming from the time, where only isotropic refinement was -- 2.39.5