From 77229e5ae3b9502ffd33725a29a07f2a0d5c6674 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 9 Jan 2022 11:08:27 -0700 Subject: [PATCH] Simplify a loop a bit. --- .../fe/fe_tools_extrapolate.templates.h | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index 2d61b259e6..d3cb9aba9d 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -1169,8 +1169,10 @@ namespace FETools std::vector & received_cells) const { std::vector> sendbuffers(cells_to_send.size()); - std::vector requests(cells_to_send.size()); - std::vector destinations; + std::vector requests; + requests.reserve(cells_to_send.size()); + + std::vector destinations; // Protect the communication below: static Utilities::MPI::CollectiveMutex mutex; @@ -1182,24 +1184,24 @@ namespace FETools // send data std::vector>::iterator buffer = sendbuffers.begin(); - unsigned int idx = 0; - for (typename std::vector::const_iterator it = - cells_to_send.begin(); - it != cells_to_send.end(); - ++it, ++idx) + for (const auto &cell_to_send : cells_to_send) { - destinations.push_back(it->receiver); + destinations.push_back(cell_to_send.receiver); + + *buffer = cell_to_send.pack_data(); - *buffer = it->pack_data(); - const int ierr = MPI_Isend(buffer->data(), + MPI_Request request; + const int ierr = MPI_Isend(buffer->data(), buffer->size(), MPI_BYTE, - it->receiver, + cell_to_send.receiver, mpi_tag, communicator, - &requests[idx]); + &request); AssertThrowMPI(ierr); + requests.emplace_back(request); + ++buffer; } -- 2.39.5