1 /* 2 Context for a Newton trust region method for solving a system 3 of nonlinear equations 4 */ 5 6 #pragma once 7 #include <petsc/private/snesimpl.h> 8 9 typedef struct { 10 PetscReal delta; /* trust region parameter */ 11 PetscReal delta0; /* initial radius for trust region */ 12 PetscReal deltaM; /* maximum radius for trust region */ 13 PetscReal kmdc; /* sufficient decrease parameter */ 14 15 /* 16 Given rho = (fk - fkp1) / (m(0) - m(pk)) 17 18 The radius is modified as: 19 rho < eta2 -> delta *= t1 20 rho > eta3 -> delta *= t2 21 delta = min(delta,deltaM) 22 23 The step is accepted if rho > eta1 24 */ 25 PetscReal eta1; 26 PetscReal eta2; 27 PetscReal eta3; 28 PetscReal t1; 29 PetscReal t2; 30 31 /* Use quasi-Newton models for J and (possibly different) Jp */ 32 SNESNewtonTRQNType qn; 33 Mat qnB; 34 Mat qnB_pre; 35 36 /* The type of norm for the trust region */ 37 NormType norm; 38 39 SNESNewtonTRFallbackType fallback; /* enum to distinguish fallback in case Newton step is outside of the trust region */ 40 41 PetscErrorCode (*precheck)(SNES, Vec, Vec, PetscBool *, void *); 42 void *precheckctx; 43 PetscErrorCode (*postcheck)(SNES, Vec, Vec, Vec, PetscBool *, PetscBool *, void *); 44 void *postcheckctx; 45 } SNES_NEWTONTR; 46