]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Applied suggestion.
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 2 Dec 2019 12:23:36 +0000 (13:23 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 2 Dec 2019 12:23:36 +0000 (13:23 +0100)
include/deal.II/base/mpi.h

index 3845b752c2011181d67a4e3cde425929b18cf58b..3f1277a0c4b9c5f6df0b59272362a38bdbff0bcf 100644 (file)
@@ -1490,15 +1490,19 @@ namespace Utilities
 #  else
       const auto my_proc = this_mpi_process(comm);
 
+      std::map<unsigned int, T> received_objects;
+
       std::vector<unsigned int> send_to;
       send_to.reserve(objects_to_send.size());
       for (const auto &m : objects_to_send)
-        if (m.first != my_proc)
+        if (m.first == my_proc)
+          received_objects[my_proc] = m.second;
+        else
           send_to.emplace_back(m.first);
 
       // Shortcut, when running in serial
       if (send_to.size() == 0)
-        return objects_to_send;
+        return received_objects;
 
       const auto receive_from =
         Utilities::MPI::compute_point_to_point_communication_pattern(comm,
@@ -1533,8 +1537,7 @@ namespace Utilities
             }
       }
 
-      // Receiving buffers
-      std::map<unsigned int, T> received_objects;
+      // Fill the output map
       {
         std::vector<char> buffer;
         // We do this on a first come/first served basis
@@ -1575,10 +1578,6 @@ namespace Utilities
                   buffer_send_requests.data(),
                   MPI_STATUSES_IGNORE);
 
-      // If necessary, insert my own objects into the received_objects
-      if (objects_to_send.find(my_proc) != objects_to_send.end())
-        received_objects[my_proc] = objects_to_send.at(my_proc);
-
       return received_objects;
 #  endif // deal.II with MPI
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.