Actual source code: lsparams.c
1: /*$Id: lsparams.c,v 1.12 2001/08/06 21:17:15 bsmith Exp $*/
3: #include src/snes/impls/ls/ls.h
5: /*@C
6: SNESSetLineSearchParams - Sets the parameters associated with the line search
7: routine in the Newton-based method SNESLS.
9: Collective on SNES
11: Input Parameters:
12: + snes - The nonlinear context obtained from SNESCreate()
13: . alpha - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
14: . maxstep - The maximum norm of the update vector
15: - steptol - The minimum norm fraction of the original step after scaling
17: Level: intermediate
19: Note:
20: Pass in PETSC_DEFAULT for any parameter you do not wish to change.
22: We are finding the zero of f() so the one dimensional minimization problem we are
23: solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)
25: Contributed by: Mathew Knepley
27: .keywords: SNES, nonlinear, set, line search params
29: .seealso: SNESGetLineSearchParams(), SNESSetLineSearch()
30: @*/
31: int SNESSetLineSearchParams(SNES snes,PetscReal alpha,PetscReal maxstep,PetscReal steptol)
32: {
33: SNES_LS *ls;
38: ls = (SNES_LS*)snes->data;
39: if (alpha >= 0.0) ls->alpha = alpha;
40: if (maxstep >= 0.0) ls->maxstep = maxstep;
41: if (steptol >= 0.0) ls->steptol = steptol;
42: return(0);
43: }
45: /*@C
46: SNESGetLineSearchParams - Gets the parameters associated with the line search
47: routine in the Newton-based method SNESLS.
49: Not collective, but any processor will return the same values
51: Input Parameters:
52: + snes - The nonlinear context obtained from SNESCreate()
53: . alpha - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
54: . maxstep - The maximum norm of the update vector
55: - steptol - The minimum norm fraction of the original step after scaling
57: Level: intermediate
59: Note:
60: To not get a certain parameter, pass in PETSC_NULL
62: We are finding the zero of f() so the one dimensional minimization problem we are
63: solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)
65: Contributed by: Mathew Knepley
67: .keywords: SNES, nonlinear, set, line search parameters
69: .seealso: SNESSetLineSearchParams(), SNESSetLineSearch()
70: @*/
71: int SNESGetLineSearchParams(SNES snes,PetscReal *alpha,PetscReal *maxstep,PetscReal *steptol)
72: {
73: SNES_LS *ls;
78: ls = (SNES_LS*)snes->data;
79: if (alpha) {
81: *alpha = ls->alpha;
82: }
83: if (maxstep) {
85: *maxstep = ls->maxstep;
86: }
87: if (steptol) {
89: *steptol = ls->steptol;
90: }
91: return(0);
92: }