From b0d3cf316abc1489abb54684330f82081b44e3c4 Mon Sep 17 00:00:00 2001
From: Peter Gottschling <peter.gottschling@simunova.com>
Date: Wed, 16 Sep 2009 15:56:26 +0000
Subject: [PATCH] =?UTF-8?q?Matrixausschriften=20als=20Kommentare;=20Iterat?=
 =?UTF-8?q?ionszahlen=20und=20Fehlercode=20k=C3=B6nnen=20abgefragt=20werde?=
 =?UTF-8?q?n.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 AMDiS/src/ITL_OEMSolver.h |  8 ++++++--
 AMDiS/src/OEMSolver.h     | 24 ++++++++++++++++++++++++
 AMDiS/src/UmfPackSolver.h |  2 ++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/AMDiS/src/ITL_OEMSolver.h b/AMDiS/src/ITL_OEMSolver.h
index ecaa854d..7c2245f7 100644
--- a/AMDiS/src/ITL_OEMSolver.h
+++ b/AMDiS/src/ITL_OEMSolver.h
@@ -74,7 +74,9 @@ namespace AMDiS {
       if (one_norm(x) > 1e100)
 	  x= 0.0;
 #endif 
-      return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter);
+      error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter);
+      iterations= iter.iterations();
+      return error;
     }
 
 
@@ -124,7 +126,9 @@ namespace AMDiS {
     {
 	itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, 
 					       this->tolerance, this->print_cycle);
-	return ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell);
+	error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell);
+	iterations= iter.iterations();
+	return error;
     }
 
     class Creator : public OEMSolverCreator
diff --git a/AMDiS/src/OEMSolver.h b/AMDiS/src/OEMSolver.h
index e5b6fb13..6f00a4c0 100644
--- a/AMDiS/src/OEMSolver.h
+++ b/AMDiS/src/OEMSolver.h
@@ -64,6 +64,8 @@ namespace AMDiS {
 	info(0),
 	residual(0),
 	print_cycle(100),
+	iterations(-1),
+	error(-1),
 	leftPrecon(NULL),
 	rightPrecon(NULL)
     {}
@@ -132,6 +134,7 @@ namespace AMDiS {
 	counter++;
       }
 	
+      // std::cout << "Iterative Solver: A = \n" << A.getMatrix();
       int r = solveSystem(A.getMatrix(), xx, bb);
 
       // Copy solution vector to DOFVector
@@ -164,6 +167,7 @@ namespace AMDiS {
       }
 
       // Solver on DOFVector for single system
+      std::cout << "Iterative Solver (System): A = \n" << A.getMatrix();
       int r= solveSystem(A.getMatrix(), xx, bb);
 
       for (int i = 0, counter = 0; i < ns; i++) {
@@ -227,6 +231,18 @@ namespace AMDiS {
       max_iter = i;
     }
 
+    /// Returns number of iterations in last run of an iterative solver
+    inline int getIterations() 
+    {
+	return iterations;
+    }
+
+    /// Returns error code in last run of an iterative solver
+    inline int getErrorCode() 
+    {
+	return error;
+    }
+
     /// Sets \ref info
     inline void setInfo(int i) 
     {
@@ -257,8 +273,16 @@ namespace AMDiS {
     /// Print cycle, after how many iterations the residuum norm is logged.
     int print_cycle;
 
+    /// How many iterations were performed in last solver (not set by UmfPack)
+    int iterations;
+
+    /// Error code  in last solver (not set by UmfPack)
+    int error;
+
+    /// Left preconditioner (ignored by some iterative solvers and by UmfPack)
     ITL_BasePreconditioner *leftPrecon;
 
+    /// Right preconditioner (ignored by some iterative solvers and by UmfPack)
     ITL_BasePreconditioner *rightPrecon;
   };
 
diff --git a/AMDiS/src/UmfPackSolver.h b/AMDiS/src/UmfPackSolver.h
index 634fbce7..8bb6ae05 100644
--- a/AMDiS/src/UmfPackSolver.h
+++ b/AMDiS/src/UmfPackSolver.h
@@ -87,6 +87,8 @@ namespace AMDiS {
 	    solver->update_numeric();
 	else
 	    solver->update();
+	
+	// std::cout << "UmfPackSolver: A = \n" << A << "\n";
 	int code= (*solver)(x, b);
 	mtl::dense_vector<value_type> r= b - A * x;
 	std::cout << "UmfPackSolver: ||b-Ax|| = " << two_norm(r) << "\n";
-- 
GitLab