]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implementation of get_n_mpi_processes and get_this_mpi_process in the namespace Utili...
authorRalf Hartmann <Ralf.Hartmann@dlr.de>
Tue, 20 Sep 2005 09:44:31 +0000 (09:44 +0000)
committerRalf Hartmann <Ralf.Hartmann@dlr.de>
Tue, 20 Sep 2005 09:44:31 +0000 (09:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@11478 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/utilities.h
deal.II/base/source/utilities.cc

index c1540528834f8c8d2f6676c914c4c7da6d570f9e..318544cc685270dc89451766a686acda4c1c4ddd 100644 (file)
@@ -18,7 +18,9 @@
 #include <vector>
 #include <string>
 
-
+#ifdef DEAL_II_USE_PETSC
+#include <petscvec.h>
+#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    
   }
 }
 
index 2fbac8bfe0aff2f479adec8adf503c8665c56344..182b4ee60b8299371bca74e07b85e82c781c9b1c 100644 (file)
@@ -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    
   }
   
 }

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.