[petsc-users] snesgetfunction calling sequence

Matthew Knepley knepley at gmail.com
Thu Sep 10 11:44:36 CDT 2015


On Thu, Sep 10, 2015 at 11:27 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>    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


1) Do not destroy the Vec you get from SNESGEtFunction()

2) I usually prefer to re-evaluate the residual with some solution

  SNESComputeFunction()

  Thanks,

     Matt


>
>
  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
> >
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150910/d5d9002c/attachment.html>


More information about the petsc-users mailing list