SNESLineSearchShellSetApply#

Sets the apply function for the SNESLINESEARCHSHELL implementation.

Synopsis#

PetscErrorCode SNESLineSearchShellSetApply(SNESLineSearch linesearch, SNESLineSearchShellApplyFn *func, void *ctx)

Not Collective

Input Parameters#

  • linesearch - SNESLineSearch context

  • func - function implementing the linesearch shell, see SNESLineSearchShellApplyFn for calling sequence

  • ctx - context for func

Usage:

  PetscErrorCode shellfunc(SNESLineSearch linesearch,void * ctx)
  {
     Vec  X,Y,F,W,G;
     SNES snes;

     PetscFunctionBegin;
     PetscCall(SNESLineSearchGetSNES(linesearch,&snes));
     PetscCall(SNESLineSearchSetReason(linesearch,SNES_LINESEARCH_SUCCEEDED));
     PetscCall(SNESLineSearchGetVecs(linesearch,&X,&F,&Y,&W,&G));
     // determine lambda using W and G as work vecs..
     PetscCall(VecAXPY(X,-lambda,Y));
     PetscCall(SNESComputeFunction(snes,X,F));
     PetscCall(SNESLineSearchComputeNorms(linesearch));
     PetscFunctionReturn(PETSC_SUCCESS);
  }

  PetscCall(SNESGetLineSearch(snes, &linesearch));
  PetscCall(SNESLineSearchSetType(linesearch, SNESLINESEARCHSHELL));
  PetscCall(SNESLineSearchShellSetApply(linesearch, shellfunc, NULL));

See Also#

SNES: Nonlinear Solvers, SNESLineSearchShellGetApply(), SNESLINESEARCHSHELL, SNESLineSearchType, SNESLineSearch, SNESLineSearchShellApplyFn

Level#

advanced

Location#

src/snes/linesearch/impls/shell/linesearchshell.c

Examples#

src/snes/tutorials/ex1f.F90


Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages