From 1fa75f43d664c1533f2f2108d740ac45aba6dc19 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 30 Oct 2017 15:14:19 -0400 Subject: [PATCH] check number of active cells in shared::Tria part of #5359 --- source/distributed/shared_tria.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source/distributed/shared_tria.cc b/source/distributed/shared_tria.cc index 681554f27d..7ffb864b7f 100644 --- a/source/distributed/shared_tria.cc +++ b/source/distributed/shared_tria.cc @@ -57,6 +57,18 @@ namespace parallel template void Triangulation::partition() { +#ifdef DEBUG + // Check that all meshes are the same (or at least have the same + // total number of active cells): + const unsigned int max_active_cells + = Utilities::MPI::max(this->n_active_cells(), this->get_communicator()); + Assert(max_active_cells == this->n_active_cells(), + ExcMessage("A parallel::shared::Triangulation needs to be refined in the same" + "way on all processors, but the participating processors don't " + "agree on the number of active cells.")) +#endif + + if (settings & partition_metis) { dealii::GridTools::partition_triangulation (this->n_subdomains, *this); @@ -183,11 +195,8 @@ namespace parallel if (cell->is_locally_owned()) n_my_cells += 1; - unsigned int total_cells; - int ierr = MPI_Allreduce (&n_my_cells, &total_cells, 1, - MPI_UNSIGNED, MPI_SUM, this->get_communicator()); - AssertThrowMPI(ierr); - + const unsigned int total_cells + = Utilities::MPI::sum(n_my_cells, this->get_communicator()); Assert(total_cells == this->n_active_cells(), ExcMessage("Not all cells are assigned to a processor.")) } @@ -204,10 +213,8 @@ namespace parallel if (cell->is_locally_owned_on_level()) n_my_cells += 1; - unsigned int total_cells; - int ierr = MPI_Allreduce (&n_my_cells, &total_cells, 1, MPI_UNSIGNED, MPI_SUM, this->get_communicator()); - AssertThrowMPI(ierr); - + const unsigned int total_cells + = Utilities::MPI::sum(n_my_cells, this->get_communicator()); Assert(total_cells == this->n_cells(), ExcMessage("Not all cells are assigned to a processor.")) } -- 2.39.5