petsc-3.7.3 2016-08-01
Report Typos and Errors

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;
    ierr = SNESLineSearchGetSNES(linesearch,&snes);CHKERRQ(ierr);
    ierr = SNESLineSearchSetReason(linesearch,SNES_LINESEARCH_SUCCEEDED);CHKERRQ(ierr);
    ierr = SNESLineSearchGetVecs(linesearch,&X,&F,&Y,&W,&G);CHKERRQ(ierr);
    .. determine lambda using W and G as work vecs..
    ierr = VecAXPY(X,-lambda,Y);CHKERRQ(ierr);
    ierr = SNESComputeFunction(snes,X,F);CHKERRQ(ierr);
    ierr = SNESLineSearchComputeNorms(linesearch);CHKERRQ(ierr);
    PetscFunctionReturn(0);
 }

 ...

 ierr = SNESGetLineSearch(snes, &linesearch);CHKERRQ(ierr);
 ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHSHELL);CHKERRQ(ierr);
 ierr = SNESLineSearchShellSetUserFunc(linesearch, shellfunc, NULL);CHKERRQ(ierr);

.keywords: SNESLineSearch, Shell, user, function, set

.seealso: SNESLineSearchShellGetUserFunc(), SNESLINESEARCHSHELL

Level:advanced
Location:
src/snes/linesearch/impls/shell/linesearchshell.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/snes/examples/tutorials/ex1f.F.html