[petsc-users] clarification of SNES / FormFunction
Jed Brown
jedbrown at mcs.anl.gov
Tue May 8 07:50:47 CDT 2012
On Tue, May 8, 2012 at 5:23 AM, Dominik Szczerba <dominik at itis.ethz.ch>wrote:
> Hi, I do set my own KSP to SNES:
>
>
> ierr = SNESCreate(PETSC_COMM_WORLD, &snes); CHKERRQ(ierr);
> ierr = SNESSetKSP(snes, ksp); CHKERRQ(ierr);
>
> I set the ksp solver type, tolerances etc. Then I register
> FormFunction using SNESSetFunction, and implement it as;
>
>
> PetscErrorCode FormFunction(SNES snes, Vec x, Vec f, void *ctx)
>
> Now my question: is "x" in the signature above expected to be the same
> as "x" obtained after a linear solve in the KSP object used in SNES
> (that I pass inside ctx), or will "x" be generally differently-valued
> due to e.g. the line search performed?
>
Newton-based SNES solves for snes->vec_sol_update, but evaluates at
snes->vec_sol and using another vector inside the line search.
If you are writing code that depends on the Vec being the same, you're
doing it wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120508/0817ea96/attachment.htm>
More information about the petsc-users
mailing list