Actual source code: lgmresp.h
1: /* A. Baker */
2: /*
3: Private data structure used by the LGMRES method.
4: */
9: #include private/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: /* currently only augvecs_user_work[0] is used, not sure if this will be */
73: /* extended in the future to use more, or if this is a design bug */
74: PetscInt aug_vv_allocated; /* aug_vv_allocated is the number of allocated lgmres
75: augmentation vectors */
76: PetscInt aug_vecs_allocated; /* aug_vecs_allocated is the total number of augmentation vecs
77: available - used to simplify the dynamic
78: allocation of vectors */
80: PetscInt augwork_alloc; /*size of chunk allocated for augmentation vectors */
82: PetscInt aug_dim; /* max number of augmented directions to add */
84: PetscInt aug_ct; /* number of aug. vectors available */
86: PetscInt *aug_order; /*keeps track of order to use aug. vectors*/
88: PetscInt approx_constant; /* = 1 then the approx space at each restart will
89: be size max_k . Therefore, more than (max_k - aug_dim)
90: krylov vectors may be used if less than aug_dim error
91: approximations are available (in the first few restarts,
92: for example) to keep the space a constant size. */
93:
94: PetscInt matvecs; /*keep track of matvecs */
95: } KSP_LGMRES;
98: #define HH(a,b) (lgmres->hh_origin + (b)*(lgmres->max_k+2)+(a))
99: /* HH will be size (max_k+2)*(max_k+1) - think of HH as
100: being stored columnwise (inc. zeros) for access purposes. */
101: #define HES(a,b) (lgmres->hes_origin + (b)*(lgmres->max_k+1)+(a))
102: /* HES will be size (max_k + 1) * (max_k + 1) -
103: again, think of HES as being stored columnwise */
104: #define CC(a) (lgmres->cc_origin + (a)) /* CC will be length (max_k+1) - cosines */
105: #define SS(a) (lgmres->ss_origin + (a)) /* SS will be length (max_k+1) - sines */
106: #define GRS(a) (lgmres->rs_origin + (a)) /* GRS will be length (max_k+2) - rt side */
108: /* vector names */
109: #define VEC_OFFSET 2
110: #define VEC_TEMP lgmres->vecs[0] /* work space */
111: #define VEC_TEMP_MATOP lgmres->vecs[1] /* work space */
112: #define VEC_VV(i) lgmres->vecs[VEC_OFFSET+i] /* use to access
113: othog basis vectors */
114: /*LGMRES_MOD */
115: #define AUG_OFFSET 1
116: #define AUGVEC(i) lgmres->augvecs[AUG_OFFSET+i] /*error approx vecors */
117: #define AUG_ORDER(i) lgmres->aug_order[i] /*order in which to augment */
118: #define A_AUGVEC(i) lgmres->augvecs[AUG_OFFSET+i+lgmres->aug_dim] /*A times error vector */
119: #define AUG_TEMP lgmres->augvecs[0] /* work vector */
120: #endif