petsc-3.3-p7 2013-05-11

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 = SNESLineSearchSetSuccess(linesearch, PETSC_TRUE);CHKERRQ(ierr);
    ierr = SNESLineSearchGetVecs(linesearch, X, Y, F, 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 = SNESGetSNESLineSearch(snes, &linesearch);CHKERRQ(ierr);
 ierr = SNESLineSearchSetType(linesearch, SNESLINESEARCHSHELL);CHKERRQ(ierr);
 ierr = SNESLineSearchShellSetUserFunc(linesearch, shellfunc, PETSC_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
src/snes/examples/tutorials/ex39f90.F.html