]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add PETSc matrix copy_from
authorTimo Heister <timo.heister@gmail.com>
Thu, 30 May 2013 20:06:25 +0000 (20:06 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 30 May 2013 20:06:25 +0000 (20:06 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29670 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 7eb8b9d087bb05fc3cbb943178e3150aeb242206..93c04f4371853649ec517dc00ce0bf85a2de7af5 100644 (file)
@@ -294,6 +294,13 @@ namespace PETScWrappers
        */
       SparseMatrix &operator = (const value_type d);
 
+
+      /**
+       * Make a copy of the PETSc matrix @p other. It is assumed that both matrices have
+       * the same SparsityPattern.
+       */
+      void copy_from(const SparseMatrix & other);
+
       /**
        * Throw away the present matrix and
        * generate one that has the same
index 405bc0c2bf104b93ebd1a72bafff9aab05a0ad6d..ecc5dac544c1c3dbd9d6102d6c5fed3adeac1a42 100644 (file)
@@ -99,7 +99,17 @@ namespace PETScWrappers
       return *this;
     }
 
+    void
+    SparseMatrix::copy_from (const SparseMatrix &other)
+    {
+      if (&other == this)
+        return;
+
+      this->communicator = other.communicator;
 
+      int ierr = MatCopy(other.matrix, matrix, SAME_NONZERO_PATTERN);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+    }
 
     void
     SparseMatrix::reinit (const MPI_Comm    &communicator,

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.