SNESLineSearchShellSetUserFunc#

Sets the user function for the SNESLINESEARCHSHELL implementation.

Synopsis#

PetscErrorCode SNESLineSearchShellSetUserFunc(SNESLineSearch linesearch, SNESLineSearchUserFunc func, void *ctx)

Not Collective

Input Parameters#

  • linesearch - SNESLineSearch context

  • func - function implementing the linesearch shell.

  • ctx - context for func

Calling sequence of func#

PetscErrorCode func(SNESLinesearch, void *ctx)
  • linesearch - the linesearch instance

  • ctx - the above mentioned context

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(SNESLineSearchShellSetUserFunc(linesearch, shellfunc, NULL));

See Also#

SNESLineSearchShellGetUserFunc(), SNESLINESEARCHSHELL, SNESLineSearchType, SNESLineSearch

Level#

advanced

Location#

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

Examples#

src/snes/tutorials/ex1f.F90


Edit on GitLab

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