From 1f72195352755b0bc4bb92a563a9b7d534dece9d Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Tue, 20 Sep 2005 09:44:31 +0000 Subject: [PATCH] Implementation of get_n_mpi_processes and get_this_mpi_process in the namespace Utilities::System. git-svn-id: https://svn.dealii.org/trunk@11478 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/utilities.h | 24 +++++++++++++++++++++++- deal.II/base/source/utilities.cc | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index c154052883..318544cc68 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -18,7 +18,9 @@ #include #include - +#ifdef DEAL_II_USE_PETSC +#include +#endif /** * A namespace for utility functions that are not particularly specific to @@ -134,6 +136,26 @@ namespace Utilities * Return the present time as HH:MM:SS. */ std::string get_time (); + +#ifdef DEAL_II_USE_PETSC + /** + * Return the number of MPI + * processes there exist. + */ + unsigned int get_n_mpi_processes (const MPI_Comm &mpi_communicator); + + /** + * Return the number of the + * present MPI process in the + * space of processes. This will + * be a unique value for each + * process between zero and (less + * than) the number of all + * processes (given by + * get_n_mpi_processes()). + */ + unsigned int get_this_mpi_process (const MPI_Comm &mpi_communicator); +#endif // DEAL_II_USE_PETSC } } diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 2fbac8bfe0..182b4ee60b 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -334,6 +334,25 @@ namespace Utilities return o.str(); } +#ifdef DEAL_II_USE_PETSC + unsigned int get_n_mpi_processes ( + const MPI_Comm &mpi_communicator) + { + int n_jobs=1; + MPI_Comm_size (mpi_communicator, &n_jobs); + + return n_jobs; + } + + unsigned int get_this_mpi_process ( + const MPI_Comm &mpi_communicator) + { + int rank=0; + MPI_Comm_rank (mpi_communicator, &rank); + + return rank; + } +#endif } } -- 2.39.5