From 19d014d15589ba4ede503fa39c2c34df8983b963 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 13 May 2009 06:19:08 +0000 Subject: [PATCH] Utilities::duplicate_communicator. git-svn-id: https://svn.dealii.org/trunk@18840 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/utilities.h | 16 +++++++++++++++- deal.II/base/source/utilities.cc | 20 +++++++++++++++++++- deal.II/doc/news/changes.h | 6 +++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index 330e5b9150..72b2a63fff 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2007, 2008 by the deal.II authors +// Copyright (C) 2005, 2006, 2007, 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -248,6 +248,20 @@ namespace Utilities */ unsigned int get_this_mpi_process (const MPI_Comm &mpi_communicator); + /** + * Given a communicator, generate a new + * communicator that contains the same + * set of processors but that has a + * different, unique identifier. + * + * This functionality can be used to + * ensure that different objects, such as + * distributed matrices, each have unique + * communicators over which they can + * interact without interfering with each + * other. + */ + MPI_Comm duplicate_communicator (const MPI_Comm &mpi_communicator); /** * A class that is used to initialize the diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 339365f5e4..4b20cb5dd8 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2008 by the deal.II authors +// Copyright (C) 2005, 2006, 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -485,6 +485,15 @@ namespace Utilities return rank; } + + + MPI_Comm duplicate_communicator (const MPI_Comm &mpi_communicator) + { + MPI_Comm new_communicator; + MPI_Comm_Dup (mpi_communicator, &new_communicator); + return new_communicator; + } + #else @@ -493,10 +502,19 @@ namespace Utilities return 1; } + + unsigned int get_this_mpi_process (const MPI_Comm &) { return 0; } + + + + MPI_Comm duplicate_communicator (const MPI_Comm &mpi_communicator) + { + return mpi_communicator; + } #endif diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 08a44b501c..20c831f10c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -55,6 +55,10 @@ inconvenience this causes.
  1. + New: The new function Utilities::duplicate_communicator can be used + to duplicate an MPI communicator to produce a unique duplicate. +
    + (WB 2009/05/13)

@@ -67,7 +71,7 @@ inconvenience this causes.
  1. - New: The SparseMatrix class has now a function mmult that + New: The SparseMatrix class has now a function SparseMatrix::mmult that can multiply two sparse matrices with each other.
    (Martin Kronbichler 2009/05/04) -- 2.39.5