From: Marc Fehling Date: Mon, 29 Mar 2021 20:12:34 +0000 (-0600) Subject: Fix hp::Refinement::choose_p_over_h() for hp-coarsening on p:s:Triangulation. X-Git-Tag: v9.3.0-rc1~267^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11980%2Fhead;p=dealii.git Fix hp::Refinement::choose_p_over_h() for hp-coarsening on p:s:Triangulation. --- diff --git a/source/hp/refinement.cc b/source/hp/refinement.cc index 5eebda3355..fb91081755 100644 --- a/source/hp/refinement.cc +++ b/source/hp/refinement.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -655,33 +656,14 @@ namespace hp dof_handler.has_hp_capabilities(), (typename dealii::DoFHandler::ExcOnlyAvailableWithHP())); - // Siblings of cells to be coarsened may not be owned by the same - // processor. We will exchange coarsening flags on ghost cells and - // temporarily store them. - std::map> ghost_buffer; - - if (dynamic_cast *>( - &dof_handler.get_triangulation())) - { - auto pack = - [](const typename dealii::DoFHandler::active_cell_iterator - &cell) -> std::pair { - return {cell->coarsen_flag_set(), cell->future_fe_index_set()}; - }; - - auto unpack = - [&ghost_buffer](const typename dealii::DoFHandler:: - active_cell_iterator & cell, - const std::pair pair) -> void { - ghost_buffer.emplace(cell->id(), pair); - }; - - GridTools::exchange_cell_data_to_ghosts< - std::pair, - dealii::DoFHandler>(dof_handler, pack, unpack); - } - + // 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) + dealii::internal::hp::DoFHandlerImplementation:: + communicate_future_fe_indices( + const_cast &>(dof_handler)); for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned() && cell->future_fe_index_set()) @@ -711,12 +693,27 @@ namespace hp } else if (child->is_ghost()) { - const std::pair &flags = - ghost_buffer[child->id()]; + // 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 (flags.first) + if (child->coarsen_flag_set()) ++h_flagged_children; - if (flags.second) + // 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 (dealii::internal:: + DoFCellAccessorImplementation:: + Implementation:: + future_fe_index_set( + *child)) ++p_flagged_children; } else diff --git a/tests/sharedtria/hp_choose_p_over_h.cc b/tests/sharedtria/hp_choose_p_over_h.cc index 5ad88c3d4b..dce9a701e0 100644 --- a/tests/sharedtria/hp_choose_p_over_h.cc +++ b/tests/sharedtria/hp_choose_p_over_h.cc @@ -69,11 +69,11 @@ test() for (unsigned int i = 0; i < cell->n_children(); ++i) { const auto &child = cell->child(i); + + child->set_coarsen_flag(); + if (child->is_locally_owned()) - { - child->set_future_fe_index(1); - child->set_coarsen_flag(); - } + child->set_future_fe_index(1); } } else if (cell->id().to_string() == "1_0:") @@ -84,12 +84,12 @@ test() for (unsigned int i = 0; i < cell->n_children(); ++i) { const auto &child = cell->child(i); + + child->set_coarsen_flag(); + if (child->is_locally_owned()) - { - if (i == 0) - child->set_future_fe_index(1); - child->set_coarsen_flag(); - } + if (i == 0) + child->set_future_fe_index(1); } } }