From: Peter Munch Date: Fri, 7 Jan 2022 10:00:11 +0000 (+0100) Subject: Fix RemotePointEvalution::marked_vertices for vectors with only false X-Git-Tag: v9.4.0-rc1~651^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff69cee992435b4b3540d08704ea96ed5f1a26a8;p=dealii.git Fix RemotePointEvalution::marked_vertices for vectors with only false --- diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 9523f71252..6e733b33d6 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -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 process( [&]() { return potential_owners_ranks; }, [&](const unsigned int other_rank, std::vector &send_buffer) { @@ -5944,36 +5960,39 @@ namespace GridTools std::vector 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( - 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( + 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)