]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Unify interfaces for parallel objects. Fix a bug where passed the wrong communicator.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 25 Mar 2004 04:42:20 +0000 (04:42 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 25 Mar 2004 04:42:20 +0000 (04:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@8871 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h
deal.II/lac/include/lac/petsc_parallel_vector.h
deal.II/lac/source/petsc_parallel_vector.cc

index cbdb05b9caefb0e0ad21d1017eada1d0d506734b..b2fb281a07def3351ce4ab2ec40e1e3d876a56c3 100644 (file)
@@ -24,7 +24,6 @@
 #include <vector>
 
 
-//TODO: How does a matrix or vector get its communicator if zero-initialized and later reinit'ed?
 
 namespace PETScWrappers
 {
@@ -75,12 +74,12 @@ namespace PETScWrappers
                                           * this flag has been set. The default
                                           * value of this flag is @p{false}.
                                           */
-        SparseMatrix (const MPI_Comm    &communicator,
-                      const unsigned int m,
-                      const unsigned int n,
-                      const unsigned int local_rows,
-                      const unsigned int n_nonzero_per_row,
-                      const bool         is_symmetric = false);
+        SparseMatrix (const MPI_Comm     &communicator,
+                      const unsigned int  m,
+                      const unsigned int  n,
+                      const unsigned int  local_rows,
+                      const unsigned int  n_nonzero_per_row,
+                      const bool          is_symmetric = false);
 
                                          /**
                                           * Initialize a rectangular matrix with
@@ -111,7 +110,7 @@ namespace PETScWrappers
         SparseMatrix (const MPI_Comm                  &communicator,
                       const unsigned int               m,
                       const unsigned int               n,
-                      const unsigned int local_rows,
+                      const unsigned int               local_rows,
                       const std::vector<unsigned int> &row_lengths,
                       const bool                       is_symmetric = false);
 
@@ -131,12 +130,12 @@ namespace PETScWrappers
                                           * the same argument list as the
                                           * present function.
                                           */
-        void reinit (const MPI_Comm    &communicator,
-                     const unsigned int m,
-                     const unsigned int n,
-                     const unsigned int local_rows,
-                     const unsigned int n_nonzero_per_row,
-                     const bool         is_symmetric = false);
+        void reinit (const MPI_Comm     &communicator,
+                     const unsigned int  m,
+                     const unsigned int  n,
+                     const unsigned int  local_rows,
+                     const unsigned int  n_nonzero_per_row,
+                     const bool          is_symmetric = false);
 
                                          /**
                                           * Throw away the present matrix and
@@ -173,7 +172,7 @@ namespace PETScWrappers
                                           */
         void do_reinit (const unsigned int               m,
                         const unsigned int               n,
-                        const unsigned int local_rows,
+                        const unsigned int               local_rows,
                         const std::vector<unsigned int> &row_lengths,
                         const bool                       is_symmetric = false);
 
index 8dd0bc41ebabfaf8ad7b6fff13151e03746f0460..2c3f9bd774bb9acc4b61aa0d369dded74a2e3e12 100644 (file)
@@ -58,9 +58,18 @@ namespace PETScWrappers
       
                                          /**
                                           * Constructor. Set dimension to
-                                          * @p{n} and initialize all
+                                          * @p n and initialize all
                                           * elements with zero.
                                           *
+                                          * @arg local_size denotes the size
+                                          * of the chunk that shall be stored
+                                          * on the present process.
+                                          *
+                                          * @arg communicator denotes the MPI
+                                          * communicator over which the
+                                          * different parts of the vector
+                                          * shall communicate
+                                          * 
                                           * The constructor is made explicit
                                           * to avoid accidents like this:
                                           * @p{v=0;}. Presumably, the user
@@ -71,29 +80,47 @@ namespace PETScWrappers
                                           * vector is replaced by one of
                                           * length zero.
                                           */
-        explicit Vector (const unsigned int n,
-                         const unsigned int local_size,
-                         const MPI_Comm    &communicator);
+        explicit Vector (const MPI_Comm     &communicator,
+                         const unsigned int  n,
+                         const unsigned int  local_size);
     
                                          /**
                                           * Copy-constructor from deal.II
                                           * vectors. Sets the dimension to that
                                           * of the given vector, and copies all
                                           * elements.
+                                          * 
+                                          * @arg local_size denotes the size
+                                          * of the chunk that shall be stored
+                                          * on the present process.
+                                          *
+                                          * @arg communicator denotes the MPI
+                                          * communicator over which the
+                                          * different parts of the vector
+                                          * shall communicate
                                           */
         template <typename Number>
-        explicit Vector (const ::Vector<Number> &v,
-                         const unsigned int      local_size,
-                         const MPI_Comm         &communicator);
+        explicit Vector (const MPI_Comm         &communicator,
+                         const ::Vector<Number> &v,
+                         const unsigned int      local_size);
 
                                          /**
                                           * Copy-constructor the
                                           * values from a PETSc wrapper vector
                                           * class.
+                                          * 
+                                          * @arg local_size denotes the size
+                                          * of the chunk that shall be stored
+                                          * on the present process.
+                                          *
+                                          * @arg communicator denotes the MPI
+                                          * communicator over which the
+                                          * different parts of the vector
+                                          * shall communicate
                                           */
-        explicit Vector (const VectorBase &v,
-                         const unsigned int local_size,
-                         const MPI_Comm    &communicator);
+        explicit Vector (const MPI_Comm     &communicator,
+                         const VectorBase   &v,
+                         const unsigned int  local_size);
 
                                          /**
                                           * Copy the given vector. Resize the
@@ -158,10 +185,10 @@ namespace PETScWrappers
                                           * elements are left an unspecified
                                           * state.
                                           */ 
-        void reinit (const unsigned int N,
-                     const unsigned int local_size,
-                     const MPI_Comm    &communicator,
-                     const bool         fast = false);
+        void reinit (const MPI_Comm     &communicator,
+                     const unsigned int  N,
+                     const unsigned int  local_size,
+                     const bool          fast = false);
     
                                          /**
                                           * Change the dimension to that of
@@ -207,9 +234,9 @@ namespace PETScWrappers
 
 
     template <typename number>
-    Vector::Vector (const ::Vector<number> &v,
-                    const unsigned int      local_size,
-                    const MPI_Comm         &communicator)
+    Vector::Vector (const MPI_Comm         &communicator,
+                    const ::Vector<number> &v,
+                    const unsigned int      local_size)
                     :
                     communicator (communicator)
     {
index 89e24bb5d76a62b7918c9ac94ff2d4466f352cdb..733190a24615a3a91e2eb826d99c31ab0c4ff361 100644 (file)
@@ -38,9 +38,9 @@ namespace PETScWrappers
 
 
 
-    Vector::Vector (const unsigned int n,
-                    const unsigned int local_size,
-                    const MPI_Comm    &communicator)
+    Vector::Vector (const MPI_Comm    &communicator,
+                    const unsigned int n,
+                    const unsigned int local_size)
                     :
                     communicator (communicator)
     {
@@ -49,9 +49,9 @@ namespace PETScWrappers
 
   
 
-    Vector::Vector (const VectorBase &v,
-                    const unsigned int local_size,
-                    const MPI_Comm    &communicator)
+    Vector::Vector (const MPI_Comm    &communicator,
+                    const VectorBase  &v,
+                    const unsigned int local_size)
                     :
                     communicator (communicator)
     {
@@ -63,9 +63,9 @@ namespace PETScWrappers
   
 
     void
-    Vector::reinit (const unsigned int n,
+    Vector::reinit (const MPI_Comm    &comm,
+                    const unsigned int n,
                     const unsigned int local_sz,
-                    const MPI_Comm    &comm,
                     const bool         fast)
     {
       communicator = comm;
@@ -115,8 +115,11 @@ namespace PETScWrappers
       Assert (local_size <= n, ExcIndexRange (local_size, 0, n));
 
       const int ierr
-        = VecCreateMPI (PETSC_COMM_SELF, local_size, n, &vector);
+        = VecCreateMPI (communicator, local_size, PETSC_DETERMINE,
+                        &vector);
       AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      Assert (size() == n, ExcInternalError());
     }
 
   }

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.