From: Marc Fehling Date: Mon, 21 Aug 2023 23:36:19 +0000 (-0600) Subject: Disable eliminate_unrefined_islands in create_geometric_coarsening_sequence(). X-Git-Tag: relicensing~561^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15907%2Fhead;p=dealii.git Disable eliminate_unrefined_islands in create_geometric_coarsening_sequence(). --- diff --git a/doc/news/changes/incompatibilities/20230822Fehling b/doc/news/changes/incompatibilities/20230822Fehling new file mode 100644 index 0000000000..8a1ae184eb --- /dev/null +++ b/doc/news/changes/incompatibilities/20230822Fehling @@ -0,0 +1,8 @@ +Changed: For Triangulations created with +MGTransferGlobalCoarseningTools::create_geometric_coarsening_sequence(), +the MeshSmoothing flag Triangulation::eliminate_unrefined_islands will +be removed. It caused unintentional refinement during coarsening which +led to problems in GlobalCoarseningFineDoFHandlerView. See also +#15541. +
+(Marc Fehling, 2023/08/22) diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index dfb99460fc..0f973922cb 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -2380,8 +2380,7 @@ namespace MGTransferGlobalCoarseningTools &fine_triangulation_in)) return std::make_shared< parallel::distributed::Triangulation>( - fine_triangulation->get_communicator(), - fine_triangulation->get_mesh_smoothing()); + fine_triangulation->get_communicator()); else #endif #ifdef DEAL_II_WITH_MPI @@ -2390,23 +2389,29 @@ namespace MGTransferGlobalCoarseningTools &fine_triangulation_in)) return std::make_shared>( fine_triangulation->get_communicator(), - fine_triangulation->get_mesh_smoothing(), + Triangulation::none, fine_triangulation->with_artificial_cells()); else #endif - return std::make_shared>( - fine_triangulation_in.get_mesh_smoothing()); + return std::make_shared>(); }; const unsigned int max_level = fine_triangulation_in.n_global_levels() - 1; + // clear 'eliminate_unrefined_islands' from MeshSmoothing flags + // to prevent unintentional refinement during coarsen_global() + const auto mesh_smoothing = + static_cast::MeshSmoothing>( + fine_triangulation_in.get_mesh_smoothing() & + ~(Triangulation::eliminate_unrefined_islands)); + // create coarse meshes for (unsigned int l = max_level; l > 0; --l) { // copy triangulation auto new_tria = create_new_empty_triangulation(); - new_tria->copy_triangulation(*coarse_grid_triangulations[l]); + new_tria->set_mesh_smoothing(mesh_smoothing); // coarsen mesh new_tria->coarsen_global(); @@ -2447,9 +2452,6 @@ namespace MGTransferGlobalCoarseningTools const auto comm = fine_triangulation->get_communicator(); - parallel::distributed::Triangulation temp_triangulation( - comm, fine_triangulation->get_mesh_smoothing()); - if (keep_fine_triangulation == true && repartition_fine_triangulation == false) { @@ -2492,12 +2494,23 @@ namespace MGTransferGlobalCoarseningTools if (fine_triangulation_in.n_global_levels() == 1) return coarse_grid_triangulations; + parallel::distributed::Triangulation temp_triangulation( + comm); + if (keep_fine_triangulation == true) temp_triangulation.copy_triangulation(*fine_triangulation); auto *temp_triangulation_ptr = keep_fine_triangulation ? &temp_triangulation : fine_triangulation; + // clear 'eliminate_unrefined_islands' from MeshSmoothing flags + // to prevent unintentional refinement during coarsen_global() + const auto mesh_smoothing = + static_cast::MeshSmoothing>( + temp_triangulation_ptr->get_mesh_smoothing() & + ~(Triangulation::eliminate_unrefined_islands)); + temp_triangulation_ptr->set_mesh_smoothing(mesh_smoothing); + const unsigned int max_level = fine_triangulation->n_global_levels() - 1; // create coarse meshes @@ -2525,6 +2538,12 @@ namespace MGTransferGlobalCoarseningTools // save mesh coarse_grid_triangulations[l - 1] = level_triangulation; } + + // recover MeshSmoothing flags in case we used the fine_triangulation + // to build the sequence + if (keep_fine_triangulation == false) + fine_triangulation->set_mesh_smoothing( + coarse_grid_triangulations.back()->get_mesh_smoothing()); #endif AssertDimension(coarse_grid_triangulations[0]->n_global_levels(), 1);