]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix RemotePointEvalution::marked_vertices for vectors with only false 13187/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 7 Jan 2022 10:00:11 +0000 (11:00 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 7 Jan 2022 10:15:54 +0000 (11:15 +0100)
source/grid/grid_tools.cc

index 9523f71252846e44b33fc8d72cc20638a9270835..6e733b33d6ffdc75ef973f06f2e93a0a360a94fa 100644 (file)
@@ -5917,6 +5917,22 @@ namespace GridTools
         return other_rank_index;
       };
 
+      Assert(
+        (marked_vertices.size() == 0) ||
+          (marked_vertices.size() == cache.get_triangulation().n_vertices()),
+        ExcMessage(
+          "The marked_vertices vector has to be either empty or its size has "
+          "to equal the number of vertices of the triangulation."));
+
+      // In the case that a marked_vertices vector has been given and none
+      // of its entries is true, we know that this process does not own
+      // any of the incoming points (and it will not send any data) so
+      // that we can take a short cut.
+      const bool has_relevant_vertices =
+        (marked_vertices.size() == 0) ||
+        (std::find(marked_vertices.begin(), marked_vertices.end(), true) !=
+         marked_vertices.end());
+
       Utilities::MPI::ConsensusAlgorithms::AnonymousProcess<char, char> process(
         [&]() { return potential_owners_ranks; },
         [&](const unsigned int other_rank, std::vector<char> &send_buffer) {
@@ -5944,36 +5960,39 @@ namespace GridTools
           std::vector<unsigned int> request_buffer_temp(
             recv_buffer_unpacked.size(), 0);
 
-          cell_hint = cache.get_triangulation().begin_active();
-
-          for (unsigned int i = 0; i < recv_buffer_unpacked.size(); ++i)
+          if (has_relevant_vertices)
             {
-              const auto &index_and_point = recv_buffer_unpacked[i];
-
-              const auto cells_and_reference_positions =
-                find_all_locally_owned_active_cells_around_point(
-                  cache,
-                  index_and_point.second,
-                  cell_hint,
-                  marked_vertices,
-                  tolerance,
-                  enforce_unique_mapping);
-
-              for (const auto &cell_and_reference_position :
-                   cells_and_reference_positions)
+              cell_hint = cache.get_triangulation().begin_active();
+
+              for (unsigned int i = 0; i < recv_buffer_unpacked.size(); ++i)
                 {
-                  send_components.emplace_back(
-                    std::pair<int, int>(
-                      cell_and_reference_position.first->level(),
-                      cell_and_reference_position.first->index()),
-                    other_rank,
-                    index_and_point.first,
-                    cell_and_reference_position.second,
-                    index_and_point.second,
-                    numbers::invalid_unsigned_int);
-                }
+                  const auto &index_and_point = recv_buffer_unpacked[i];
+
+                  const auto cells_and_reference_positions =
+                    find_all_locally_owned_active_cells_around_point(
+                      cache,
+                      index_and_point.second,
+                      cell_hint,
+                      marked_vertices,
+                      tolerance,
+                      enforce_unique_mapping);
+
+                  for (const auto &cell_and_reference_position :
+                       cells_and_reference_positions)
+                    {
+                      send_components.emplace_back(
+                        std::pair<int, int>(
+                          cell_and_reference_position.first->level(),
+                          cell_and_reference_position.first->index()),
+                        other_rank,
+                        index_and_point.first,
+                        cell_and_reference_position.second,
+                        index_and_point.second,
+                        numbers::invalid_unsigned_int);
+                    }
 
-              request_buffer_temp[i] = cells_and_reference_positions.size();
+                  request_buffer_temp[i] = cells_and_reference_positions.size();
+                }
             }
 
           if (perform_handshake)

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.