X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/GMRES2stage.git/blobdiff_plain/90a7d5a4672d8b4883fce5722939a29439b059d2..91273b11316f5330c60a8ab039e3102501f371ce:/code/ex15.c diff --git a/code/ex15.c b/code/ex15.c index 94c9365..7dc050b 100644 --- a/code/ex15.c +++ b/code/ex15.c @@ -120,7 +120,7 @@ int KrylovMinimize(Mat A, Vec b, Vec x) { //Initializations // ierr = KSPGMRESSetRestart(ksp, 16); CHKERRQ(ierr); - ierr = KSPSetTolerances(ksp, 1e-10, 1e-10, PETSC_DEFAULT, 16); CHKERRQ(ierr); + ierr = KSPSetTolerances(ksp, 1e-13, 1e-13, PETSC_DEFAULT, 16); CHKERRQ(ierr); ierr = KSPSetInitialGuessNonzero(ksp, PETSC_TRUE); CHKERRQ(ierr); @@ -146,11 +146,13 @@ int KrylovMinimize(Mat A, Vec b, Vec x) { - //Error + KSPGetResidualNorm(ksp,&norm); + + /* //Error ierr = VecCopy(x, residu); CHKERRQ(ierr); ierr = VecAXPY(residu, -1, x_old); CHKERRQ(ierr); ierr = VecNorm(residu, NORM_INFINITY, &norm); CHKERRQ(ierr); - + */ ierr = PetscPrintf(PETSC_COMM_WORLD, "Norm of error %g, outer iteration %D\n", norm, giter); CHKERRQ(ierr); @@ -335,11 +337,14 @@ int KrylovMinimizeLSQR(Mat A, Vec b, Vec x) { + KSPGetResidualNorm(ksp,&norm); + + /* //Error ierr = VecCopy(x, residu); CHKERRQ(ierr); ierr = VecAXPY(residu, -1, x_old); CHKERRQ(ierr); ierr = VecNorm(residu, NORM_INFINITY, &norm); CHKERRQ(ierr); - + */ ierr = PetscPrintf(PETSC_COMM_WORLD, "Norm of error %g, outer iteration %D\n", norm, giter); CHKERRQ(ierr); @@ -641,7 +646,7 @@ int main(int argc,char **args) } - + /* Free work space. All PETSc objects should be destroyed when they