<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> Kevin,<div><br></div><div> The manual page is misleading. It actually returns the total length of the history as set by KSPSetResidualHistory(), not the number of iterations.</div><div><br></div><div> Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Jan 10, 2024, at 7:09 PM, Kevin G. Wang <kevinw3@vt.edu> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default"><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;">Hello everyone!</div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;">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 </div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;">KSPGetIterationNumber(ksp, &numIts)</div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;">is *different* from the size of the residual history given by</div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif; font-size: small;">KSPGetResidualHistory(ksp, NULL, &nEntries);<br></div><div style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small"><div class="gmail_default" style="font-family: arial, sans-serif;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif;">That is, "numIts" is not equal to "nEntries". Is this expected, or a bug in my code? (I thought they should be the same...)</div><div class="gmail_default" style="font-family: arial, sans-serif;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif;">I have tried several pairs of solvers and preconditioners (e.g., fgmres & bjacobi, ibcgs & bjacobi). This issue happens to all of them.</div><div class="gmail_default" style="font-family: arial, sans-serif;"><br></div><div class="gmail_default" style="font-family: arial, sans-serif;">Thanks!</div><font color="#888888"><div class="gmail_default" style="font-family: arial, sans-serif;">Kevin</div></font></div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Kevin G. Wang, Ph.D.</div><div dir="ltr">Associate Professor</div><div dir="ltr">Kevin T. Crofton Department of Aerospace and Ocean Engineering</div><div dir="ltr">Virginia Tech</div><div dir="ltr">1600 Innovation Dr., VTSS Rm 224H, Blacksburg, VA 24061<br></div><div dir="ltr">Office: (540) 231-7547 | Mobile: (650) 862-2663 </div><div dir="ltr">URL: <a href="https://www.aoe.vt.edu/people/faculty/wang.html" target="_blank">https://www.aoe.vt.edu/people/faculty/wang.html</a> </div><div>Codes: <a href="https://github.com/kevinwgy" target="_blank">https://github.com/kevinwgy</a></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></body></html>