From 37fb8e449697de4691321c4d70fae4eabfaf6b4e Mon Sep 17 00:00:00 2001 From: heister Date: Thu, 30 May 2013 20:06:25 +0000 Subject: [PATCH] add PETSc matrix copy_from git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29670 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/lac/petsc_parallel_sparse_matrix.h | 7 +++++++ deal.II/source/lac/petsc_parallel_sparse_matrix.cc | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h b/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h index 7eb8b9d087..93c04f4371 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@ -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 diff --git a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc index 405bc0c2bf..ecc5dac544 100644 --- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc @@ -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, -- 2.39.5