[petsc-users] KSP number of iterations different from size of residual array
Barry Smith
bsmith at petsc.dev
Wed Jan 10 19:30:12 CST 2024
Kevin,
The manual page is misleading. It actually returns the total length of the history as set by KSPSetResidualHistory(), not the number of iterations.
Barry
> On Jan 10, 2024, at 7:09 PM, Kevin G. Wang <kevinw3 at vt.edu> wrote:
>
> Hello everyone!
>
> I am writing a code that uses PETSc/KSP to solve linear systems. I just realized that after running "KSPSolve(...)", the number of iterations given by
>
> KSPGetIterationNumber(ksp, &numIts)
>
> is *different* from the size of the residual history given by
>
> KSPGetResidualHistory(ksp, NULL, &nEntries);
>
> That is, "numIts" is not equal to "nEntries". Is this expected, or a bug in my code? (I thought they should be the same...)
>
> I have tried several pairs of solvers and preconditioners (e.g., fgmres & bjacobi, ibcgs & bjacobi). This issue happens to all of them.
>
> Thanks!
> Kevin
>
> --
> Kevin G. Wang, Ph.D.
> Associate Professor
> Kevin T. Crofton Department of Aerospace and Ocean Engineering
> Virginia Tech
> 1600 Innovation Dr., VTSS Rm 224H, Blacksburg, VA 24061
> Office: (540) 231-7547 | Mobile: (650) 862-2663
> URL: https://www.aoe.vt.edu/people/faculty/wang.html
> Codes: https://github.com/kevinwgy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240110/8e7431b8/attachment.html>
More information about the petsc-users
mailing list