PETSc version 3.17.5
Fix/Edit manual page

SNESLineSearchShellSetUserFunc

Sets the user function for the SNESLineSearch Shell 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

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(0);
 }

 ...

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

.seealso: SNESLineSearchShellGetUserFunc(), SNESLINESEARCHSHELL

Level

advanced

Location

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

Examples

src/snes/tutorials/ex1f.F90.html

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