From 6f72d23a3971907ec4a9600366fd9f89dcd7af8b Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 7 Aug 2009 16:45:16 +0000 Subject: [PATCH] Implement duplicate_map. git-svn-id: https://svn.dealii.org/trunk@19196 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/utilities.h | 20 ++++++++++++++++++++ deal.II/base/source/utilities.cc | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index 5a9476aaed..195e4eb79d 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -29,6 +29,7 @@ typedef int MPI_Comm; #ifdef DEAL_II_USE_TRILINOS # include # include +# include # ifdef DEAL_II_COMPILER_SUPPORTS_MPI # include # else @@ -442,6 +443,25 @@ namespace Utilities * get_n_mpi_processes()). */ unsigned int get_this_mpi_process (const Epetra_Comm &mpi_communicator); + + /** + * Given a Trilinos Epetra map, create a + * new map that has the same subdivision + * of elements to processors but uses the + * given communicator object instead of + * the one stored in the first + * argument. In essence, this means that + * we create a map that communicates + * among the same processors in the same + * way, but using a separate channel. + * + * This function is typically used with a + * communicator that has been obtained by + * the duplicate_communicator() function. + */ + Epetra_Map + duplicate_map (const Epetra_Map &map, + const Epetra_Comm &comm); } #endif diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 0d242560f2..1c0b7108b1 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -645,6 +645,24 @@ namespace Utilities { return (unsigned int)mpi_communicator.MyPID(); } + + + + Epetra_Map + duplicate_map (const Epetra_Map &map, + const Epetra_Comm &comm) + { + // assume that each processor stores a + // contiguous range of elements in the + // following constructor call + Assert (map.LinearMap() == true, + ExcNotImplemented()); + return + Epetra_Map (map.NumGlobalElements(), + map.NumMyElements(), + map.IndexBase(), + comm); + } } #endif -- 2.39.5