<div dir="ltr"><div>Thank you. It seems to be working like a charm with PCSHELL, I have the drastic reductions in KSP iterations ! (incidentally, my convergence problem was probably mostly due to a mistake in the Schur matrix, but putting things in the right place also helps !)<br><br></div><div>Now I have to move the KSP step in the preconditioner to multigrid method, it should in principle be more efficient than the default KSP options for my specific problem. However there is almost no example using multigrid in the documentation. I found only ksp/ksp/examples/tutorials/ex42.c and ksp/ksp/examples/tests/ex19.c, however in the first one it is not the default and trying to use the option -stokes_pc_type pcmg produced errors like<br>[0]PETSC ERROR: Unable to find requested PC type pcmg <br></div><div><br></div><div>Regarding the second one, it says at the top that it is the "bad way", so I am not sure I should follow this example... In which sense is it a bad way ? Is it because there are only two levels and in principle we shoud have a hierarchy until the lowest grid ?<br><br></div><div>In anycase if anyone has a nice multigrid example on a simple case like Laplacian, in the "good way", I would be interested<br></div><div><br></div><div>Best<br><br></div><div>Timothee<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-28 14:21 GMT+02:00 Timothée Nicolas <span dir="ltr"><<a href="mailto:timothee.nicolas@gmail.com" target="_blank">timothee.nicolas@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Thanks a lot, I expected something like that. I will look in this direction.<br><br></div>Best<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Timothée<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-09-28 21:17 GMT+09:00 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Sep 28, 2015 at 2:53 AM, Timothée Nicolas <span dir="ltr"><<a href="mailto:timothee.nicolas@gmail.com" target="_blank">timothee.nicolas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi all,<br><br></div>I have something strange in my application and I don't know what could cause this. I am trying to do an implicit MHD problem and I thought I finally figured out the preconditioner step, but somehow I don't get the expected result, not even close.<br><br>For the preconditioning, I am using an approximate Schur complement, which requires two relatively easy KSP inversions at each preconditioner application. I apply this algorithm directly to the result function at the end of the routine FormFunction. I have checked that the approximation to the inversion of the Jacobian is good, in the sense that when I multiply the preconditioned vector by the <u><b>total</b></u><b> </b>Jacobian matrix, I indeed recover almost the initial unpreconditioned vector. Also, I know that my Jacobian matrix is correct, because (i) I have checked manually that F(X + dX) ~ F(X) + J * dX and (ii) when I don't use -snes_mf and use the provided Jacobian matrix the result is pretty much equivalent to using -snes_mf.<br><br></div>In my understanding, this means that what I effectively feed to SNES at the end of my FormFunction routine is a good approximation to J^(-1) F. As a result, I naturally expect that the number of KSP iterations necessary to achieve one SNES iteration be drastically reduced. However, I observe virtually no change whatsoever in the number of iterations.<br><br></div>Any thoughts about what I could be missing ? Maybe I forgot to set a SNES or KSP option somewhere ? I can send pieces of code if needs be.<br></div></div></div></blockquote><div><br></div></span><div>It sounds like you are putting this in the wrong place. If you have the action of a good preconditioner for the Jacobian, then you</div><div>should use a PCSHELL and pass it to the KSP. It does not belong in the FormFunction.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div></div>Best<br><br></div>Timothee<br><div><br><br></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>