From d378e9d585359c70c90d3e82a3c80b0252366dbe Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Tue, 21 May 2024 16:49:09 +0200 Subject: [PATCH] Let choose_p_over_h() communicate future FE indices and refinement flags on all types of parallel Triangulation. --- doc/news/changes/minor/20240318Fehling | 6 ++ source/hp/refinement.cc | 82 ++++++++++++-------------- 2 files changed, 43 insertions(+), 45 deletions(-) create mode 100644 doc/news/changes/minor/20240318Fehling diff --git a/doc/news/changes/minor/20240318Fehling b/doc/news/changes/minor/20240318Fehling new file mode 100644 index 0000000000..4bc065f025 --- /dev/null +++ b/doc/news/changes/minor/20240318Fehling @@ -0,0 +1,6 @@ +Changed: hp::Refinement::choose_p_over_h() now communicates +refinement flags and future FE indices on ghost cells for +all types of parallel Triangulation objects to decide between +p- and h-refinement. +
+(Marc Fehling, 2024/03/18) diff --git a/source/hp/refinement.cc b/source/hp/refinement.cc index c9a4b218a4..b11a2ca884 100644 --- a/source/hp/refinement.cc +++ b/source/hp/refinement.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -704,17 +705,29 @@ namespace hp Assert(dof_handler.has_hp_capabilities(), (typename DoFHandler::ExcOnlyAvailableWithHP())); - // Ghost siblings might occur on parallel::shared::Triangulation objects. - // We need information about future FE indices on all locally relevant - // cells here, and thus communicate them. - if (dynamic_cast *>( - &dof_handler.get_triangulation()) != nullptr) - internal::hp::DoFHandlerImplementation::communicate_future_fe_indices( - const_cast &>(dof_handler)); + // Ghost siblings might occur on parallel Triangulation objects. + // We need information about refinement flags and future FE indices + // on all locally relevant cells here, and thus communicate them. + if (dealii::parallel::distributed::Triangulation *tria = + dynamic_cast< + dealii::parallel::distributed::Triangulation *>( + const_cast *>( + &dof_handler.get_triangulation()))) + { + dealii::internal::parallel::distributed::TriangulationImplementation:: + exchange_refinement_flags(*tria); + } + + internal::hp::DoFHandlerImplementation::communicate_future_fe_indices( + const_cast &>(dof_handler)); + // Now: choose p-adaptation over h-adaptation. for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned() && cell->future_fe_index_set()) { + // This cell is flagged for p-adaptation. + + // Remove any h-refinement flags. cell->clear_refine_flag(); // A cell will only be coarsened into its parent if all of its @@ -740,43 +753,22 @@ namespace hp { if (child->is_active()) { - if (child->is_locally_owned()) - { - if (child->coarsen_flag_set()) - ++h_flagged_children; - if (child->future_fe_index_set()) - ++p_flagged_children; - } - else if (child->is_ghost()) - { - // The case of siblings being owned by different - // processors can only occur for - // parallel::shared::Triangulation objects. - Assert( - (dynamic_cast *>( - &dof_handler.get_triangulation()) != nullptr), - ExcInternalError()); - - if (child->coarsen_flag_set()) - ++h_flagged_children; - // The public interface does not allow to access - // future FE indices on ghost cells. However, we - // need this information here and thus call the - // internal function that does not check for cell - // ownership. - if (internal::DoFCellAccessorImplementation:: - Implementation:: - future_fe_index_set( - *child)) - ++p_flagged_children; - } - else - { - // Siblings of locally owned cells are all - // either also locally owned or ghost cells. - DEAL_II_ASSERT_UNREACHABLE(); - } + Assert(child->is_artificial() == false, + ExcInternalError()); + + if (child->coarsen_flag_set()) + ++h_flagged_children; + + // The public interface does not allow to access + // future FE indices on ghost cells. However, we + // need this information here and thus call the + // internal function that does not check for cell + // ownership. + if (internal::DoFCellAccessorImplementation:: + Implementation:: + future_fe_index_set( + *child)) + ++p_flagged_children; } } @@ -796,7 +788,7 @@ namespace hp } else { - // Perform p-adaptation on all children and + // Perform p-adaptation (if scheduled) and // drop all h-coarsening flags. for (const auto &child : parent->child_iterators()) { -- 2.39.5