From 03ba48aa4f7a7e39baac9e542b39a0927dd62a6a Mon Sep 17 00:00:00 2001
From: Emilie Marchandise <emilie.marchandise@uclouvain.be>
Date: Fri, 13 Aug 2010 15:19:19 +0000
Subject: [PATCH] Temporal stokes ok

---
 Numeric/fullMatrix.h         | 8 ++++++++
 Solver/linearSystemPETSc.cpp | 2 ++
 Solver/linearSystemPETSc.h   | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Numeric/fullMatrix.h b/Numeric/fullMatrix.h
index aedad7f1e3..184ed22064 100644
--- a/Numeric/fullMatrix.h
+++ b/Numeric/fullMatrix.h
@@ -123,6 +123,14 @@ class fullMatrix
     #endif
     (*this)(r, c) = v; 
   }
+  inline scalar norm()
+  {
+    scalar n = 0.;
+    for(int i = 0; i < _r; ++i) 
+      for(int j = 0; j < _c; ++j) 
+	n += (*this)(i, j) * (*this)(i, j);
+    return sqrt(n);
+  }
   fullMatrix(scalar *original, int r, int c)
   {
     _r = r;
diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp
index 876f9aa74b..69634f6ffb 100644
--- a/Solver/linearSystemPETSc.cpp
+++ b/Solver/linearSystemPETSc.cpp
@@ -82,6 +82,8 @@ void linearSystemPETSc<fullMatrix<PetscScalar> >::allocate(int nbRows)
   if (_blockSize == 0)
     Msg::Error ("'blockSize' parameters must be set for linearSystemPETScBlock");
   clear();
+  //printf("allocate linear system petsc \n");
+  //_try(PetscOptionsInsertString("-ksp_monitor_true_residual -ksp_rtol 1e-10"));
   _try(MatCreate(PETSC_COMM_WORLD, &_a)); 
   _try(MatSetSizes(_a, PETSC_DECIDE, PETSC_DECIDE, nbRows * _blockSize, nbRows * _blockSize));
   _try(MatSetType(_a, MATSEQBAIJ));
diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h
index 33e83d5f75..1972c4705e 100644
--- a/Solver/linearSystemPETSc.h
+++ b/Solver/linearSystemPETSc.h
@@ -55,7 +55,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
     PC pc;
     _try(KSPGetPC(_ksp, &pc));
     // set some default options
-    _try(PCSetType(pc, PCILU));
+    _try(PCSetType(pc, PCLU));//LU for direct solver and PCILU for indirect solver
     _try(PCFactorSetMatOrderingType(pc, MATORDERING_RCM));
     _try(PCFactorSetLevels(pc, 1));
     _try(KSPSetTolerances(_ksp, 1.e-8, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT));
-- 
GitLab