1 #ifndef __LINESEARCHIMPL_H 2 #define __LINESEARCHIMPL_H 3 4 #include <petscsnes.h> 5 #include <petsc/private/petscimpl.h> 6 7 PETSC_EXTERN PetscBool SNESLineSearchRegisterAllCalled; 8 PETSC_EXTERN PetscErrorCode SNESLineSearchRegisterAll(void); 9 PETSC_EXTERN PetscLogEvent SNESLINESEARCH_Apply; 10 11 typedef struct _LineSearchOps *LineSearchOps; 12 13 struct _LineSearchOps { 14 PetscErrorCode (*view)(SNESLineSearch, PetscViewer); 15 SNESLineSearchApplyFunc apply; 16 PetscErrorCode (*precheck)(SNESLineSearch,Vec,Vec,PetscBool*,void*); 17 SNESLineSearchVIProjectFunc viproject; 18 SNESLineSearchVINormFunc vinorm; 19 PetscErrorCode (*postcheck)(SNESLineSearch,Vec,Vec,Vec,PetscBool *,PetscBool *,void*); 20 PetscErrorCode (*setfromoptions)(PetscOptionItems*,SNESLineSearch); 21 PetscErrorCode (*reset)(SNESLineSearch); 22 PetscErrorCode (*destroy)(SNESLineSearch); 23 PetscErrorCode (*setup)(SNESLineSearch); 24 PetscErrorCode (*snesfunc)(SNES,Vec,Vec); 25 }; 26 27 #define MAXSNESLSMONITORS 5 28 29 struct _p_LineSearch { 30 PETSCHEADER(struct _LineSearchOps); 31 32 SNES snes; 33 34 void *data; 35 36 PetscBool setupcalled; 37 38 Vec vec_sol; 39 Vec vec_sol_new; 40 Vec vec_func; 41 Vec vec_func_new; 42 Vec vec_update; 43 44 PetscInt nwork; 45 Vec *work; 46 47 PetscReal lambda; 48 49 PetscBool norms; 50 PetscReal fnorm; 51 PetscReal ynorm; 52 PetscReal xnorm; 53 SNESLineSearchReason result; 54 PetscBool keeplambda; 55 56 PetscReal damping; 57 PetscReal maxstep; 58 PetscReal steptol; 59 PetscInt max_its; 60 PetscReal rtol; 61 PetscReal atol; 62 PetscReal ltol; 63 PetscInt order; 64 65 PetscReal precheck_picard_angle; 66 67 void * precheckctx; 68 void * postcheckctx; 69 70 PetscViewer monitor; 71 PetscErrorCode (*monitorftns[MAXSNESLSMONITORS])(SNESLineSearch,void*); /* monitor routine */ 72 PetscErrorCode (*monitordestroy[MAXSNESLSMONITORS])(void**); /* monitor context destroy routine */ 73 void *monitorcontext[MAXSNESLSMONITORS]; /* monitor context */ 74 PetscInt numbermonitors; /* number of monitors */ 75 }; 76 77 #endif 78