]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix constructor of InverseMatrixRichardson\
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 20 Sep 2005 17:09:27 +0000 (17:09 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 20 Sep 2005 17:09:27 +0000 (17:09 +0000)
catch exceptions in its vmult functions

git-svn-id: https://svn.dealii.org/trunk@11485 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/matrix_lib.h
deal.II/lac/include/lac/matrix_lib.templates.h

index 2a65cff8978dc2582ee13224adb9cbe8e1140f4a..4d99d5f642cb61a01045290e3a71f02d1d9f33b3 100644 (file)
@@ -311,6 +311,8 @@ class MeanValueFilter : public Subscriptor
  */
 template<class VECTOR>
 class InverseMatrixRichardson
+  :
+  public Subscriptor
 {
   public:
                                     /**
@@ -502,8 +504,12 @@ template <class MATRIX, class PRECONDITION>
 inline void
 InverseMatrixRichardson<VECTOR>::initialize (const MATRIX& m, const PRECONDITION& p)
 {
-  matrix = &m;
-  precondition = &p;
+  if (matrix != 0)
+    delete matrix;
+  matrix = new PointerMatrix<MATRIX, VECTOR>(&m);
+  if (precondition != 0)
+    delete precondition;
+  precondition = new PointerMatrix<PRECONDITION, VECTOR>(&p);;
 }
 
 
index e3498494fa0fa1bb2c256786155daf61f3190427..9f4a1f3eaaceb18693aa87c994072f295a5eec53 100644 (file)
@@ -140,7 +140,13 @@ InverseMatrixRichardson<VECTOR>::vmult(VECTOR& dst, const VECTOR& src) const
 {
   Assert (matrix != 0, ExcNotInitialized());
   Assert (precondition != 0, ExcNotInitialized());
-  solver.solve(*matrix, dst, src, *precondition);
+  dst = 0.;
+  try
+    {
+      solver.solve(*matrix, dst, src, *precondition);
+    }
+  catch(...)
+    {}  
 }
 
 
@@ -153,7 +159,12 @@ InverseMatrixRichardson<VECTOR>::vmult_add(VECTOR& dst, const VECTOR& src) const
   Assert (precondition != 0, ExcNotInitialized());
   VECTOR* aux = mem.alloc();
   aux->reinit(dst);
-  solver.solve(*matrix, *aux, src, *precondition);
+  try
+    {
+      solver.solve(*matrix, *aux, src, *precondition);
+    }
+  catch(...)
+    {}  
   dst += *aux;
   mem.free(aux);
 }
@@ -166,7 +177,13 @@ InverseMatrixRichardson<VECTOR>::Tvmult(VECTOR& dst, const VECTOR& src) const
 {
   Assert (matrix != 0, ExcNotInitialized());
   Assert (precondition != 0, ExcNotInitialized());
-  solver.Tsolve(*matrix, dst, src, *precondition);
+  dst = 0.;
+  try
+    {
+      solver.Tsolve(*matrix, dst, src, *precondition);
+    }
+  catch(...)
+    {}  
 }
 
 
@@ -179,7 +196,12 @@ InverseMatrixRichardson<VECTOR>::Tvmult_add(VECTOR& dst, const VECTOR& src) cons
   Assert (precondition != 0, ExcNotInitialized());
   VECTOR* aux = mem.alloc();
   aux->reinit(dst);
-  solver.Tsolve(*matrix, *aux, src, *precondition);
+  try
+    {
+      solver.Tsolve(*matrix, *aux, src, *precondition);
+    }
+  catch(...)
+    {}  
   dst += *aux;
   mem.free(aux);
 }

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.