Number of iterations of the CG method

Barry Smith bsmith at mcs.anl.gov
Fri Jan 25 19:40:33 CST 2008


   With PETSc to do this simply run with the option -ksp_monitor.

   The first few residual norms should be VERY similar; eventually  
since it is likely the order of the floating
point operations is different between your code and PETSc they will  
eventually be a bit different. But you should
see the exact, or almost the exact same number of iterations.

    Barry

On Jan 25, 2008, at 6:38 PM, Mads Hoel wrote:

> 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 gmail.com> wrote:
>
>> This sounds like the stopping criteria are different.
>>
>>  Matt
>>
>> On Jan 25, 2008 5:28 PM, USUARIO INICIAL <ronanrmo at ig.com.br> 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