Date: 2025-03-29T05:58:18+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:   SNESLineSearchVIDirDerivFn *vidirderiv;
     19:   PetscErrorCode (*postcheck)(SNESLineSearch, Vec, Vec, Vec, PetscBool *, PetscBool *, void *);
     20:   PetscErrorCode (*setfromoptions)(SNESLineSearch, PetscOptionItems);
     21:   PetscErrorCode (*reset)(SNESLineSearch);
     22:   PetscErrorCode (*destroy)(SNESLineSearch);
     23:   PetscErrorCode (*setup)(SNESLineSearch);
     24:   PetscErrorCode (*snesfunc)(SNES, Vec, Vec);
     25: };

     27: #define MAXSNESLSMONITORS 5

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

     32:   SNES snes;

     34:   void *data;

     36:   PetscBool setupcalled;

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

     44:   PetscInt nwork;
     45:   Vec     *work;

     47:   PetscReal lambda;

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

     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;

     65:   PetscReal precheck_picard_angle;

     67:   void *precheckctx;
     68:   void *postcheckctx;

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