]> https://gitweb.dealii.org/ - dealii.git/commitdiff
return MPI_Comm by const ref 9002/head
authorTimo Heister <timo.heister@gmail.com>
Tue, 5 Nov 2019 01:38:50 +0000 (20:38 -0500)
committerTimo Heister <timo.heister@gmail.com>
Tue, 5 Nov 2019 01:38:50 +0000 (20:38 -0500)
Fix a few places where we return the MPI_Comm by value. This is
problematic if we pass it to a function taking a reference and storing
it:

    CollectiveMutex::ScopedLock lock(mutex, tria.get_communicator());

include/deal.II/distributed/tria_base.h
include/deal.II/multigrid/multigrid.h
source/distributed/tria_base.cc

index ffdb86988ff71239d3fdf9fde91e5aa934ba9be2..dbfe8d5cdf4a54c1ad67ee5d68428d69426c95d5 100644 (file)
@@ -93,7 +93,7 @@ namespace parallel
     /**
      * Return MPI communicator used by this triangulation.
      */
-    virtual MPI_Comm
+    virtual const MPI_Comm &
     get_communicator() const;
 
     /**
index 97e8e54390a15beb88a5561344d0d070399219b4..7c738ea95df5dc8843cb276add32b24b64e2765c 100644 (file)
@@ -577,7 +577,7 @@ public:
   /**
    * Return the MPI communicator object in use with this preconditioner.
    */
-  MPI_Comm
+  const MPI_Comm &
   get_mpi_communicator() const;
 
   /**
@@ -929,14 +929,14 @@ PreconditionMG<dim, VectorType, TRANSFER>::locally_owned_domain_indices(
 
 
 template <int dim, typename VectorType, class TRANSFER>
-MPI_Comm
+const MPI_Comm &
 PreconditionMG<dim, VectorType, TRANSFER>::get_mpi_communicator() const
 {
-  // currently parallel GMG works with distributed Triangulation only,
+  // currently parallel GMG works with parallel triangulations only,
   // so it should be a safe bet to use it to query MPI communicator:
   const Triangulation<dim> &tria = dof_handler_vector[0]->get_triangulation();
-  const parallel::distributed::Triangulation<dim> *ptria =
-    dynamic_cast<const parallel::distributed::Triangulation<dim> *>(&tria);
+  const parallel::TriangulationBase<dim> *ptria =
+    dynamic_cast<const parallel::TriangulationBase<dim> *>(&tria);
   Assert(ptria != nullptr, ExcInternalError());
   return ptria->get_communicator();
 }
index ab57bb0e6e8c34b9541c9c46158ce3aab4d1bf8e..1586e61bb0372cae40d6f262a03ba8b72506c5d3 100644 (file)
@@ -167,7 +167,7 @@ namespace parallel
   }
 
   template <int dim, int spacedim>
-  MPI_Comm
+  const MPI_Comm &
   TriangulationBase<dim, spacedim>::get_communicator() const
   {
     return mpi_communicator;

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.