PetscErrorCode SNESLineSearchShellSetUserFunc(SNESLineSearch linesearch, SNESLineSearchUserFunc func, void *ctx)Not Collective
linesearch | - SNESLineSearch context | |
func | - function implementing the linesearch shell. | |
ctx | - context for func |
linesearch | - the linesearch instance | |
ctx | - the above mentioned context |
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