diff --git a/Numeric/fullMatrix.h b/Numeric/fullMatrix.h index aedad7f1e31118744106e07e6087d08147fcb603..184ed22064b6e82b84a864f87c8b4e8f2c79a552 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 876f9aa74bc115cf7e25a688ffedfd2a1248ebc6..69634f6ffbb33a9df1956bbaaf3fa26323491117 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 33e83d5f75a59642db04b8e610a09440b4fd8bb0..1972c4705e41ffd7884d36a92130cbbf00a7055a 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));