<div dir="ltr"><div dir="ltr"><div>Well, this is just because the Python code implementing KSPSolve does not reset the iteration counter to zero. This was an oversight on my part when I wrote that code ages ago.</div><div><br></div><div>Barry, I'm wondering whether this should be done at the interface rather than implementation level? If you do not want to change things in core KSP (and then maybe SNES, etc), the the following patch should fix things. </div><div><br></div><div><br></div><div>diff --git a/src/ksp/ksp/examples/tutorials/example100.py b/src/ksp/ksp/examples/tutorials/example100.py</div><div>index ef085522bf..7ad03ec194 100644</div><div>--- a/src/ksp/ksp/examples/tutorials/example100.py</div><div>+++ b/src/ksp/ksp/examples/tutorials/example100.py</div><div>@@ -119,11 +119,13 @@ class ConjGrad(object):</div><div> </div><div>     def solve(self, ksp, b, x):</div><div>         LOG('ConjGrad.solve()')</div><div>+        ksp.setIterationNumber(0)</div><div>         A, P = get_op_pc(ksp, transpose=False)</div><div>         pcg(ksp, A, P, b, x, *<a href="http://self.work">self.work</a>)</div><div> </div><div>     def solveTranspose(self, ksp, b, x):</div><div>         LOG('ConjGrad.solveTranspose()')</div><div>+        ksp.setIterationNumber(0)</div><div>         A, P = get_op_pc(ksp, transpose=True)</div><div>         pcg(ksp, A, P, b, x, *<a href="http://self.work">self.work</a>)</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 4 Mar 2019 at 06:15, Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
   Pierre,<br>
<br>
     I can confirm the problem.<br>
<br>
   Lisandro,<br>
<br>
     Could you please take a look at this? I have no explanation for why this would happen.<br>
<br>
   Barry<br>
<br>
<br>
<br>
> On Feb 25, 2019, at 1:21 PM, Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> wrote:<br>
> <br>
> I’m not sure this is the expected behavior. Is it?<br>
> $ git diff ex100.py<br>
> diff --git a/src/ksp/ksp/examples/tutorials/ex100.py b/src/ksp/ksp/examples/tutorials/ex100.py<br>
> index dbb3f8e012..051637ce1d 100644<br>
> --- a/src/ksp/ksp/examples/tutorials/ex100.py<br>
> +++ b/src/ksp/ksp/examples/tutorials/ex100.py<br>
> @@ -29,6 +29,7 @@ def RunTest():<br>
>     ksp.setOperators(A, A)<br>
>     ksp.setFromOptions()<br>
>     ksp.solve(b, x)<br>
> +    ksp.solve(b, x)<br>
> <br>
>     r = b.duplicate()<br>
>     A.mult(x, r)<br>
> <br>
> $ mpirun -np 8 python ./ex100.py -ksp_converged_reason -ksp_monitor<br>
>  0 KSP Residual norm 5.101520253035e-04<br>
>  1 KSP Residual norm 1.168905135944e-03<br>
> [..]<br>
> 12 KSP Residual norm 5.101520253035e-05<br>
> 13 KSP Residual norm 7.504522604366e-20<br>
> Linear solve converged due to CONVERGED_RTOL iterations 13<br>
> 13 KSP Residual norm 5.101520253035e-04<br>
> 14 KSP Residual norm 1.168905135944e-03<br>
> [..]<br>
> 25 KSP Residual norm 5.101520253035e-05<br>
> 26 KSP Residual norm 7.504522604366e-20<br>
> Linear solve converged due to CONVERGED_RTOL iterations 26<br>
> <br>
> Shouldn’t the iterate number be reset to 0 for the 2nd KSPSolve?<br>
> <br>
> Thanks,<br>
> Pierre<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Lisandro Dalcin<br>============<br>Research Scientist<br>Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)<br>Extreme Computing Research Center (ECRC)<br>King Abdullah University of Science and Technology (KAUST)<br><a href="http://ecrc.kaust.edu.sa/" target="_blank">http://ecrc.kaust.edu.sa/</a><br><br>4700 King Abdullah University of Science and Technology<br>al-Khawarizmi Bldg (Bldg 1), Office # 0109<br>Thuwal 23955-6900, Kingdom of Saudi Arabia<br><a href="http://www.kaust.edu.sa" target="_blank">http://www.kaust.edu.sa</a><br><br>Office Phone: +966 12 808-0459</div>