Number of iterations of the CG method

Mads Hoel mfhoel at
Fri Jan 25 18:38:08 CST 2008

Do you use the same starting vector in both cases? You can look at the  
residual, check it after each iteration. You can also try to let PETSc use  
the same convergence test/monitor.

On Sat, 26 Jan 2008 00:35:04 +0100, Matthew Knepley <knepley at>  

> This sounds like the stopping criteria are different.
>   Matt
> On Jan 25, 2008 5:28 PM, USUARIO INICIAL <ronanrmo at> wrote:
>> I have a conjugate gradient implemented in C without Petsc and when I
>> solve the linear system of my problem (an elliptic pde) it converges
>> with something about 270 iterations. But with Petsc (ksp_type cg
>> pc_type none) the same linear system converges with 510 iterations.
>> Do someone have any idea why is that happenning?
>> I already checked the matrix and they are equal. The results are quite
>> close and I set the same tolerance to both methods (setting rtol on
>> petsc to a very small number, to use only atol). And besides the
>> number of iterations, the time spent by petsc is not much more than
>> the other method.
>> Thanks,
>> Ronan
>> I'm sorry, I dont know english very well, I did the best I could.

Mads Hoel

More information about the petsc-users mailing list