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: #undef __FUNCT__
7: /*@C
8: SNESSetLineSearchParams - Sets the parameters associated with the line search
9: routine in the Newton-based method SNESLS.
11: Collective on SNES
13: Input Parameters:
14: + snes - The nonlinear context obtained from SNESCreate()
15: . alpha - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
16: . maxstep - The maximum norm of the update vector
17: - steptol - The minimum norm fraction of the original step after scaling
19: Level: intermediate
21: Note:
22: Pass in PETSC_DEFAULT for any parameter you do not wish to change.
24: We are finding the zero of f() so the one dimensional minimization problem we are
25: solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)
27: Contributed by: Mathew Knepley
29: .keywords: SNES, nonlinear, set, line search params
31: .seealso: SNESGetLineSearchParams(), SNESSetLineSearch()
32: @*/
33: int SNESSetLineSearchParams(SNES snes,PetscReal alpha,PetscReal maxstep,PetscReal steptol)
34: {
35: SNES_LS *ls;
40: ls = (SNES_LS*)snes->data;
41: if (alpha >= 0.0) ls->alpha = alpha;
42: if (maxstep >= 0.0) ls->maxstep = maxstep;
43: if (steptol >= 0.0) ls->steptol = steptol;
44: return(0);
45: }
47: #undef __FUNCT__
49: /*@C
50: SNESGetLineSearchParams - Gets the parameters associated with the line search
51: routine in the Newton-based method SNESLS.
53: Not collective, but any processor will return the same values
55: Input Parameters:
56: + snes - The nonlinear context obtained from SNESCreate()
57: . alpha - The scalar such that .5*f_{n+1} . f_{n+1} <= .5*f_n . f_n - alpha |f_n . J . f_n|
58: . maxstep - The maximum norm of the update vector
59: - steptol - The minimum norm fraction of the original step after scaling
61: Level: intermediate
63: Note:
64: To not get a certain parameter, pass in PETSC_NULL
66: We are finding the zero of f() so the one dimensional minimization problem we are
67: solving in the line search is minimize .5*f(x_n + lambda*step_direction) . f(x_n + lambda*step_direction)
69: Contributed by: Mathew Knepley
71: .keywords: SNES, nonlinear, set, line search parameters
73: .seealso: SNESSetLineSearchParams(), SNESSetLineSearch()
74: @*/
75: int SNESGetLineSearchParams(SNES snes,PetscReal *alpha,PetscReal *maxstep,PetscReal *steptol)
76: {
77: SNES_LS *ls;
82: ls = (SNES_LS*)snes->data;
83: if (alpha) {
85: *alpha = ls->alpha;
86: }
87: if (maxstep) {
89: *maxstep = ls->maxstep;
90: }
91: if (steptol) {
93: *steptol = ls->steptol;
94: }
95: return(0);
96: }