Actual source code: gmresimpl.h

  1: /*
  2:    Private data structure used by the GMRES method. This data structure
  3:   must be identical to the beginning of the KSP_FGMRES data structure
  4:   so if you CHANGE anything here you must also change it there.
  5: */

 9:  #include private/kspimpl.h

 11: typedef struct {
 12:   /* Hessenberg matrix and orthogonalization information.  Hes holds
 13:        the original (unmodified) hessenberg matrix which may be used
 14:        to estimate the Singular Values of the matrix */
 15:   PetscScalar *hh_origin,*hes_origin,*cc_origin,*ss_origin,*rs_origin;

 17:   PetscScalar *orthogwork; /* holds dot products computed in orthogonalization */

 19:   /* Work space for computing eigenvalues/singular values */
 20:   PetscReal   *Dsvd;
 21:   PetscScalar *Rsvd;
 22: 
 23:   /* parameters */
 24:   PetscReal haptol;
 25:   PetscInt  max_k;

 27:   PetscErrorCode (*orthog)(KSP,PetscInt); /* Functions to use (special to gmres) */
 28:   KSPGMRESCGSRefinementType cgstype;
 29: 
 30:   Vec   *vecs;  /* holds the work vectors */
 31:   /* vv_allocated is the number of allocated gmres direction vectors */
 32:   PetscInt    q_preallocate,delta_allocate;
 33:   PetscInt    vv_allocated;
 34:   /* vecs_allocated is the total number of vecs available (used to 
 35:        simplify the dynamic allocation of vectors */
 36:   PetscInt    vecs_allocated;
 37:   /* Since we may call the user "obtain_work_vectors" several times, 
 38:        we have to keep track of the pointers that it has returned 
 39:       (so that we may free the storage) */
 40:   Vec         **user_work;
 41:   PetscInt    *mwork_alloc;    /* Number of work vectors allocated as part of
 42:                                a work-vector chunck */
 43:   PetscInt    nwork_alloc;     /* Number of work vectors allocated */

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

 48:   PetscInt    it;              /* Current iteration: inside restart */
 49:   PetscScalar *nrs;            /* temp that holds the coefficients of the 
 50:                                Krylov vectors that form the minimum residual
 51:                                solution */
 52:   Vec         sol_temp;        /* used to hold temporary solution */
 53: } KSP_GMRES;

 55: #define HH(a,b)  (gmres->hh_origin + (b)*(gmres->max_k+2)+(a))
 56: #define HES(a,b) (gmres->hes_origin + (b)*(gmres->max_k+1)+(a))
 57: #define CC(a)    (gmres->cc_origin + (a))
 58: #define SS(a)    (gmres->ss_origin + (a))
 59: #define GRS(a)   (gmres->rs_origin + (a))

 61: /* vector names */
 62: #define VEC_OFFSET     2
 63: #define VEC_TEMP       gmres->vecs[0]
 64: #define VEC_TEMP_MATOP gmres->vecs[1]
 65: #define VEC_VV(i)      gmres->vecs[VEC_OFFSET+i]

 67: #endif