<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 11, 2014 at 12:46 AM, Fande Kong <span dir="ltr"><<a href="mailto:fd.kong@siat.ac.cn" target="_blank">fd.kong@siat.ac.cn</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">Thanks,</div></blockquote><div><br></div><div>Never mail me personally. That is what the list is for.</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>If we follow a), we can not change any options from command line for the second solve. </div>
</div></blockquote><div><br></div><div>No, you miss the whole point of changing the prefix:</div><div><br></div><div> SNESSetOptionsPrefix(snes, "second_");</div><div><br></div><div>so that afterwards</div><div>
<br></div><div> second_pc_type lu</div><div><br></div><div>will be picked up by the second call to SNESSetFromOptions(). However, as I said before,</div><div>I think there is no reason to do this.</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 class="gmail_extra"><div class="gmail_quote">On Mon, Mar 10, 2014 at 10:35 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@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 class="gmail_extra"><div class="gmail_quote"><div>On Mon, Mar 10, 2014 at 11:29 PM, Fande Kong <span dir="ltr"><<a href="mailto:fd.kong@siat.ac.cn" target="_blank">fd.kong@siat.ac.cn</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">Hi all,<div><br></div><div>I am trying to solve two different nonlinear equations. I first solve the first nonlinear equation using a snes within which a ksp is preconditioned by a pcasm. And then I want to use the solution of the first nonlinear equation as an initial guess to solve the second nonlinear equation, but this time I want to switch the preconditioner to pcmg. How could I finish this by creating snes only once, then using snessolve() twice, and switching preconditioner for linear solvers? </div>
</div></blockquote><div><br></div></div><div>It seems like you gain nothing at all by reusing the SNES, and complicate your code. I would not do it.</div><div><br></div><div>If you insist, you can</div><div><br></div><div>
a) Change the prefix, and call SNESSetFromOptions() before the second solve</div>
<div><br></div><div> b) Pull out the PC (SNESGetKSP, SNESGetPC) and set it there</div><div><br></div><div>Note that in any event, you will have to reset the function/Jacobian methods for the second solve.</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"><span><font color="#888888"><div>
Fande </div></font></span></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>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
</font></span></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>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></div>