Actual source code: fgmresp.h

      1: /*
      2:    Private data structure used by the FGMRES method. The beginning of this
      3:  data structure MUST be identical to the beginning of KSP_GMRES since they
      4:  share several functions!
      5: */

     10:  #include src/ksp/ksp/kspimpl.h

     12: typedef struct {
     13:     /* Hessenberg matrix and orthogonalization information. */
     14:     PetscScalar *hh_origin;   /* holds hessenburg matrix that has been
     15:                             multiplied by plane rotations (upper tri) */
     16:     PetscScalar *hes_origin;  /* holds the original (unmodified) hessenberg matrix
     17:                             which may be used to estimate the Singular Values
     18:                             of the matrix */
     19:     PetscScalar *cc_origin;   /* holds cosines for rotation matrices */
     20:     PetscScalar *ss_origin;   /* holds sines for rotation matrices */
     21:     PetscScalar *rs_origin;   /* holds the right-hand-side of the Hessenberg system */

     23:     /* Work space for computing eigenvalues/singular values */
     24:     PetscReal   *Dsvd;
     25:     PetscScalar *Rsvd;
     26:
     27:     /* parameters */
     28:     PetscReal haptol;            /* tolerance used for the "HAPPY BREAK DOWN"  */
     29:     PetscInt  max_k;             /* maximum number of Krylov directions to find
     30:                                     before restarting */

     32:     PetscErrorCode (*orthog)(KSP,PetscInt); /* orthogonalization function to use */
     33:     KSPGMRESCGSRefinementType cgstype;
     34:
     35:     Vec       *vecs;              /* holds the work vectors */
     36:
     37:     PetscInt  q_preallocate;     /* 0 = don't pre-allocate space for work vectors */
     38:     PetscInt  delta_allocate;    /* the number of vectors to allocate in each block
     39:                                     if not pre-allocated */
     40:     PetscInt  vv_allocated;      /* vv_allocated is the number of allocated fgmres
     41:                                     direction vectors */
     42:
     43:     PetscInt  vecs_allocated;    /* vecs_allocated is the total number of vecs
     44:                                     available - used to simplify the dynamic
     45:                                     allocation of vectors */
     46:
     47:     Vec       **user_work;       /* Since we may call the user "obtain_work_vectors"
     48:                                     several times, we have to keep track of the pointers
     49:                                     that it has returned (so that we may free the
     50:                                     storage) */

     52:     PetscInt *mwork_alloc;       /* Number of work vectors allocated as part of
     53:                                     a work-vector chunck */
     54:     PetscInt nwork_alloc;         /* Number of work-vector chunks allocated */

     57:     /* In order to allow the solution to be constructed during the solution
     58:        process, we need some additional information: */

     60:     PetscInt    it;              /* Current iteration */
     61:     PetscScalar *nrs;            /* temp that holds the coefficients of the
     62:                                     Krylov vectors that form the minimum residual
     63:                                     solution */
     64:     Vec         sol_temp;        /* used to hold temporary solution */

     67:     /* new storage for fgmres */
     68:     Vec         *prevecs;        /* holds the preconditioned basis vectors for fgmres.
     69:                                     We will allocate these at the same time as vecs
     70:                                     above (and in the same "chunks". */
     71:     Vec          **prevecs_user_work; /* same purpose as user_work above, but this one is
     72:                                     for our preconditioned vectors */

     74:     /* we need a function for interacting with the pcfamily */
     75:
     76:     PetscErrorCode (*modifypc)(KSP,PetscInt,PetscInt,PetscReal,void*);  /* function to modify the preconditioner*/
     77:     PetscErrorCode (*modifydestroy)(void*);
     78:     void   *modifyctx;
     79: } KSP_FGMRES;

     81: #define HH(a,b)  (fgmres->hh_origin + (b)*(fgmres->max_k+2)+(a))
     82:                  /* HH will be size (max_k+2)*(max_k+1)  -  think of HH as
     83:                     being stored columnwise for access purposes. */
     84: #define HES(a,b) (fgmres->hes_origin + (b)*(fgmres->max_k+1)+(a))
     85:                   /* HES will be size (max_k + 1) * (max_k + 1) -
     86:                      again, think of HES as being stored columnwise */
     87: #define CC(a)    (fgmres->cc_origin + (a)) /* CC will be length (max_k+1) - cosines */
     88: #define SS(a)    (fgmres->ss_origin + (a)) /* SS will be length (max_k+1) - sines */
     89: #define RS(a)    (fgmres->rs_origin + (a)) /* RS will be length (max_k+2) - rt side */

     91: /* vector names */
     92: #define VEC_OFFSET     2
     93: #define VEC_TEMP       fgmres->vecs[0]               /* work space */
     94: #define VEC_TEMP_MATOP fgmres->vecs[1]               /* work space */
     95: #define VEC_VV(i)      fgmres->vecs[VEC_OFFSET+i]    /* use to access
     96:                                                         othog basis vectors */
     97: #define PREVEC(i)      fgmres->prevecs[i]            /* use to access
     98:                                                         preconditioned basis */

    100: #endif