From: wolf Date: Thu, 29 Apr 2004 17:40:49 +0000 (+0000) Subject: PETScWrappers::MatrixBase::clear X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c792b7105570da1bc4b30fa5b279a76433cbc4a9;p=dealii-svn.git PETScWrappers::MatrixBase::clear git-svn-id: https://svn.dealii.org/trunk@9123 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_matrix_base.h b/deal.II/lac/include/lac/petsc_matrix_base.h index e4c12249af..13e88c9fb1 100644 --- a/deal.II/lac/include/lac/petsc_matrix_base.h +++ b/deal.II/lac/include/lac/petsc_matrix_base.h @@ -308,6 +308,14 @@ namespace PETScWrappers */ virtual ~MatrixBase (); + /** + * Release all memory and return + * to a state just like after + * having called the default + * constructor. + */ + void clear (); + /** * Set all matrix entries to zero, but * retain the sparsity pattern and all diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index 2bfdecd788..1f0f0fdffd 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -116,6 +116,22 @@ namespace PETScWrappers + void + MatrixBase::clear () + { + // destroy the matrix... + int ierr = MatDestroy (matrix); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + // ...and replace it by an empty + // sequential matrix + const int m=0, n=0, n_nonzero_per_row=0; + ierr = MatCreateSeqAIJ(PETSC_COMM_SELF, m, n, n_nonzero_per_row, + 0, &matrix); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } + + + void MatrixBase::reinit () {