Actual source code: gmresimpl.h

petsc-3.3-p5 2012-12-01
  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 <petsc-private/kspimpl.h>        /*I "petscksp.h" I*/

 11: #define KSPGMRESHEADER                                                  \
 12:   /* Hessenberg matrix and orthogonalization information. */            \
 13:   PetscScalar *hh_origin;   /* holds hessenburg matrix that has been multiplied by plane rotations (upper tri) */ \
 14:   PetscScalar *hes_origin;  /* holds the original (unmodified) hessenberg matrix which may be used to estimate the Singular Values of the matrix */ \
 15:   PetscScalar *cc_origin;   /* holds cosines for rotation matrices */   \
 16:   PetscScalar *ss_origin;   /* holds sines for rotation matrices */     \
 17:   PetscScalar *rs_origin;   /* holds the right-hand-side of the Hessenberg system */ \
 18:                                                                         \
 19:   PetscScalar *orthogwork; /* holds dot products computed in orthogonalization */ \
 20:                                                                         \
 21:   /* Work space for computing eigenvalues/singular values */            \
 22:   PetscReal   *Dsvd;                                                    \
 23:   PetscScalar *Rsvd;                                                    \
 24:                                                                         \
 25:                                                                         \
 26:   PetscReal haptol;                                       /* tolerance for happy ending */ \
 27:   PetscInt  max_k;                                        /* number of vectors in Krylov space, restart size */ \
 28:   PetscInt  nextra_vecs;                                  /* number of extra vecs needed, e.g. for a pipeline */ \
 29:                                                                         \
 30:   PetscErrorCode            (*orthog)(KSP,PetscInt);                    \
 31:   KSPGMRESCGSRefinementType cgstype;                                    \
 32:                                                                         \
 33:   Vec         *vecs;                                     /* the work vectors */ \
 34:   PetscInt    q_preallocate; /* 0=don't preallocate space for work vectors */ \
 35:   PetscInt    delta_allocate; /* number of vectors to preallocaate in each block if not preallocated */ \
 36:   PetscInt    vv_allocated;   /* number of allocated gmres direction vectors */ \
 37:   PetscInt    vecs_allocated;                           /*   total number of vecs available */ \
 38:   /* Since we may call the user "obtain_work_vectors" several times, we have to keep track of the pointers that it has returned */ \
 39:   Vec         **user_work;                                              \
 40:   PetscInt    *mwork_alloc;    /* Number of work vectors allocated as part of  a work-vector chunck */ \
 41:   PetscInt    nwork_alloc;     /* Number of work vector chunks allocated */ \
 42:                                                                         \
 43:   /* Information for building solution */                               \
 44:   PetscInt    it;              /* Current iteration: inside restart */  \
 45:   PetscScalar *nrs;            /* temp that holds the coefficients of the Krylov vectors that form the minimum residual solution */ \
 46:   Vec         sol_temp;        /* used to hold temporary solution */

 48: typedef struct {
 49:   KSPGMRESHEADER
 50: } KSP_GMRES;

 52: extern PetscErrorCode KSPView_GMRES(KSP,PetscViewer);
 53: extern PetscErrorCode KSPSetUp_GMRES(KSP);
 54: extern PetscErrorCode KSPSetFromOptions_GMRES(KSP);
 55: extern PetscErrorCode KSPComputeExtremeSingularValues_GMRES(KSP,PetscReal *,PetscReal *);
 56: extern PetscErrorCode KSPComputeEigenvalues_GMRES(KSP,PetscInt,PetscReal *,PetscReal *,PetscInt *);
 57: extern PetscErrorCode KSPReset_GMRES(KSP);
 58: extern PetscErrorCode KSPDestroy_GMRES(KSP);
 59: extern PetscErrorCode KSPGMRESGetNewVectors(KSP,PetscInt);

 61: typedef PetscErrorCode (*FCN)(KSP,PetscInt); /* force argument to next function to not be extern C*/


 72: /* These macros are guarded because they are redefined by derived implementations */
 73: #if !defined(KSPGMRES_NO_MACROS)
 74: #define HH(a,b)  (gmres->hh_origin + (b)*(gmres->max_k+2)+(a))
 75: #define HES(a,b) (gmres->hes_origin + (b)*(gmres->max_k+1)+(a))
 76: #define CC(a)    (gmres->cc_origin + (a))
 77: #define SS(a)    (gmres->ss_origin + (a))
 78: #define GRS(a)   (gmres->rs_origin + (a))

 80: /* vector names */
 81: #define VEC_OFFSET     2
 82: #define VEC_TEMP       gmres->vecs[0]
 83: #define VEC_TEMP_MATOP gmres->vecs[1]
 84: #define VEC_VV(i)      gmres->vecs[VEC_OFFSET+i]
 85: #endif

 87: #endif