[petsc-users] snesgetfunction calling sequence

Barry Smith bsmith at mcs.anl.gov
Thu Sep 10 11:27:17 CDT 2015


   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.

  Barry

> On Sep 10, 2015, at 10:40 AM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
> 
> If I want to get the residual vector from a SNES, what is the correct calling order?
> 
> Currently, I have
> 
>     VecDuplicate(U,&F);
> 
> 
>   SNESSetFunction(snes, F, form_function, ctx);
> 
>   SNESSolve(snes, NULL, U);
> 
> SNESGetFunction(snes,&F,NULL,NULL);
> VecDestroy(&U);
> VecDestroy(&F);
> 
> But this generates an error, 
> 
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Invalid argument
> [0]PETSC ERROR: Wrong type of object: Parameter # 1
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.6.1, unknown 
> [0]PETSC ERROR: ./blowup_refine on a arch-darwin-c-debug named gs_air by gideon Thu Sep 10 11:36:10 2015
> [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
> [0]PETSC ERROR: #1 VecDestroy() line 424 in /opt/petsc/src/vec/vec/interface/vector.c
> 
> 
> 
> -gideon
> 



More information about the petsc-users mailing list