From: David Wells Date: Fri, 18 Feb 2022 15:41:24 +0000 (-0500) Subject: Move DictionaryPayload into a source file. X-Git-Tag: v9.4.0-rc1~466^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ae5160d6add1c2d82d53661d10745c93bef1b16;p=dealii.git Move DictionaryPayload into a source file. --- diff --git a/include/deal.II/base/mpi_compute_index_owner_internal.h b/include/deal.II/base/mpi_compute_index_owner_internal.h index 2ab4bebbd1..38cb7fad13 100644 --- a/include/deal.II/base/mpi_compute_index_owner_internal.h +++ b/include/deal.II/base/mpi_compute_index_owner_internal.h @@ -59,28 +59,14 @@ namespace Utilities std::vector &actually_owning_ranks, const std::pair & local_range, - std::vector &actually_owning_rank_list) - : buffers(buffers) - , actually_owning_ranks(actually_owning_ranks) - , local_range(local_range) - , actually_owning_rank_list(actually_owning_rank_list) - { - Assert(local_range.first <= local_range.second, ExcInternalError()); - } + std::vector &actually_owning_rank_list); /** * Implementation of * Utilities::MPI::ConsensusAlgorithms::Process::compute_targets(). */ virtual std::vector - compute_targets() override - { - std::vector targets; - for (const auto &rank_pair : buffers) - targets.push_back(rank_pair.first); - - return targets; - } + compute_targets() override; /** * Implementation of @@ -90,10 +76,7 @@ namespace Utilities create_request(const unsigned int other_rank, std::vector> - &send_buffer) override - { - send_buffer = this->buffers.at(other_rank); - } + &send_buffer) override; /** * Implementation of @@ -104,40 +87,7 @@ namespace Utilities const unsigned int other_rank, const std::vector> &buffer_recv, - std::vector &request_buffer) override - { - (void)request_buffer; // not needed - - - // process message: loop over all intervals - for (auto interval : buffer_recv) - { -#ifdef DEBUG - for (types::global_dof_index i = interval.first; - i < interval.second; - i++) - Assert( - actually_owning_ranks[i - local_range.first] == - numbers::invalid_unsigned_int, - ExcMessage( - "Multiple processes seem to own the same global index. " - "A possible reason is that the sets of locally owned " - "indices are not distinct.")); - Assert(interval.first < interval.second, ExcInternalError()); - Assert( - local_range.first <= interval.first && - interval.second <= local_range.second, - ExcMessage( - "The specified interval is not handled by the current process.")); -#endif - std::fill(actually_owning_ranks.data() + interval.first - - local_range.first, - actually_owning_ranks.data() + interval.second - - local_range.first, - other_rank); - } - actually_owning_rank_list.push_back(other_rank); - } + std::vector &request_buffer) override; private: const std::map + +#include +#include + +DEAL_II_NAMESPACE_OPEN + +namespace Utilities +{ + namespace MPI + { + namespace internal + { + /** + * An internal namespace used for Utilities::MPI::compute_index_owner() + * and for Utilities::MPI::Partitioner::set_ghost_indices(). + */ + namespace ComputeIndexOwner + { + DictionaryPayLoad::DictionaryPayLoad( + const std::map>> + & buffers, + std::vector &actually_owning_ranks, + const std::pair + & local_range, + std::vector &actually_owning_rank_list) + : buffers(buffers) + , actually_owning_ranks(actually_owning_ranks) + , local_range(local_range) + , actually_owning_rank_list(actually_owning_rank_list) + { + Assert(local_range.first <= local_range.second, ExcInternalError()); + } + + + + std::vector + DictionaryPayLoad::compute_targets() + { + std::vector targets; + for (const auto &rank_pair : buffers) + targets.push_back(rank_pair.first); + + return targets; + } + + + + void + DictionaryPayLoad::create_request( + const unsigned int other_rank, + std::vector> &send_buffer) + { + send_buffer = this->buffers.at(other_rank); + } + + + + void + DictionaryPayLoad::answer_request( + const unsigned int other_rank, + const std::vector> &buffer_recv, + std::vector & request_buffer) + { + (void)request_buffer; // not needed + + + // process message: loop over all intervals + for (auto interval : buffer_recv) + { +#ifdef DEBUG + for (types::global_dof_index i = interval.first; + i < interval.second; + i++) + Assert( + actually_owning_ranks[i - local_range.first] == + numbers::invalid_unsigned_int, + ExcMessage( + "Multiple processes seem to own the same global index. " + "A possible reason is that the sets of locally owned " + "indices are not distinct.")); + Assert(interval.first < interval.second, ExcInternalError()); + Assert( + local_range.first <= interval.first && + interval.second <= local_range.second, + ExcMessage( + "The specified interval is not handled by the current process.")); +#endif + std::fill(actually_owning_ranks.data() + interval.first - + local_range.first, + actually_owning_ranks.data() + interval.second - + local_range.first, + other_rank); + } + actually_owning_rank_list.push_back(other_rank); + } + } // namespace ComputeIndexOwner + } // namespace internal + } // namespace MPI +} // namespace Utilities + +DEAL_II_NAMESPACE_CLOSE