+
+ */
+
+
+ //
+ //
+ //version to control the error
+ {
+
+ Vec x2;
+ Vec sol;
+ VecDuplicate(ff,&x2);
+ VecDuplicate(ff,&sol);
+
+ PetscScalar norm=100;
+ PetscScalar T1,T2;
+ PetscInt total,its;
+ ierr = KSPSetTolerances(ksp_E,1e-10,1e-10,PETSC_DEFAULT,30);CHKERRQ(ierr);
+ ierr = KSPSetInitialGuessNonzero(ksp_E, PETSC_TRUE); CHKERRQ(ierr);
+ T1 = MPI_Wtime();
+ while(norm>1e-3) {
+ ierr = KSPSolve(ksp_E,ff,x2);CHKERRQ(ierr);
+ KSPGetResidualNorm(ksp_E,&norm);
+ ierr = KSPGetIterationNumber(ksp_E, &its); CHKERRQ(ierr);
+ total += its;
+ ierr = PetscPrintf(PETSC_COMM_WORLD, "Norm of error %g\n", norm); CHKERRQ(ierr);
+ }
+
+ T2 = MPI_Wtime();
+
+ MatMult(A,x2,sol);
+ VecAXPY(sol,-1,ff);
+ VecNorm(sol, NORM_2, &norm);
+ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed norm of error %g iterations %D\n",(double)norm,total);CHKERRQ(ierr);
+ ierr = PetscPrintf(PETSC_COMM_WORLD, "\t\t\t -- Execution time NORMAL GMRES : %g (s)\n\n\n", T2-T1); CHKERRQ(ierr);
+
+ ierr = KSPDestroy(&ksp_E);CHKERRQ(ierr);
+ ierr = VecDestroy(&x2);CHKERRQ(ierr);
+ ierr = VecDestroy(&sol);CHKERRQ(ierr);
+ }
+
+
+
+
+ /*