X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/GMRES2stage.git/blobdiff_plain/90a7d5a4672d8b4883fce5722939a29439b059d2..704a29e1a3accbeb491a424bc8e02cb8a54dd3b2:/code/ex15.c diff --git a/code/ex15.c b/code/ex15.c index 94c9365..f62763f 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); @@ -475,6 +480,10 @@ int main(int argc,char **args) ierr = PetscOptionsGetInt(NULL,"-m",&m,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,"-n",&n,NULL);CHKERRQ(ierr); + PetscMPIInt size; + MPI_Comm_size(PETSC_COMM_WORLD,&size); + PetscPrintf(PETSC_COMM_WORLD,"Number of processors = %d\n",size); + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrix and right-hand-side vector that define the linear system, Ax = b. @@ -641,7 +650,7 @@ int main(int argc,char **args) } - + /* Free work space. All PETSc objects should be destroyed when they