[petsc-users] KSP has an extra iteration when use shell matrix

Barry Smith bsmith at petsc.dev
Tue Jan 30 11:35:35 CST 2024


  How do I see a difference? What does "hence ruin my previous converged KSP result" mean? A different answer at the end of the KSP solve?

$ ./joe > joe.basic
~/Src/petsc/src/ksp/ksp/tutorials (barry/2023-09-15/fix-log-pcmpi=) arch-fix-log-pcmpi
$ ./joe -ksp_monitor -ksp_converged_reason -snes_monitor > joe.monitor
~/Src/petsc/src/ksp/ksp/tutorials (barry/2023-09-15/fix-log-pcmpi=) arch-fix-log-pcmpi
$ diff joe.basic joe.monitor 
0a1,36
>   0 SNES Function norm 6.041522986797e+00 
>     0 KSP Residual norm 6.041522986797e+00 
>     1 KSP Residual norm 5.065392549852e-16 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   1 SNES Function norm 3.512662245652e+00 
>     0 KSP Residual norm 3.512662245652e+00 
>     1 KSP Residual norm 6.230314124713e-16 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   2 SNES Function norm 8.969285922373e-01 
>     0 KSP Residual norm 8.969285922373e-01 
>     1 KSP Residual norm 0.000000000000e+00 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   3 SNES Function norm 4.863816734540e-01 
>     0 KSP Residual norm 4.863816734540e-01 
>     1 KSP Residual norm 0.000000000000e+00 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   4 SNES Function norm 3.512070785520e-01 
>     0 KSP Residual norm 3.512070785520e-01 
>     1 KSP Residual norm 0.000000000000e+00 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   5 SNES Function norm 2.769700293115e-01 
>     0 KSP Residual norm 2.769700293115e-01 
>     1 KSP Residual norm 1.104778916974e-16 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   6 SNES Function norm 2.055345318150e-01 
>     0 KSP Residual norm 2.055345318150e-01 
>     1 KSP Residual norm 1.535110861002e-17 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   7 SNES Function norm 1.267482220786e-01 
>     0 KSP Residual norm 1.267482220786e-01 
>     1 KSP Residual norm 1.498679601680e-17 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1
>   8 SNES Function norm 3.468150619264e-02 
>     0 KSP Residual norm 3.468150619264e-02 
>     1 KSP Residual norm 5.944160522951e-18 
>   Linear solve converged due to CONVERGED_RTOL_NORMAL iterations 1



> On Jan 30, 2024, at 11:19 AM, Yi Hu <y.hu at mpie.de> wrote:
> 
> Dear PETSc team,
>  
> I am still trying to sort out my previous thread https://lists.mcs.anl.gov/pipermail/petsc-users/2024-January/050079.html using a minimal working example. However, I encountered another problem. Basically I combined the basic usage of SNES solver and shell matrix and tried to make it work. The jacobian of my snes is replaced by a customized MATOP_MULT. The minimal example code can be viewed here https://github.com/hyharry/small_petsc_test/blob/master/test_shell_jac/ex1f.F90
>  
> When running with -ksp_monitor -ksp_converged_reason, it shows an extra mymult step, and hence ruin my previous converged KSP result. Implement a customized converged call-back also does not help. I am wondering how to skip this extra ksp iteration. Could anyone help me on this?
>  
> Thanks for your help.
>  
> Best wishes,
> Yi
> 
> 
> -------------------------------------------------
> Stay up to date and follow us on LinkedIn, Twitter and YouTube.
> 
> Max-Planck-Institut für Eisenforschung GmbH
> Max-Planck-Straße 1
> D-40237 Düsseldorf
>  
> Handelsregister B 2533 
> Amtsgericht Düsseldorf
>  
> Geschäftsführung
> Prof. Dr. Gerhard Dehm
> Prof. Dr. Jörg Neugebauer
> Prof. Dr. Dierk Raabe
> Dr. Kai de Weldige
>  
> Ust.-Id.-Nr.: DE 11 93 58 514 
> Steuernummer: 105 5891 1000
> 
> 
> Please consider that invitations and e-mails of our institute are 
> only valid if they end with …@mpie.de. 
> If you are not sure of the validity please contact rco at mpie.de <mailto:rco at mpie.de>
> 
> Bitte beachten Sie, dass Einladungen zu Veranstaltungen und E-Mails
> aus unserem Haus nur mit der Endung …@mpie.de gültig sind. 
> In Zweifelsfällen wenden Sie sich bitte an rco at mpie.de <mailto:rco at mpie.de>
> -------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240130/9d17c9ca/attachment-0001.html>


More information about the petsc-users mailing list