X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/GMRES2stage.git/blobdiff_plain/12958908db074a04fed4200e347802c16b3c0c01..67de434b39a9f2df1984bae1717a1bd52916f54d:/code/ex15.c diff --git a/code/ex15.c b/code/ex15.c index 1fffcbe..820ec8d 100644 --- a/code/ex15.c +++ b/code/ex15.c @@ -120,13 +120,14 @@ int KrylovMinimize(Mat A, Vec b, Vec x) { //Initializations // ierr = KSPGMRESSetRestart(ksp, 16); CHKERRQ(ierr); - ierr = KSPSetTolerances(ksp, 1e-13, 1e-13, PETSC_DEFAULT, 16); CHKERRQ(ierr); + ierr = KSPSetTolerances(ksp, 1e-13, 1e-13, PETSC_DEFAULT, 30); CHKERRQ(ierr); ierr = KSPSetInitialGuessNonzero(ksp, PETSC_TRUE); CHKERRQ(ierr); //GMRES WITH MINIMIZATION T1 = MPI_Wtime(); + ierr = KSPSetUp(ksp); CHKERRQ(ierr); while(giterEprecision ){ for(col=0; colEprecision; col++){ @@ -310,7 +311,7 @@ int KrylovMinimizeLSQR(Mat A, Vec b, Vec x) { //Initializations // ierr = KSPGMRESSetRestart(ksp, 16); CHKERRQ(ierr); - ierr = KSPSetTolerances(ksp, 1e-13, 1e-13, PETSC_DEFAULT, 16); CHKERRQ(ierr); + ierr = KSPSetTolerances(ksp, 1e-13, 1e-13, PETSC_DEFAULT, 30); CHKERRQ(ierr); ierr = KSPSetInitialGuessNonzero(ksp, PETSC_TRUE); CHKERRQ(ierr); @@ -318,6 +319,7 @@ int KrylovMinimizeLSQR(Mat A, Vec b, Vec x) { //GMRES WITH MINIMIZATION T1 = MPI_Wtime(); + ierr = KSPSetUp(ksp); CHKERRQ(ierr); while(giterEprecision ){ for(col=0; colEprecision; col++){ @@ -515,7 +517,8 @@ int main(int argc,char **args) */ for (Ii=Istart; Ii0) {J = Ii - n; ierr = MatSetValues(A,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);} + PetscScalar v2=-1.; + if (i>0) {J = Ii - n; ierr = MatSetValues(A,1,&Ii,1,&J,&v2,INSERT_VALUES);CHKERRQ(ierr);} if (i0) {J = Ii - 1; ierr = MatSetValues(A,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);} if (j -pc_type -ksp_monitor -ksp_rtol @@ -588,7 +601,7 @@ int main(int argc,char **args) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ PetscScalar T1,T2; T1 = MPI_Wtime(); - ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); + ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); T2 = MPI_Wtime(); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Check solution and clean up