Actual source code: lgmresp.h
1: /* A. Baker */
2: /*
3: Private data structure used by the LGMRES method.
4: */
9: #include src/ksp/ksp/kspimpl.h
11: typedef struct {
12: /* Hessenberg matrix and orthogonalization information. */
13: PetscScalar *hh_origin; /* holds hessenburg matrix that has been
14: multiplied by plane rotations (upper tri) */
15: PetscScalar *hes_origin; /* holds the original (unmodified) hessenberg matrix
16: which may be used to estimate the Singular Values
17: of the matrix */
18: PetscScalar *cc_origin; /* holds cosines for rotation matrices */
19: PetscScalar *ss_origin; /* holds sines for rotation matrices */
20: PetscScalar *rs_origin; /* holds the right-hand-side of the Hessenberg system */
22: PetscScalar *orthogwork; /* holds dot products computed in orthogonalization */
24: /* Work space for computing eigenvalues/singular values */
25: PetscReal *Dsvd;
26: PetscScalar *Rsvd;
27:
28: /* parameters */
29: PetscReal haptol; /* tolerance used for the "HAPPY BREAK DOWN" */
30: PetscInt max_k; /* maximum size of the approximation space
31: before restarting */
33: PetscErrorCode (*orthog)(KSP,PetscInt); /* orthogonalization function to use */
34: KSPGMRESCGSRefinementType cgstype;
35:
36: Vec *vecs; /* holds the work vectors */
37:
38: PetscInt q_preallocate; /* 0 = don't pre-allocate space for work vectors */
39: PetscInt delta_allocate; /* the number of vectors to allocate in each block
40: if not pre-allocated */
41: PetscInt vv_allocated; /* vv_allocated is the number of allocated lgmres
42: direction vectors */
43:
44: PetscInt vecs_allocated; /* vecs_allocated is the total number of vecs
45: available - used to simplify the dynamic
46: allocation of vectors */
47:
48: Vec **user_work; /* Since we may call the user "obtain_work_vectors"
49: several times, we have to keep track of the pointers
50: that it has returned (so that we may free the
51: storage) */
53: PetscInt *mwork_alloc; /* Number of work vectors allocated as part of
54: a work-vector chunck */
55: PetscInt nwork_alloc; /* Number of work-vector chunks allocated */
58: /* In order to allow the solution to be constructed during the solution
59: process, we need some additional information: */
61: PetscInt it; /* Current iteration */
62: PetscScalar *nrs; /* temp that holds the coefficients of the
63: Krylov vectors that form the minimum residual
64: solution */
65: Vec sol_temp; /* used to hold temporary solution */
68: /* LGMRES_MOD - make these for the z vectors - new storage for lgmres */
69: Vec *augvecs; /* holds the error approximation vectors for lgmres. */
70: Vec **augvecs_user_work; /* same purpose as user_work above, but this one is
71: for our error approx vectors */
72: PetscInt aug_vv_allocated; /* aug_vv_allocated is the number of allocated lgmres
73: augmentation vectors */
74: PetscInt aug_vecs_allocated; /* aug_vecs_allocated is the total number of augmentation vecs
75: available - used to simplify the dynamic
76: allocation of vectors */
78: PetscInt augwork_alloc; /*size of chunk allocated for augmentation vectors */
80: PetscInt aug_dim; /* max number of augmented directions to add */
82: PetscInt aug_ct; /* number of aug. vectors available */
84: PetscInt *aug_order; /*keeps track of order to use aug. vectors*/
86: PetscInt approx_constant; /* = 1 then the approx space at each restart will
87: be size max_k . Therefore, more than (max_k - aug_dim)
88: krylov vectors may be used if less than aug_dim error
89: approximations are available (in the first few restarts,
90: for example) to keep the space a constant size. */
91:
92: PetscInt matvecs; /*keep track of matvecs */
93: } KSP_LGMRES;
96: #define HH(a,b) (lgmres->hh_origin + (b)*(lgmres->max_k+2)+(a))
97: /* HH will be size (max_k+2)*(max_k+1) - think of HH as
98: being stored columnwise (inc. zeros) for access purposes. */
99: #define HES(a,b) (lgmres->hes_origin + (b)*(lgmres->max_k+1)+(a))
100: /* HES will be size (max_k + 1) * (max_k + 1) -
101: again, think of HES as being stored columnwise */
102: #define CC(a) (lgmres->cc_origin + (a)) /* CC will be length (max_k+1) - cosines */
103: #define SS(a) (lgmres->ss_origin + (a)) /* SS will be length (max_k+1) - sines */
104: #define GRS(a) (lgmres->rs_origin + (a)) /* GRS will be length (max_k+2) - rt side */
106: /* vector names */
107: #define VEC_OFFSET 2
108: #define VEC_TEMP lgmres->vecs[0] /* work space */
109: #define VEC_TEMP_MATOP lgmres->vecs[1] /* work space */
110: #define VEC_VV(i) lgmres->vecs[VEC_OFFSET+i] /* use to access
111: othog basis vectors */
112: /*LGMRES_MOD */
113: #define AUG_OFFSET 1
114: #define AUGVEC(i) lgmres->augvecs[AUG_OFFSET+i] /*error approx vecors */
115: #define AUG_ORDER(i) lgmres->aug_order[i] /*order in which to augment */
116: #define A_AUGVEC(i) lgmres->augvecs[AUG_OFFSET+i+lgmres->aug_dim] /*A times error vector */
117: #define AUG_TEMP lgmres->augvecs[0] /* work vector */
118: #endif