]> https://gitweb.dealii.org/ - dealii.git/commitdiff
implement PETScWrappers::MPI::SparseMatrix::reinit
authorTimo Heister <timo.heister@gmail.com>
Mon, 12 Jan 2015 16:26:49 +0000 (11:26 -0500)
committerTimo Heister <timo.heister@gmail.com>
Mon, 12 Jan 2015 18:10:34 +0000 (13:10 -0500)
include/deal.II/lac/petsc_parallel_sparse_matrix.h
source/lac/petsc_parallel_sparse_matrix.cc

index 1b7df5c61c465c7470db1049a9ef8589834bfacd..8830fc83380fc11e57f72c6f1cdf21378b463656 100644 (file)
@@ -325,6 +325,12 @@ namespace PETScWrappers
                    const SparsityType         &sparsity_pattern,
                    const MPI_Comm                  &communicator);
 
+      /**
+       * Initialize this matrix to have the same structure as @p other. This will not copy
+       * the values of the other matrix, but you can use copy_from() for this.
+       */
+      void reinit (const SparseMatrix &other);
+
       /**
        * Return a reference to the MPI communicator object in use with this
        * matrix.
index d488abb7d1639a929084e94bad30020e58ef52fc..6ab9194223635a1163aa8507dbd24bdbe778c3fd 100644 (file)
@@ -106,6 +106,27 @@ namespace PETScWrappers
     }
 
 
+    void
+    SparseMatrix::
+    reinit (const SparseMatrix &other)
+    {
+      if (&other == this)
+        return;
+
+      this->communicator = other.communicator;
+
+      int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+      ierr = MatDestroy (matrix);
+#else
+      ierr = MatDestroy (&matrix);
+#endif
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      ierr = MatDuplicate(other.matrix, MAT_DO_NOT_COPY_VALUES, &matrix);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+    }
+
 
     SparseMatrix &
     SparseMatrix::operator = (const value_type d)

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.