From c792b7105570da1bc4b30fa5b279a76433cbc4a9 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 29 Apr 2004 17:40:49 +0000 Subject: [PATCH] PETScWrappers::MatrixBase::clear git-svn-id: https://svn.dealii.org/trunk@9123 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/petsc_matrix_base.h | 8 ++++++++ deal.II/lac/source/petsc_matrix_base.cc | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) 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 () { -- 2.39.5