From 20e1adb5525b9224e32782e9e4dde636264d6ffa Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Fri, 23 Oct 2009 09:21:02 +0000
Subject: [PATCH] Small changes in solver interface the get the residual.

---
 AMDiS/src/DOFMatrix.cc         |  4 ++--
 AMDiS/src/ITL_OEMSolver.h      | 21 +++++++--------------
 AMDiS/src/ITL_Preconditioner.h |  2 +-
 AMDiS/src/Mesh.cc              |  2 +-
 AMDiS/src/OEMSolver.h          |  8 ++++----
 AMDiS/src/ProblemScal.cc       | 12 ++----------
 6 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/AMDiS/src/DOFMatrix.cc b/AMDiS/src/DOFMatrix.cc
index 1191824c..4f60974c 100644
--- a/AMDiS/src/DOFMatrix.cc
+++ b/AMDiS/src/DOFMatrix.cc
@@ -197,9 +197,9 @@ namespace AMDiS {
 	if (condition->applyBoundaryCondition()) {
 #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
  	  if (rankDofs[rowIndices[i]]) 
- 	    applyDBCs.insert(static_cast<int>(rowIndices[i]));
+ 	    applyDBCs.insert(static_cast<int>(row));
 #else
-	  applyDBCs.insert(static_cast<int>(rowIndices[i]));
+	  applyDBCs.insert(static_cast<int>(row));
 #endif
 	}
       } else {
diff --git a/AMDiS/src/ITL_OEMSolver.h b/AMDiS/src/ITL_OEMSolver.h
index 152faa9f..b2a859e3 100644
--- a/AMDiS/src/ITL_OEMSolver.h
+++ b/AMDiS/src/ITL_OEMSolver.h
@@ -64,18 +64,10 @@ namespace AMDiS {
     {
       itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, 
 					     this->tolerance, this->print_cycle);
-#if 0
-      std::cout << "A is " << num_rows(A) << " x " << num_cols(A)
-		<< ", one_norm(A) = " << one_norm(A)
-		<< ", b is " << num_rows(b) 
-		<< ", one_norm(b) = " << one_norm(b)
-		<< ", x is " << num_rows(x)
-		<< ", one_norm(x) = " << one_norm(x) << "\n";
-      if (one_norm(x) > 1e100)
-	  x= 0.0;
-#endif 
-      error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter);
-      iterations= iter.iterations();
+
+      error = ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter);
+      iterations = iter.iterations();
+      residual = iter.resid();
       return error;
     }
 
@@ -127,8 +119,9 @@ namespace AMDiS {
     {
 	itl::cyclic_iteration<value_type> iter(b, this->max_iter, this->relative, 
 					       this->tolerance, this->print_cycle);
-	error= ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell);
-	iterations= iter.iterations();
+	error = ITLSolver()(A, x, b, *this->leftPrecon, *this->rightPrecon, iter, ell);
+	iterations = iter.iterations();
+	residual = iter.resid();
 	return error;
     }
 
diff --git a/AMDiS/src/ITL_Preconditioner.h b/AMDiS/src/ITL_Preconditioner.h
index 91bcf146..2acd6a48 100644
--- a/AMDiS/src/ITL_Preconditioner.h
+++ b/AMDiS/src/ITL_Preconditioner.h
@@ -142,7 +142,7 @@ namespace AMDiS {
       : public ITL_Preconditioner<itl::pc::identity<DOFMatrix::base_matrix_type> >
   {
       typedef ITL_Preconditioner<itl::pc::identity<DOFMatrix::base_matrix_type> > base;
-
+  public:
       IdentityPreconditioner(const DOFMatrix::base_matrix_type& A) : base(A) {}
   };
 
diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc
index f411a43f..d763d661 100644
--- a/AMDiS/src/Mesh.cc
+++ b/AMDiS/src/Mesh.cc
@@ -474,7 +474,7 @@ namespace AMDiS {
       traverse(-1, fill_flag, newDOFFct2);
       
       newDOF.resize(0);
-    }   
+    }       
   }
 
 
diff --git a/AMDiS/src/OEMSolver.h b/AMDiS/src/OEMSolver.h
index 356963f4..ad4fb7aa 100644
--- a/AMDiS/src/OEMSolver.h
+++ b/AMDiS/src/OEMSolver.h
@@ -182,25 +182,25 @@ namespace AMDiS {
      */
 
     /// Returns solvers \ref name.
-    inline std::string getName() 
+    inline std::string getName() const
     { 
       return name; 
     }
 
     /// Returns \ref tolerance
-    inline double getTolerance() 
+    inline double getTolerance() const
     {
       return tolerance;
     }  
 
     /// Returns \ref max_iter
-    inline int getMaxIterations() 
+    inline int getMaxIterations() const
     {
       return max_iter;
     }
 
     /// Returns \ref residual
-    inline double getResidual() 
+    inline double getResidual() const
     {
       return residual;
     }
diff --git a/AMDiS/src/ProblemScal.cc b/AMDiS/src/ProblemScal.cc
index 4e35e06d..47c2d0ec 100644
--- a/AMDiS/src/ProblemScal.cc
+++ b/AMDiS/src/ProblemScal.cc
@@ -587,9 +587,8 @@ namespace AMDiS {
     }
 
     systemMatrix->removeRowsWithDBC(systemMatrix->getApplyDBCs());
-
     systemMatrix->finishInsertion();
-  
+
     // TODO: ExitMatrix should be called after finishInsertion!
     if (systemMatrix->getBoundaryManager())
       systemMatrix->getBoundaryManager()->exitMatrix(systemMatrix);
@@ -599,14 +598,7 @@ namespace AMDiS {
       solution->getBoundaryManager()->exitVector(solution);
 
     INFO(info, 8)("buildAfterCoarsen needed %.5f seconds\n", TIME_USED(first,clock()));
-
-#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
-//     PetscErrorCode ierr;
-//     Mat A;
-
-//     ierr = MatCreate(PETSC_COMM_WORLD, &A); CHKERRQ(ierr);
-#endif
-  
+ 
     createPrecon();
   }
 
-- 
GitLab