From: Wolfgang Bangerth Date: Sun, 9 Jan 2022 18:08:27 +0000 (-0700) Subject: Simplify a loop a bit. X-Git-Tag: v9.4.0-rc1~597^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77229e5ae3b9502ffd33725a29a07f2a0d5c6674;p=dealii.git Simplify a loop a bit. --- 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; }