From: Wolfgang Bangerth Date: Fri, 15 Jul 2022 03:24:51 +0000 (-0600) Subject: Reduce the volume of communication somewhat. X-Git-Tag: v9.5.0-rc1~1085^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af2b8bc3e6d29a86cd53a905967a2acdd858767a;p=dealii.git Reduce the volume of communication somewhat. --- diff --git a/source/distributed/shared_tria.cc b/source/distributed/shared_tria.cc index f9b999d28f..f111aa38fe 100644 --- a/source/distributed/shared_tria.cc +++ b/source/distributed/shared_tria.cc @@ -14,6 +14,7 @@ // --------------------------------------------------------------------- #include +#include #include #include @@ -27,6 +28,8 @@ #include +#include + DEAL_II_NAMESPACE_OPEN @@ -354,15 +357,30 @@ namespace parallel // make sure that all refinement/coarsening flags are the same on all // processes { - std::vector refinement_configurations( - this->n_active_cells() * 2, 0u); + // Obtain the type used to store the different possibilities + // a cell can be refined. This is a bit awkward because + // what `cell->refine_flag_set()` returns is a struct + // type, RefinementCase, which internally stores a + // std::uint8_t, which actually holds integers of + // enum type RefinementPossibilities::Possibilities. + // In the following, use the actual name of the enum, but + // make sure that it is in fact a `std::uint8_t` or + // equally sized type. + using int_type = std::underlying_type_t< + typename RefinementPossibilities::Possibilities>; + static_assert(sizeof(int_type) == sizeof(std::uint8_t), + "Internal type mismatch."); + + std::vector refinement_configurations(this->n_active_cells() * + 2, + int_type(0)); for (const auto &cell : this->active_cell_iterators()) if (cell->is_locally_owned()) { refinement_configurations[cell->active_cell_index() * 2 + 0] = - cell->refine_flag_set(); + static_cast(cell->refine_flag_set()); refinement_configurations[cell->active_cell_index() * 2 + 1] = - cell->coarsen_flag_set(); + static_cast(cell->coarsen_flag_set() ? 1 : 0); } Utilities::MPI::max(refinement_configurations, @@ -385,7 +403,7 @@ namespace parallel ExcMessage( "Refinement/coarsening flags of cells are not consistent in parallel!")); - if (refinement_configurations[cell->active_cell_index() * 2 + 0] > + if (refinement_configurations[cell->active_cell_index() * 2 + 0] != 0) cell->set_refine_flag(RefinementCase( refinement_configurations[cell->active_cell_index() * 2 + 0]));