From: Wolfgang Bangerth Date: Mon, 23 Oct 2017 19:03:47 +0000 (-0600) Subject: Clean up code in MGLevelGlobalTransfer::fill_and_communicate_copy_indices. X-Git-Tag: v9.0.0-rc1~896^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=046ca5334bfbece40afc947ee2fc4d16c8cf9cbc;p=dealii.git Clean up code in MGLevelGlobalTransfer::fill_and_communicate_copy_indices. --- diff --git a/source/multigrid/mg_level_global_transfer.cc b/source/multigrid/mg_level_global_transfer.cc index 49603c7b09..d7c8ffdb3f 100644 --- a/source/multigrid/mg_level_global_transfer.cc +++ b/source/multigrid/mg_level_global_transfer.cc @@ -51,13 +51,14 @@ MGLevelGlobalTransfer::fill_and_communicate_copy_indices copy_indices_global_mine, copy_indices_level_mine); // check if we can run a plain copy operation between the global DoFs and - // the finest level. - perform_plain_copy = + // the finest level, on the current processor. + bool + my_perform_plain_copy = (copy_indices.back().size() == mg_dof.locally_owned_dofs().n_elements()) && (mg_dof.locally_owned_dofs().n_elements() == mg_dof.locally_owned_mg_dofs(mg_dof.get_triangulation().n_global_levels()-1).n_elements()); - if (perform_plain_copy) + if (my_perform_plain_copy) { AssertDimension(copy_indices_global_mine.back().size(), 0); AssertDimension(copy_indices_level_mine.back().size(), 0); @@ -68,19 +69,23 @@ MGLevelGlobalTransfer::fill_and_communicate_copy_indices for (unsigned int i=0; i *ptria = - dynamic_cast *> - (&mg_dof.get_triangulation()); - const MPI_Comm mpi_communicator = ptria != nullptr ? ptria->get_communicator() : - MPI_COMM_SELF; - perform_plain_copy = - Utilities::MPI::min(static_cast(perform_plain_copy), - mpi_communicator); + // now do a global reduction over all processors to see what operation + // they can agree upon + if (const parallel::Triangulation *ptria = + dynamic_cast *> + (&mg_dof.get_triangulation())) + perform_plain_copy = + (Utilities::MPI::min(my_perform_plain_copy ? 1 : 0, + ptria->get_communicator()) + == + 1); + else + perform_plain_copy = my_perform_plain_copy; }