Date: 2024-07-30T17:31:10+00:00

Actual source code: linesearchimpl.h

      1: #pragma once

      3: #include <petscsnes.h>
      4: #include <petsc/private/petscimpl.h>

      6: PETSC_EXTERN PetscBool      SNESLineSearchRegisterAllCalled;
      7: PETSC_EXTERN PetscErrorCode SNESLineSearchRegisterAll(void);
      8: PETSC_EXTERN PetscLogEvent  SNESLINESEARCH_Apply;

     10: typedef struct _LineSearchOps *LineSearchOps;

     12: struct _LineSearchOps {
     13:   PetscErrorCode (*view)(SNESLineSearch, PetscViewer);
     14:   SNESLineSearchApplyFn *apply;
     15:   PetscErrorCode (*precheck)(SNESLineSearch, Vec, Vec, PetscBool *, void *);
     16:   SNESLineSearchVIProjectFn *viproject;
     17:   SNESLineSearchVINormFn    *vinorm;
     18:   PetscErrorCode (*postcheck)(SNESLineSearch, Vec, Vec, Vec, PetscBool *, PetscBool *, void *);
     19:   PetscErrorCode (*setfromoptions)(SNESLineSearch, PetscOptionItems *);
     20:   PetscErrorCode (*reset)(SNESLineSearch);
     21:   PetscErrorCode (*destroy)(SNESLineSearch);
     22:   PetscErrorCode (*setup)(SNESLineSearch);
     23:   PetscErrorCode (*snesfunc)(SNES, Vec, Vec);
     24: };

     26: #define MAXSNESLSMONITORS 5

     28: struct _p_LineSearch {
     29:   PETSCHEADER(struct _LineSearchOps);

     31:   SNES snes;

     33:   void *data;

     35:   PetscBool setupcalled;

     37:   Vec vec_sol;
     38:   Vec vec_sol_new;
     39:   Vec vec_func;
     40:   Vec vec_func_new;
     41:   Vec vec_update;

     43:   PetscInt nwork;
     44:   Vec     *work;

     46:   PetscReal lambda;

     48:   PetscBool            norms;
     49:   PetscReal            fnorm;
     50:   PetscReal            ynorm;
     51:   PetscReal            xnorm;
     52:   SNESLineSearchReason result;
     53:   PetscBool            keeplambda;

     55:   PetscReal damping;
     56:   PetscReal maxstep;
     57:   PetscReal steptol;
     58:   PetscInt  max_its;
     59:   PetscReal rtol;
     60:   PetscReal atol;
     61:   PetscReal ltol;
     62:   PetscInt  order;

     64:   PetscReal precheck_picard_angle;

     66:   void *precheckctx;
     67:   void *postcheckctx;

     69:   PetscViewer monitor;
     70:   PetscErrorCode (*monitorftns[MAXSNESLSMONITORS])(SNESLineSearch, void *); /* monitor routine */
     71:   PetscErrorCode (*monitordestroy[MAXSNESLSMONITORS])(void **);             /* monitor context destroy routine */
     72:   void    *monitorcontext[MAXSNESLSMONITORS];                               /* monitor context */
     73:   PetscInt numbermonitors;                                                  /* number of monitors */
     74: };