]> https://gitweb.dealii.org/ - dealii.git/commitdiff
check number of active cells in shared::Tria 5362/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 30 Oct 2017 19:14:19 +0000 (15:14 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 31 Oct 2017 19:50:40 +0000 (15:50 -0400)
part of #5359

source/distributed/shared_tria.cc

index 681554f27d8c765455fd93bb2539f615257f2008..7ffb864b7fa4ce1d19d93be0474caba252f04959 100644 (file)
@@ -57,6 +57,18 @@ namespace parallel
     template <int dim, int spacedim>
     void Triangulation<dim,spacedim>::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."))
         }

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.