Actual source code: lsparams.c

 2:  #include src/snes/impls/ls/ls.h

  6: /*@C
  7:    SNESSetLineSearchParams - Sets the parameters associated with the line search
  8:    routine in the Newton-based method SNESLS.

 10:    Collective on SNES

 12:    Input Parameters:
 13: +  snes    - The nonlinear context obtained from SNESCreate()
 14: .  alpha   - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
 15: .  maxstep - The maximum norm of the update vector
 16: -  steptol - The minimum norm fraction of the original step after scaling

 18:    Level: intermediate

 20:    Note:
 21:    Pass in PETSC_DEFAULT for any parameter you do not wish to change.

 23:    We are finding the zero of f() so the one dimensional minimization problem we are
 24:    solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)

 26:    Contributed by: Mathew Knepley

 28: .keywords: SNES, nonlinear, set, line search params

 30: .seealso: SNESGetLineSearchParams(), SNESSetLineSearch()
 31: @*/
 32: PetscErrorCode SNESSetLineSearchParams(SNES snes,PetscReal alpha,PetscReal maxstep,PetscReal steptol)
 33: {
 34:   SNES_LS *ls;


 39:   ls = (SNES_LS*)snes->data;
 40:   if (alpha   >= 0.0) ls->alpha   = alpha;
 41:   if (maxstep >= 0.0) ls->maxstep = maxstep;
 42:   if (steptol >= 0.0) ls->steptol = steptol;
 43:   return(0);
 44: }

 48: /*@C
 49:    SNESGetLineSearchParams - Gets the parameters associated with the line search
 50:      routine in the Newton-based method SNESLS.

 52:    Not collective, but any processor will return the same values

 54:    Input Parameters:
 55: +  snes    - The nonlinear context obtained from SNESCreate()
 56: .  alpha   - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
 57: .  maxstep - The maximum norm of the update vector
 58: -  steptol - The minimum norm fraction of the original step after scaling

 60:    Level: intermediate

 62:    Note:
 63:     To not get a certain parameter, pass in PETSC_NULL

 65:    We are finding the zero of f() so the one dimensional minimization problem we are
 66:    solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)

 68:    Contributed by: Mathew Knepley

 70: .keywords: SNES, nonlinear, set, line search parameters

 72: .seealso: SNESSetLineSearchParams(), SNESSetLineSearch()
 73: @*/
 74: PetscErrorCode SNESGetLineSearchParams(SNES snes,PetscReal *alpha,PetscReal *maxstep,PetscReal *steptol)
 75: {
 76:   SNES_LS *ls;


 81:   ls = (SNES_LS*)snes->data;
 82:   if (alpha) {
 84:     *alpha   = ls->alpha;
 85:   }
 86:   if (maxstep) {
 88:     *maxstep = ls->maxstep;
 89:   }
 90:   if (steptol) {
 92:     *steptol = ls->steptol;
 93:   }
 94:   return(0);
 95: }