From 8fe0aa44c42ee636d73eff9a024bebd0c1b92314 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 13 Sep 2024 07:27:53 -0600 Subject: [PATCH] Use Utilties::MPI::compute_index_owner() instead of lower-level facilities. --- .../mg_transfer_global_coarsening.templates.h | 44 ++++--------------- .../repartitioning_policy_tools.cc | 25 +++-------- source/multigrid/mg_tools.cc | 22 +++------- 3 files changed, 19 insertions(+), 72 deletions(-) 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 7db8a1b7f1..eca2376982 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -837,25 +837,11 @@ namespace internal is_dst_remote_potentially_relevant.subtract_set(is_dst_locally_owned); - std::vector owning_ranks_of_ghosts( - is_dst_remote_potentially_relevant.n_elements()); - - { - Utilities::MPI::internal::ComputeIndexOwner:: - ConsensusAlgorithmsPayload process( - is_dst_locally_owned, - is_dst_remote_potentially_relevant, - communicator, - owning_ranks_of_ghosts, - false); - - Utilities::MPI::ConsensusAlgorithms::Selector< - std::vector< - std::pair>, - std::vector> - consensus_algorithm; - consensus_algorithm.run(process, communicator); - } + const std::vector owning_ranks_of_ghosts = + Utilities::MPI::compute_index_owner( + is_dst_locally_owned, + is_dst_remote_potentially_relevant, + communicator); for (unsigned i = 0; i < is_dst_remote_potentially_relevant.n_elements(); @@ -3961,22 +3947,10 @@ MGTwoLevelTransfer::reinit( const MPI_Comm communicator = dof_handler_fine.get_mpi_communicator(); - std::vector owning_ranks( - is_locally_owned_coarse.n_elements()); - - Utilities::MPI::internal::ComputeIndexOwner::ConsensusAlgorithmsPayload - process(is_locally_owned_fine, - is_locally_owned_coarse, - communicator, - owning_ranks, - false); - - Utilities::MPI::ConsensusAlgorithms::Selector< - std::vector< - std::pair>, - std::vector> - consensus_algorithm; - consensus_algorithm.run(process, communicator); + const std::vector owning_ranks = + Utilities::MPI::compute_index_owner(is_locally_owned_fine, + is_locally_owned_coarse, + communicator); bool all_cells_found = true; diff --git a/source/distributed/repartitioning_policy_tools.cc b/source/distributed/repartitioning_policy_tools.cc index 1377c7d1a4..7430a8fc36 100644 --- a/source/distributed/repartitioning_policy_tools.cc +++ b/source/distributed/repartitioning_policy_tools.cc @@ -13,8 +13,7 @@ // ------------------------------------------------------------------------ -#include -#include +#include #include #include @@ -145,28 +144,14 @@ namespace RepartitioningPolicyTools if (cell->is_locally_owned()) is_coarse.add_index(cell_id_translator.translate(cell)); - std::vector owning_ranks_of_coarse_cells( - is_coarse.n_elements()); - { - Utilities::MPI::internal::ComputeIndexOwner::ConsensusAlgorithmsPayload - process(is_level_partitions, - is_coarse, - communicator, - owning_ranks_of_coarse_cells, - false); - - Utilities::MPI::ConsensusAlgorithms::Selector< - std::vector< - std::pair>, - std::vector> - consensus_algorithm; - consensus_algorithm.run(process, communicator); - } + const std::vector owning_ranks_of_coarse_cells = + Utilities::MPI::compute_index_owner(is_level_partitions, + is_coarse, + communicator); const auto tria = dynamic_cast *>( &tria_coarse_in); - Assert(tria, ExcNotImplemented()); LinearAlgebra::distributed::Vector partition( diff --git a/source/multigrid/mg_tools.cc b/source/multigrid/mg_tools.cc index 62ecfa943e..db27943f74 100644 --- a/source/multigrid/mg_tools.cc +++ b/source/multigrid/mg_tools.cc @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -1771,22 +1771,10 @@ namespace MGTools cell_id_translator.translate(cell, i)); } - std::vector is_fine_required_ranks( - is_fine_required.n_elements()); - - Utilities::MPI::internal::ComputeIndexOwner::ConsensusAlgorithmsPayload - process(is_fine_owned, - is_fine_required, - communicator, - is_fine_required_ranks, - false); - - Utilities::MPI::ConsensusAlgorithms::Selector< - std::vector< - std::pair>, - std::vector> - consensus_algorithm; - consensus_algorithm.run(process, communicator); + const std::vector is_fine_required_ranks = + Utilities::MPI::compute_index_owner(is_fine_owned, + is_fine_required, + communicator); for (unsigned i = 0; i < is_fine_required.n_elements(); ++i) if (is_fine_required_ranks[i] == my_rank) -- 2.39.5