]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETScWrappers::MatrixBase::clear
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 29 Apr 2004 17:40:49 +0000 (17:40 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 29 Apr 2004 17:40:49 +0000 (17:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@9123 0785d39b-7218-0410-832d-ea1e28bc413d

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

index e4c12249af761426448f92e7131010b3131b3a0b..13e88c9fb194faa06c2eff4fcf15fb9d1f2d93be 100644 (file)
@@ -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
index 2bfdecd78857847e350f7f22ee626fdc655c9615..1f0f0fdffd3e7377852d05293fbb1b65cae76277 100644 (file)
@@ -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 ()
   {

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.