]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not use MPI_COMM_WORLD.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 10 Mar 2018 06:10:18 +0000 (07:10 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 10 Mar 2018 06:18:42 +0000 (07:18 +0100)
include/deal.II/multigrid/mg_transfer.h

index b13fb5fb2d34961653b124b8ff4afe6635dd7fd5..2608dedbf805bf6373226b9a5d0ed2f2bf04512a 100644 (file)
@@ -66,9 +66,16 @@ namespace internal
     template <typename SparsityPatternType, typename DoFHandlerType>
     static void reinit(Matrix &matrix, Sparsity &, int level, const SparsityPatternType &sp, DoFHandlerType &dh)
     {
+      const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *dist_tria =
+        dynamic_cast<const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension>*>
+        (&(dh.get_triangulation()));
+      MPI_Comm communicator = dist_tria != nullptr ?
+                              dist_tria->get_communicator() :
+                              MPI_COMM_SELF;
+
       matrix.reinit(dh.locally_owned_mg_dofs(level+1),
                     dh.locally_owned_mg_dofs(level),
-                    sp, MPI_COMM_WORLD, true);
+                    sp, communicator, true);
     }
 
   };
@@ -82,9 +89,15 @@ namespace internal
     template <typename SparsityPatternType, typename DoFHandlerType>
     static void reinit(Matrix &matrix, Sparsity &, int level, const SparsityPatternType &sp, DoFHandlerType &dh)
     {
+      const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *dist_tria =
+        dynamic_cast<const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension>*>
+        (&(dh.get_triangulation()));
+      MPI_Comm communicator = dist_tria != nullptr ?
+                              dist_tria->get_communicator() :
+                              MPI_COMM_SELF;
       matrix.reinit(dh.locally_owned_mg_dofs(level+1),
                     dh.locally_owned_mg_dofs(level),
-                    sp, MPI_COMM_WORLD, true);
+                    sp, communicator, true);
     }
 
   };
@@ -99,9 +112,15 @@ namespace internal
     template <typename SparsityPatternType, typename DoFHandlerType>
     static void reinit(Matrix &matrix, Sparsity &, int level, const SparsityPatternType &sp, DoFHandlerType &dh)
     {
+      const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension> *dist_tria =
+        dynamic_cast<const parallel::Triangulation<DoFHandlerType::dimension,DoFHandlerType::space_dimension>*>
+        (&(dh.get_triangulation()));
+      MPI_Comm communicator = dist_tria != nullptr ?
+                              dist_tria->get_communicator() :
+                              MPI_COMM_SELF;
       matrix.reinit(dh.locally_owned_mg_dofs(level+1),
                     dh.locally_owned_mg_dofs(level),
-                    sp, MPI_COMM_WORLD, true);
+                    sp, communicator, true);
     }
   };
 #endif

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.