From: Wolfgang Bangerth Date: Thu, 13 Jan 2022 04:50:54 +0000 (-0700) Subject: Validate correctness of input arguments. X-Git-Tag: v9.4.0-rc1~605^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=769ba804fa1c0b61208c27a2aaac35ba57300ad6;p=dealii.git Validate correctness of input arguments. --- diff --git a/include/deal.II/base/mpi_consensus_algorithms.templates.h b/include/deal.II/base/mpi_consensus_algorithms.templates.h index 1e216c979a..e7982b81d4 100644 --- a/include/deal.II/base/mpi_consensus_algorithms.templates.h +++ b/include/deal.II/base/mpi_consensus_algorithms.templates.h @@ -150,7 +150,21 @@ namespace Utilities { #ifdef DEAL_II_WITH_MPI // 1) - targets = this->process.compute_targets(); + targets = this->process.compute_targets(); + Assert( + [this]() { + std::vector my_destinations = this->targets; + const unsigned int n_destinations = my_destinations.size(); + std::sort(my_destinations.begin(), my_destinations.end()); + my_destinations.erase(std::unique(my_destinations.begin(), + my_destinations.end()), + my_destinations.end()); + return (my_destinations.size() == n_destinations); + }(), + ExcMessage("The consensus algorithms expect that each process " + "only sends a single message to another process, " + "but the targets provided include duplicates.")); + const auto n_targets = targets.size(); const int tag_request = Utilities::MPI::internal::Tags:: @@ -428,14 +442,29 @@ namespace Utilities PEX::start_communication() { #ifdef DEAL_II_WITH_MPI - // 1) determine with which processes this process wants to communicate - targets = this->process.compute_targets(); - const int tag_request = Utilities::MPI::internal::Tags:: consensus_algorithm_pex_answer_request; const int tag_deliver = Utilities::MPI::internal::Tags:: consensus_algorithm_pex_process_deliver; + + // 1) determine with which processes this process wants to communicate + // with + targets = this->process.compute_targets(); + Assert( + [this]() { + std::vector my_destinations = this->targets; + const unsigned int n_destinations = my_destinations.size(); + std::sort(my_destinations.begin(), my_destinations.end()); + my_destinations.erase(std::unique(my_destinations.begin(), + my_destinations.end()), + my_destinations.end()); + return (my_destinations.size() == n_destinations); + }(), + ExcMessage("The consensus algorithms expect that each process " + "only sends a single message to another process, " + "but the targets provided include duplicates.")); + // 2) determine who wants to communicate with this process sources = compute_point_to_point_communication_pattern(this->comm, targets);