<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 10, 2015 at 11:27 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
From what you've shown the code looks reasonable, but there must be something missing. Easiest thing is to run in the debugger and put a breakpoint in after the SNESGetFunction() then check what is in F</blockquote><div><br></div><div>1) Do not destroy the Vec you get from SNESGEtFunction()</div><div><br></div><div>2) I usually prefer to re-evaluate the residual with some solution</div><div><br></div><div> SNESComputeFunction()</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"> <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Sep 10, 2015, at 10:40 AM, Gideon Simpson <<a href="mailto:gideon.simpson@gmail.com">gideon.simpson@gmail.com</a>> wrote:<br>
><br>
> If I want to get the residual vector from a SNES, what is the correct calling order?<br>
><br>
> Currently, I have<br>
><br>
> VecDuplicate(U,&F);<br>
><br>
><br>
> SNESSetFunction(snes, F, form_function, ctx);<br>
><br>
> SNESSolve(snes, NULL, U);<br>
><br>
> SNESGetFunction(snes,&F,NULL,NULL);<br>
> VecDestroy(&U);<br>
> VecDestroy(&F);<br>
><br>
> But this generates an error,<br>
><br>
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>
> [0]PETSC ERROR: Invalid argument<br>
> [0]PETSC ERROR: Wrong type of object: Parameter # 1<br>
> [0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>
> [0]PETSC ERROR: Petsc Release Version 3.6.1, unknown<br>
> [0]PETSC ERROR: ./blowup_refine on a arch-darwin-c-debug named gs_air by gideon Thu Sep 10 11:36:10 2015<br>
> [0]PETSC ERROR: Configure options --download-mpich=yes --download-suitesparse=yes --download-superlu=yes --download-superlu_dist=yes --download-mumps=yes --download-sprng=yes --with-cxx=clang++ --with-cc=clang --with-fc=gfortran --download-metis=yes --download-parmetis=yes --download-scalapack=yes<br>
> [0]PETSC ERROR: #1 VecDestroy() line 424 in /opt/petsc/src/vec/vec/interface/vector.c<br>
><br>
><br>
><br>
> -gideon<br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">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></div>