<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">If I want to get the residual vector from a SNES, what is the correct calling order?<div class=""><br class=""></div><div class="">Currently, I have</div><div class=""><br class=""></div><div class=""> VecDuplicate(U,&F);</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> SNESSetFunction(snes, F, form_function, ctx);<br class=""><div class=""><br class=""></div><div class=""> SNESSolve(snes, NULL, U);</div><div class=""><br class=""></div><div class="">SNESGetFunction(snes,&F,NULL,NULL);</div><div class="">VecDestroy(&U);</div><div class="">VecDestroy(&F);</div><div class=""><br class=""></div><div class="">But this generates an error, </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-family: Menlo; color: rgb(195, 55, 32);" class=""><b style="font-size: 12px;" class="">[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</b></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: Invalid argument</span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: Wrong type of object: Parameter # 1</span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" class="">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: Petsc Release Version 3.6.1, unknown </span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: ./blowup_refine on a arch-darwin-c-debug named gs_air by gideon Thu Sep 10 11:36:10 2015</span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[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</span></div><div style="margin: 0px; font-family: Menlo;" class=""><span style="font-size: 12px;" class="">[0]PETSC ERROR: #1 VecDestroy() line 424 in /opt/petsc/src/vec/vec/interface/vector.c</span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">-gideon</span>
</div>
<br class=""></div></div></body></html>