| 6 |
dsic.upv.es!jroman |
1 |
|
|
|
2 |
/*
|
|
|
3 |
This file implements a wrapper to the BLZPACK package
|
|
|
4 |
*/
|
| 62 |
dsic.upv.es!antodo |
5 |
#include "src/eps/impls/blzpack/blzpackp.h" /*I "slepceps.h" I*/
|
| 6 |
dsic.upv.es!jroman |
6 |
|
| 114 |
dsic.upv.es!antodo |
7 |
const char* blzpack_error[33] = {
|
|
|
8 |
"",
|
|
|
9 |
"illegal data, LFLAG ",
|
|
|
10 |
"illegal data, dimension of (U), (V), (X) ",
|
|
|
11 |
"illegal data, leading dimension of (U), (V), (X) ",
|
|
|
12 |
"illegal data, leading dimension of (EIG) ",
|
|
|
13 |
"illegal data, number of required eigenpairs ",
|
|
|
14 |
"illegal data, Lanczos algorithm block size ",
|
|
|
15 |
"illegal data, maximum number of steps ",
|
|
|
16 |
"illegal data, number of starting vectors ",
|
|
|
17 |
"illegal data, number of eigenpairs provided ",
|
|
|
18 |
"illegal data, problem type flag ",
|
|
|
19 |
"illegal data, spectrum slicing flag ",
|
|
|
20 |
"illegal data, eigenvectors purification flag ",
|
|
|
21 |
"illegal data, level of output ",
|
|
|
22 |
"illegal data, output file unit ",
|
|
|
23 |
"illegal data, LCOMM (MPI or PVM) ",
|
|
|
24 |
"illegal data, dimension of ISTOR ",
|
|
|
25 |
"illegal data, convergence threshold ",
|
|
|
26 |
"illegal data, dimension of RSTOR ",
|
|
|
27 |
"illegal data on at least one PE ",
|
|
|
28 |
"ISTOR(3:14) must be equal on all PEs ",
|
|
|
29 |
"RSTOR(1:3) must be equal on all PEs ",
|
|
|
30 |
"not enough space in ISTOR to start eigensolution ",
|
|
|
31 |
"not enough space in RSTOR to start eigensolution ",
|
|
|
32 |
"illegal data, number of negative eigenvalues ",
|
|
|
33 |
"illegal data, entries of V ",
|
|
|
34 |
"illegal data, entries of X ",
|
|
|
35 |
"failure in computational subinterval ",
|
|
|
36 |
"file I/O error, blzpack.__.BQ ",
|
|
|
37 |
"file I/O error, blzpack.__.BX ",
|
|
|
38 |
"file I/O error, blzpack.__.Q ",
|
|
|
39 |
"file I/O error, blzpack.__.X ",
|
|
|
40 |
"parallel interface error "
|
|
|
41 |
};
|
|
|
42 |
|
| 6 |
dsic.upv.es!jroman |
43 |
#undef __FUNCT__
|
|
|
44 |
#define __FUNCT__ "EPSSetUp_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
45 |
PetscErrorCode EPSSetUp_BLZPACK(EPS eps)
|
| 6 |
dsic.upv.es!jroman |
46 |
{
|
| 476 |
dsic.upv.es!antodo |
47 |
PetscErrorCode ierr;
|
| 1089 |
slepc |
48 |
PetscInt N, n;
|
|
|
49 |
int listor, lrstor, ncuv, k1, k2, k3, k4;
|
| 476 |
dsic.upv.es!antodo |
50 |
EPS_BLZPACK *blz = (EPS_BLZPACK *)eps->data;
|
|
|
51 |
PetscTruth flg;
|
|
|
52 |
KSP ksp;
|
|
|
53 |
PC pc;
|
| 6 |
dsic.upv.es!jroman |
54 |
|
|
|
55 |
PetscFunctionBegin;
|
| 260 |
dsic.upv.es!antodo |
56 |
ierr = VecGetSize(eps->vec_initial,&N);CHKERRQ(ierr);
|
|
|
57 |
ierr = VecGetLocalSize(eps->vec_initial,&n);CHKERRQ(ierr);
|
|
|
58 |
if (eps->ncv) {
|
|
|
59 |
if( eps->ncv < PetscMin(eps->nev+10,eps->nev*2) )
|
|
|
60 |
SETERRQ(0,"Warning: BLZpack recommends that ncv be larger than min(nev+10,nev*2)");
|
|
|
61 |
}
|
|
|
62 |
else eps->ncv = PetscMin(eps->nev+10,eps->nev*2);
|
| 1220 |
slepc |
63 |
if (!eps->max_it) eps->max_it = PetscMax(1000,N);
|
| 260 |
dsic.upv.es!antodo |
64 |
|
| 6 |
dsic.upv.es!jroman |
65 |
if (!eps->ishermitian)
|
|
|
66 |
SETERRQ(PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");
|
| 420 |
dsic.upv.es!antodo |
67 |
if (blz->slice) {
|
|
|
68 |
ierr = PetscTypeCompare((PetscObject)eps->OP,STSINV,&flg);CHKERRQ(ierr);
|
|
|
69 |
if (!flg)
|
|
|
70 |
SETERRQ(PETSC_ERR_SUP,"Shift-and-invert ST is needed for spectrum slicing");
|
|
|
71 |
ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
|
|
|
72 |
ierr = PetscTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr);
|
|
|
73 |
if (!flg)
|
|
|
74 |
SETERRQ(PETSC_ERR_SUP,"Preonly KSP is needed for spectrum slicing");
|
|
|
75 |
ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
|
|
|
76 |
ierr = PetscTypeCompare((PetscObject)pc,PCCHOLESKY,&flg);CHKERRQ(ierr);
|
|
|
77 |
if (!flg)
|
|
|
78 |
SETERRQ(PETSC_ERR_SUP,"Cholesky PC is needed for spectrum slicing");
|
|
|
79 |
}
|
| 92 |
dsic.upv.es!antodo |
80 |
if (eps->which!=EPS_SMALLEST_REAL)
|
| 6 |
dsic.upv.es!jroman |
81 |
SETERRQ(1,"Wrong value of eps->which");
|
|
|
82 |
|
|
|
83 |
k1 = PetscMin(N,180);
|
| 211 |
dsic.upv.es!antodo |
84 |
k2 = blz->block_size;
|
| 6 |
dsic.upv.es!jroman |
85 |
k4 = PetscMin(eps->ncv,N);
|
|
|
86 |
k3 = 484+k1*(13+k1*2+k2+PetscMax(18,k2+2))+k2*k2*3+k4*2;
|
|
|
87 |
|
|
|
88 |
listor = 123+k1*12;
|
| 1040 |
slepc |
89 |
ierr = PetscFree(blz->istor);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
90 |
ierr = PetscMalloc((17+listor)*sizeof(int),&blz->istor);CHKERRQ(ierr);
|
|
|
91 |
blz->istor[14] = listor;
|
|
|
92 |
|
| 420 |
dsic.upv.es!antodo |
93 |
if (blz->slice) lrstor = n*(k2*4+k1*2+k4)+k3;
|
| 6 |
dsic.upv.es!jroman |
94 |
else lrstor = n*(k2*4+k1)+k3;
|
| 1040 |
slepc |
95 |
ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
96 |
ierr = PetscMalloc((4+lrstor)*sizeof(PetscReal),&blz->rstor);CHKERRQ(ierr);
|
|
|
97 |
blz->rstor[3] = lrstor;
|
|
|
98 |
|
|
|
99 |
ncuv = PetscMax(3,blz->block_size);
|
| 1040 |
slepc |
100 |
ierr = PetscFree(blz->u);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
101 |
ierr = PetscMalloc(ncuv*n*sizeof(PetscScalar),&blz->u);CHKERRQ(ierr);
|
| 1040 |
slepc |
102 |
ierr = PetscFree(blz->v);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
103 |
ierr = PetscMalloc(ncuv*n*sizeof(PetscScalar),&blz->v);CHKERRQ(ierr);
|
|
|
104 |
|
| 1040 |
slepc |
105 |
ierr = PetscFree(blz->eig);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
106 |
ierr = PetscMalloc(2*eps->ncv*sizeof(PetscReal),&blz->eig);CHKERRQ(ierr);
|
|
|
107 |
|
| 260 |
dsic.upv.es!antodo |
108 |
ierr = EPSAllocateSolutionContiguous(eps);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
109 |
PetscFunctionReturn(0);
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
#undef __FUNCT__
|
|
|
113 |
#define __FUNCT__ "EPSSolve_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
114 |
PetscErrorCode EPSSolve_BLZPACK(EPS eps)
|
| 6 |
dsic.upv.es!jroman |
115 |
{
|
| 476 |
dsic.upv.es!antodo |
116 |
PetscErrorCode ierr;
|
| 1089 |
slepc |
117 |
EPS_BLZPACK *blz = (EPS_BLZPACK *)eps->data;
|
|
|
118 |
PetscInt n, nn;
|
|
|
119 |
int i, nneig, lflag, nvopu;
|
| 476 |
dsic.upv.es!antodo |
120 |
Vec x, y;
|
|
|
121 |
PetscScalar sigma,*pV;
|
|
|
122 |
Mat A;
|
|
|
123 |
KSP ksp;
|
|
|
124 |
PC pc;
|
| 6 |
dsic.upv.es!jroman |
125 |
|
|
|
126 |
PetscFunctionBegin;
|
|
|
127 |
|
|
|
128 |
ierr = VecGetLocalSize(eps->vec_initial,&n); CHKERRQ(ierr);
|
|
|
129 |
ierr = VecCreateMPIWithArray(eps->comm,n,PETSC_DECIDE,PETSC_NULL,&x);CHKERRQ(ierr);
|
|
|
130 |
ierr = VecCreateMPIWithArray(eps->comm,n,PETSC_DECIDE,PETSC_NULL,&y);CHKERRQ(ierr);
|
|
|
131 |
ierr = VecGetArray(eps->V[0],&pV);CHKERRQ(ierr);
|
|
|
132 |
|
| 420 |
dsic.upv.es!antodo |
133 |
if (blz->slice) { ierr = STGetShift(eps->OP,&sigma);CHKERRQ(ierr); }
|
|
|
134 |
else sigma = 0.0; /* shift of origin */
|
|
|
135 |
nneig = 0; /* no. of eigs less than sigma */
|
|
|
136 |
|
| 6 |
dsic.upv.es!jroman |
137 |
blz->istor[0] = n; /* number of rows of U, V, X*/
|
|
|
138 |
blz->istor[1] = n; /* leading dimension of U, V, X */
|
|
|
139 |
blz->istor[2] = eps->nev; /* number of required eigenpairs */
|
|
|
140 |
blz->istor[3] = eps->ncv; /* number of working eigenpairs */
|
|
|
141 |
blz->istor[4] = blz->block_size; /* number of vectors in a block */
|
| 422 |
dsic.upv.es!antodo |
142 |
blz->istor[5] = blz->nsteps; /* maximun number of steps per run */
|
| 6 |
dsic.upv.es!jroman |
143 |
blz->istor[6] = 1; /* number of starting vectors as input */
|
|
|
144 |
blz->istor[7] = 0; /* number of eigenpairs given as input */
|
| 420 |
dsic.upv.es!antodo |
145 |
blz->istor[8] = blz->slice; /* problem type */
|
|
|
146 |
blz->istor[9] = blz->slice; /* spectrum slicing */
|
| 422 |
dsic.upv.es!antodo |
147 |
blz->istor[10] = blz->slice; /* solutions refinement (purify) */
|
| 420 |
dsic.upv.es!antodo |
148 |
blz->istor[11] = 0; /* level of printing */
|
| 6 |
dsic.upv.es!jroman |
149 |
blz->istor[12] = 6; /* file unit for output */
|
|
|
150 |
blz->istor[13] = MPI_Comm_c2f(eps->comm); /* communicator */
|
|
|
151 |
|
|
|
152 |
blz->rstor[0] = blz->initial; /* lower limit of eigenvalue interval */
|
|
|
153 |
blz->rstor[1] = blz->final; /* upper limit of eigenvalue interval */
|
|
|
154 |
blz->rstor[2] = eps->tol; /* threshold for convergence */
|
|
|
155 |
|
|
|
156 |
lflag = 0; /* reverse communication interface flag */
|
|
|
157 |
|
| 422 |
dsic.upv.es!antodo |
158 |
do {
|
| 6 |
dsic.upv.es!jroman |
159 |
|
|
|
160 |
BLZpack_( blz->istor, blz->rstor, &sigma, &nneig, blz->u, blz->v,
|
|
|
161 |
&lflag, &nvopu, blz->eig, pV );
|
|
|
162 |
|
| 422 |
dsic.upv.es!antodo |
163 |
switch (lflag) {
|
|
|
164 |
case 1:
|
| 6 |
dsic.upv.es!jroman |
165 |
/* compute v = OP u */
|
|
|
166 |
for (i=0;i<nvopu;i++) {
|
|
|
167 |
ierr = VecPlaceArray( x, blz->u+i*n );CHKERRQ(ierr);
|
|
|
168 |
ierr = VecPlaceArray( y, blz->v+i*n );CHKERRQ(ierr);
|
| 420 |
dsic.upv.es!antodo |
169 |
if (blz->slice) {
|
| 6 |
dsic.upv.es!jroman |
170 |
ierr = STApplyNoB( eps->OP, x, y ); CHKERRQ(ierr);
|
|
|
171 |
} else {
|
|
|
172 |
ierr = STApply( eps->OP, x, y ); CHKERRQ(ierr);
|
|
|
173 |
}
|
| 1163 |
slepc |
174 |
ierr = EPSOrthogonalize(eps,eps->nds,PETSC_NULL,eps->DS,y,PETSC_NULL,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
|
| 850 |
dsic.upv.es!antodo |
175 |
ierr = VecResetArray(x);CHKERRQ(ierr);
|
|
|
176 |
ierr = VecResetArray(y);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
177 |
}
|
| 422 |
dsic.upv.es!antodo |
178 |
/* monitor */
|
|
|
179 |
eps->nconv = BLZistorr_(blz->istor,"NTEIG",5);
|
|
|
180 |
EPSMonitor(eps,eps->its,eps->nconv,
|
|
|
181 |
blz->rstor+BLZistorr_(blz->istor,"IRITZ",5),
|
|
|
182 |
eps->eigi,
|
|
|
183 |
blz->rstor+BLZistorr_(blz->istor,"IRITZ",5)+BLZistorr_(blz->istor,"JT",2),
|
|
|
184 |
BLZistorr_(blz->istor,"NRITZ",5));
|
| 624 |
dsic.upv.es!antodo |
185 |
eps->its = eps->its + 1;
|
| 422 |
dsic.upv.es!antodo |
186 |
if (eps->its >= eps->max_it || eps->nconv >= eps->nev) lflag = 5;
|
|
|
187 |
break;
|
|
|
188 |
case 2:
|
| 6 |
dsic.upv.es!jroman |
189 |
/* compute v = B u */
|
|
|
190 |
for (i=0;i<nvopu;i++) {
|
|
|
191 |
ierr = VecPlaceArray( x, blz->u+i*n );CHKERRQ(ierr);
|
|
|
192 |
ierr = VecPlaceArray( y, blz->v+i*n );CHKERRQ(ierr);
|
|
|
193 |
ierr = STApplyB( eps->OP, x, y ); CHKERRQ(ierr);
|
| 850 |
dsic.upv.es!antodo |
194 |
ierr = VecResetArray(x);CHKERRQ(ierr);
|
|
|
195 |
ierr = VecResetArray(y);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
196 |
}
|
| 422 |
dsic.upv.es!antodo |
197 |
break;
|
|
|
198 |
case 3:
|
| 6 |
dsic.upv.es!jroman |
199 |
/* update shift */
|
| 420 |
dsic.upv.es!antodo |
200 |
ierr = STSetShift(eps->OP,sigma);CHKERRQ(ierr);
|
|
|
201 |
ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
|
|
|
202 |
ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
|
|
|
203 |
ierr = PCGetFactoredMatrix(pc,&A);CHKERRQ(ierr);
|
| 1089 |
slepc |
204 |
ierr = MatGetInertia(A,&nn,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
|
|
|
205 |
nneig = nn;
|
| 422 |
dsic.upv.es!antodo |
206 |
break;
|
|
|
207 |
case 4:
|
| 6 |
dsic.upv.es!jroman |
208 |
/* copy the initial vector */
|
|
|
209 |
ierr = VecPlaceArray(x,blz->v);CHKERRQ(ierr);
|
|
|
210 |
ierr = VecCopy(eps->vec_initial,x);CHKERRQ(ierr);
|
| 850 |
dsic.upv.es!antodo |
211 |
ierr = VecResetArray(x);CHKERRQ(ierr);
|
| 422 |
dsic.upv.es!antodo |
212 |
break;
|
| 6 |
dsic.upv.es!jroman |
213 |
}
|
| 422 |
dsic.upv.es!antodo |
214 |
|
|
|
215 |
} while (lflag > 0);
|
| 6 |
dsic.upv.es!jroman |
216 |
|
|
|
217 |
ierr = VecRestoreArray( eps->V[0], &pV ); CHKERRQ(ierr);
|
|
|
218 |
|
|
|
219 |
eps->nconv = BLZistorr_(blz->istor,"NTEIG",5);
|
|
|
220 |
eps->reason = EPS_CONVERGED_TOL;
|
|
|
221 |
|
|
|
222 |
for (i=0;i<eps->nconv;i++) {
|
|
|
223 |
eps->eigr[i]=blz->eig[i];
|
|
|
224 |
}
|
|
|
225 |
|
| 114 |
dsic.upv.es!antodo |
226 |
if (lflag!=0) {
|
|
|
227 |
char msg[2048] = "";
|
|
|
228 |
for (i = 0; i < 33; i++) {
|
| 134 |
dsic.upv.es!antodo |
229 |
if (blz->istor[15] & (1 << i)) PetscStrcat(msg, blzpack_error[i]);
|
| 114 |
dsic.upv.es!antodo |
230 |
}
|
|
|
231 |
SETERRQ2(PETSC_ERR_LIB,"Error in BLZPACK (code=%d): '%s'",blz->istor[15], msg);
|
|
|
232 |
}
|
| 6 |
dsic.upv.es!jroman |
233 |
ierr = VecDestroy(x);CHKERRQ(ierr);
|
|
|
234 |
ierr = VecDestroy(y);CHKERRQ(ierr);
|
|
|
235 |
|
|
|
236 |
PetscFunctionReturn(0);
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
#undef __FUNCT__
|
| 420 |
dsic.upv.es!antodo |
240 |
#define __FUNCT__ "EPSBackTransform_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
241 |
PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)
|
| 420 |
dsic.upv.es!antodo |
242 |
{
|
| 476 |
dsic.upv.es!antodo |
243 |
PetscErrorCode ierr;
|
|
|
244 |
EPS_BLZPACK *blz = (EPS_BLZPACK *)eps->data;
|
| 420 |
dsic.upv.es!antodo |
245 |
|
|
|
246 |
PetscFunctionBegin;
|
| 442 |
dsic.upv.es!antodo |
247 |
if (!blz->slice) {
|
|
|
248 |
ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr);
|
|
|
249 |
}
|
| 420 |
dsic.upv.es!antodo |
250 |
PetscFunctionReturn(0);
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
254 |
#define __FUNCT__ "EPSDestroy_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
255 |
PetscErrorCode EPSDestroy_BLZPACK(EPS eps)
|
| 6 |
dsic.upv.es!jroman |
256 |
{
|
| 476 |
dsic.upv.es!antodo |
257 |
PetscErrorCode ierr;
|
|
|
258 |
EPS_BLZPACK *blz = (EPS_BLZPACK *)eps->data;
|
| 6 |
dsic.upv.es!jroman |
259 |
|
|
|
260 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
261 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 1040 |
slepc |
262 |
ierr = PetscFree(blz->istor);CHKERRQ(ierr);
|
|
|
263 |
ierr = PetscFree(blz->rstor);CHKERRQ(ierr);
|
|
|
264 |
ierr = PetscFree(blz->u);CHKERRQ(ierr);
|
|
|
265 |
ierr = PetscFree(blz->v);CHKERRQ(ierr);
|
|
|
266 |
ierr = PetscFree(blz->eig);CHKERRQ(ierr);
|
|
|
267 |
ierr = PetscFree(eps->data);CHKERRQ(ierr);
|
| 260 |
dsic.upv.es!antodo |
268 |
ierr = EPSFreeSolutionContiguous(eps);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
269 |
PetscFunctionReturn(0);
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
#undef __FUNCT__
|
|
|
273 |
#define __FUNCT__ "EPSView_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
274 |
PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)
|
| 6 |
dsic.upv.es!jroman |
275 |
{
|
| 476 |
dsic.upv.es!antodo |
276 |
PetscErrorCode ierr;
|
|
|
277 |
EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;
|
|
|
278 |
PetscTruth isascii;
|
| 6 |
dsic.upv.es!jroman |
279 |
|
|
|
280 |
PetscFunctionBegin;
|
|
|
281 |
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
|
|
282 |
if (!isascii) {
|
|
|
283 |
SETERRQ1(1,"Viewer type %s not supported for EPSBLZPACK",((PetscObject)viewer)->type_name);
|
|
|
284 |
}
|
|
|
285 |
ierr = PetscViewerASCIIPrintf(viewer,"block size of the block-Lanczos algorithm: %d\n",blz->block_size);CHKERRQ(ierr);
|
|
|
286 |
ierr = PetscViewerASCIIPrintf(viewer,"computational interval: [%f,%f]\n",blz->initial,blz->final);CHKERRQ(ierr);
|
|
|
287 |
PetscFunctionReturn(0);
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
#undef __FUNCT__
|
|
|
291 |
#define __FUNCT__ "EPSSetFromOptions_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
292 |
PetscErrorCode EPSSetFromOptions_BLZPACK(EPS eps)
|
| 6 |
dsic.upv.es!jroman |
293 |
{
|
| 476 |
dsic.upv.es!antodo |
294 |
PetscErrorCode ierr;
|
|
|
295 |
EPS_BLZPACK *blz = (EPS_BLZPACK *)eps->data;
|
| 1089 |
slepc |
296 |
PetscInt bs,n;
|
| 476 |
dsic.upv.es!antodo |
297 |
PetscReal interval[2];
|
|
|
298 |
PetscTruth flg;
|
|
|
299 |
KSP ksp;
|
|
|
300 |
PC pc;
|
| 6 |
dsic.upv.es!jroman |
301 |
|
|
|
302 |
PetscFunctionBegin;
|
|
|
303 |
ierr = PetscOptionsHead("BLZPACK options");CHKERRQ(ierr);
|
|
|
304 |
|
| 444 |
dsic.upv.es!antodo |
305 |
bs = blz->block_size;
|
|
|
306 |
ierr = PetscOptionsInt("-eps_blzpack_block_size","Block size","EPSBlzpackSetBlockSize",bs,&bs,&flg);CHKERRQ(ierr);
|
|
|
307 |
if (flg) {ierr = EPSBlzpackSetBlockSize(eps,bs);CHKERRQ(ierr);}
|
| 6 |
dsic.upv.es!jroman |
308 |
|
| 444 |
dsic.upv.es!antodo |
309 |
n = blz->nsteps;
|
|
|
310 |
ierr = PetscOptionsInt("-eps_blzpack_nsteps","Number of steps","EPSBlzpackSetNSteps",n,&n,&flg);CHKERRQ(ierr);
|
|
|
311 |
if (flg) {ierr = EPSBlzpackSetNSteps(eps,n);CHKERRQ(ierr);}
|
| 422 |
dsic.upv.es!antodo |
312 |
|
| 444 |
dsic.upv.es!antodo |
313 |
interval[0] = blz->initial;
|
|
|
314 |
interval[1] = blz->final;
|
|
|
315 |
n = 2;
|
|
|
316 |
ierr = PetscOptionsRealArray("-eps_blzpack_interval","Computational interval","EPSBlzpackSetInterval",interval,&n,&flg);CHKERRQ(ierr);
|
|
|
317 |
if (flg) {
|
|
|
318 |
if (n==1) interval[1]=interval[0];
|
|
|
319 |
ierr = EPSBlzpackSetInterval(eps,interval[0],interval[1]);CHKERRQ(ierr);
|
|
|
320 |
}
|
| 6 |
dsic.upv.es!jroman |
321 |
|
| 444 |
dsic.upv.es!antodo |
322 |
if (blz->slice) {
|
|
|
323 |
ierr = STSetType(eps->OP,STSINV);CHKERRQ(ierr);
|
|
|
324 |
ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
|
|
|
325 |
ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr);
|
|
|
326 |
ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr);
|
|
|
327 |
ierr = PCSetType(pc,PCCHOLESKY);CHKERRQ(ierr);
|
|
|
328 |
}
|
|
|
329 |
|
| 6 |
dsic.upv.es!jroman |
330 |
ierr = PetscOptionsTail();CHKERRQ(ierr);
|
|
|
331 |
PetscFunctionReturn(0);
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
EXTERN_C_BEGIN
|
|
|
335 |
#undef __FUNCT__
|
|
|
336 |
#define __FUNCT__ "EPSBlzpackSetBlockSize_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
337 |
PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,int bs)
|
| 6 |
dsic.upv.es!jroman |
338 |
{
|
| 476 |
dsic.upv.es!antodo |
339 |
EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;;
|
| 6 |
dsic.upv.es!jroman |
340 |
|
|
|
341 |
PetscFunctionBegin;
|
| 211 |
dsic.upv.es!antodo |
342 |
if (bs == PETSC_DEFAULT) blz->block_size = 3;
|
|
|
343 |
else if (bs <= 0) {
|
|
|
344 |
SETERRQ(1, "Incorrect block size");
|
|
|
345 |
} else blz->block_size = bs;
|
| 6 |
dsic.upv.es!jroman |
346 |
PetscFunctionReturn(0);
|
|
|
347 |
}
|
|
|
348 |
EXTERN_C_END
|
|
|
349 |
|
|
|
350 |
#undef __FUNCT__
|
|
|
351 |
#define __FUNCT__ "EPSBlzpackSetBlockSize"
|
|
|
352 |
/*@
|
|
|
353 |
EPSBlzpackSetBlockSize - Sets the block size for the BLZPACK package.
|
|
|
354 |
|
|
|
355 |
Collective on EPS
|
|
|
356 |
|
|
|
357 |
Input Parameters:
|
|
|
358 |
+ eps - the eigenproblem solver context
|
|
|
359 |
- bs - block size
|
|
|
360 |
|
|
|
361 |
Options Database Key:
|
|
|
362 |
. -eps_blzpack_block_size - Sets the value of the block size
|
|
|
363 |
|
|
|
364 |
Level: advanced
|
|
|
365 |
|
| 553 |
dsic.upv.es!jroman |
366 |
.seealso: EPSBlzpackSetInterval()
|
| 6 |
dsic.upv.es!jroman |
367 |
@*/
|
| 476 |
dsic.upv.es!antodo |
368 |
PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,int bs)
|
| 6 |
dsic.upv.es!jroman |
369 |
{
|
| 476 |
dsic.upv.es!antodo |
370 |
PetscErrorCode ierr, (*f)(EPS,int);
|
| 6 |
dsic.upv.es!jroman |
371 |
|
|
|
372 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
373 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
374 |
ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",(void (**)())&f);CHKERRQ(ierr);
|
|
|
375 |
if (f) {
|
|
|
376 |
ierr = (*f)(eps,bs);CHKERRQ(ierr);
|
|
|
377 |
}
|
|
|
378 |
PetscFunctionReturn(0);
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
EXTERN_C_BEGIN
|
|
|
382 |
#undef __FUNCT__
|
|
|
383 |
#define __FUNCT__ "EPSBlzpackSetInterval_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
384 |
PetscErrorCode EPSBlzpackSetInterval_BLZPACK(EPS eps,PetscReal initial,PetscReal final)
|
| 6 |
dsic.upv.es!jroman |
385 |
{
|
| 476 |
dsic.upv.es!antodo |
386 |
EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;;
|
| 6 |
dsic.upv.es!jroman |
387 |
|
|
|
388 |
PetscFunctionBegin;
|
|
|
389 |
blz->initial = initial;
|
|
|
390 |
blz->final = final;
|
| 420 |
dsic.upv.es!antodo |
391 |
blz->slice = 1;
|
| 6 |
dsic.upv.es!jroman |
392 |
PetscFunctionReturn(0);
|
|
|
393 |
}
|
|
|
394 |
EXTERN_C_END
|
|
|
395 |
|
|
|
396 |
#undef __FUNCT__
|
|
|
397 |
#define __FUNCT__ "EPSBlzpackSetInterval"
|
|
|
398 |
/*@
|
|
|
399 |
EPSBlzpackSetInterval - Sets the computational interval for the BLZPACK
|
|
|
400 |
package.
|
|
|
401 |
|
|
|
402 |
Collective on EPS
|
|
|
403 |
|
|
|
404 |
Input Parameters:
|
|
|
405 |
+ eps - the eigenproblem solver context
|
|
|
406 |
. initial - lower bound of the interval
|
|
|
407 |
- final - upper bound of the interval
|
|
|
408 |
|
|
|
409 |
Options Database Key:
|
|
|
410 |
. -eps_blzpack_interval - Sets the bounds of the interval (two values
|
|
|
411 |
separated by commas)
|
|
|
412 |
|
|
|
413 |
Note:
|
|
|
414 |
The following possibilities are accepted (see Blzpack user's guide for
|
|
|
415 |
details).
|
|
|
416 |
initial>final: start seeking for eigenpairs in the upper bound
|
|
|
417 |
initial<final: start in the lower bound
|
|
|
418 |
initial=final: run around a single value (no interval)
|
|
|
419 |
|
|
|
420 |
Level: advanced
|
|
|
421 |
|
|
|
422 |
.seealso: EPSBlzpackSetBlockSize()
|
|
|
423 |
@*/
|
| 476 |
dsic.upv.es!antodo |
424 |
PetscErrorCode EPSBlzpackSetInterval(EPS eps,PetscReal initial,PetscReal final)
|
| 6 |
dsic.upv.es!jroman |
425 |
{
|
| 476 |
dsic.upv.es!antodo |
426 |
PetscErrorCode ierr, (*f)(EPS,PetscReal,PetscReal);
|
| 6 |
dsic.upv.es!jroman |
427 |
|
|
|
428 |
PetscFunctionBegin;
|
| 25 |
dsic.upv.es!jroman |
429 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
| 6 |
dsic.upv.es!jroman |
430 |
ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetInterval_C",(void (**)())&f);CHKERRQ(ierr);
|
|
|
431 |
if (f) {
|
|
|
432 |
ierr = (*f)(eps,initial,final);CHKERRQ(ierr);
|
|
|
433 |
}
|
|
|
434 |
PetscFunctionReturn(0);
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
EXTERN_C_BEGIN
|
|
|
438 |
#undef __FUNCT__
|
| 422 |
dsic.upv.es!antodo |
439 |
#define __FUNCT__ "EPSBlzpackSetNSteps_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
440 |
PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,int nsteps)
|
| 422 |
dsic.upv.es!antodo |
441 |
{
|
| 476 |
dsic.upv.es!antodo |
442 |
EPS_BLZPACK *blz = (EPS_BLZPACK *) eps->data;
|
| 422 |
dsic.upv.es!antodo |
443 |
|
|
|
444 |
PetscFunctionBegin;
|
|
|
445 |
blz->nsteps = nsteps == PETSC_DEFAULT ? 0 : nsteps;
|
|
|
446 |
PetscFunctionReturn(0);
|
|
|
447 |
}
|
|
|
448 |
EXTERN_C_END
|
|
|
449 |
|
|
|
450 |
#undef __FUNCT__
|
|
|
451 |
#define __FUNCT__ "EPSBlzpackSetNSteps"
|
|
|
452 |
/*@
|
|
|
453 |
EPSBlzpackSetNSteps - Sets the maximum number of steps per run for the BLZPACK
|
|
|
454 |
package.
|
|
|
455 |
|
|
|
456 |
Collective on EPS
|
|
|
457 |
|
|
|
458 |
Input Parameters:
|
|
|
459 |
+ eps - the eigenproblem solver context
|
|
|
460 |
- nsteps - maximum number of steps
|
|
|
461 |
|
|
|
462 |
Options Database Key:
|
| 424 |
dsic.upv.es!antodo |
463 |
. -eps_blzpack_nsteps - Sets the maximum number of steps per run
|
| 422 |
dsic.upv.es!antodo |
464 |
|
|
|
465 |
Level: advanced
|
|
|
466 |
|
|
|
467 |
@*/
|
| 476 |
dsic.upv.es!antodo |
468 |
PetscErrorCode EPSBlzpackSetNSteps(EPS eps,int nsteps)
|
| 422 |
dsic.upv.es!antodo |
469 |
{
|
| 476 |
dsic.upv.es!antodo |
470 |
PetscErrorCode ierr, (*f)(EPS,int);
|
| 422 |
dsic.upv.es!antodo |
471 |
|
|
|
472 |
PetscFunctionBegin;
|
|
|
473 |
PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
|
|
|
474 |
ierr = PetscObjectQueryFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",(void (**)())&f);CHKERRQ(ierr);
|
|
|
475 |
if (f) {
|
|
|
476 |
ierr = (*f)(eps,nsteps);CHKERRQ(ierr);
|
|
|
477 |
}
|
|
|
478 |
PetscFunctionReturn(0);
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
EXTERN_C_BEGIN
|
|
|
482 |
#undef __FUNCT__
|
| 6 |
dsic.upv.es!jroman |
483 |
#define __FUNCT__ "EPSCreate_BLZPACK"
|
| 476 |
dsic.upv.es!antodo |
484 |
PetscErrorCode EPSCreate_BLZPACK(EPS eps)
|
| 6 |
dsic.upv.es!jroman |
485 |
{
|
| 476 |
dsic.upv.es!antodo |
486 |
PetscErrorCode ierr;
|
|
|
487 |
EPS_BLZPACK *blzpack;
|
| 6 |
dsic.upv.es!jroman |
488 |
|
|
|
489 |
PetscFunctionBegin;
|
|
|
490 |
ierr = PetscNew(EPS_BLZPACK,&blzpack);CHKERRQ(ierr);
|
|
|
491 |
PetscLogObjectMemory(eps,sizeof(EPS_BLZPACK));
|
|
|
492 |
eps->data = (void *) blzpack;
|
| 503 |
dsic.upv.es!antodo |
493 |
eps->ops->solve = EPSSolve_BLZPACK;
|
| 6 |
dsic.upv.es!jroman |
494 |
eps->ops->setup = EPSSetUp_BLZPACK;
|
| 503 |
dsic.upv.es!antodo |
495 |
eps->ops->setfromoptions = EPSSetFromOptions_BLZPACK;
|
| 6 |
dsic.upv.es!jroman |
496 |
eps->ops->destroy = EPSDestroy_BLZPACK;
|
|
|
497 |
eps->ops->view = EPSView_BLZPACK;
|
| 420 |
dsic.upv.es!antodo |
498 |
eps->ops->backtransform = EPSBackTransform_BLZPACK;
|
| 503 |
dsic.upv.es!antodo |
499 |
eps->ops->computevectors = EPSComputeVectors_Default;
|
| 6 |
dsic.upv.es!jroman |
500 |
|
| 211 |
dsic.upv.es!antodo |
501 |
blzpack->block_size = 3;
|
| 6 |
dsic.upv.es!jroman |
502 |
blzpack->initial = 0.0;
|
|
|
503 |
blzpack->final = 0.0;
|
| 420 |
dsic.upv.es!antodo |
504 |
blzpack->slice = 0;
|
| 422 |
dsic.upv.es!antodo |
505 |
blzpack->nsteps = 0;
|
|
|
506 |
|
|
|
507 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetBlockSize_C","EPSBlzpackSetBlockSize_BLZPACK",EPSBlzpackSetBlockSize_BLZPACK);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
508 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetInterval_C","EPSBlzpackSetInterval_BLZPACK",EPSBlzpackSetInterval_BLZPACK);CHKERRQ(ierr);
|
| 422 |
dsic.upv.es!antodo |
509 |
ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSBlzpackSetNSteps_C","EPSBlzpackSetNSteps_BLZPACK",EPSBlzpackSetNSteps_BLZPACK);CHKERRQ(ierr);
|
| 6 |
dsic.upv.es!jroman |
510 |
|
| 104 |
dsic.upv.es!antodo |
511 |
eps->which = EPS_SMALLEST_REAL;
|
|
|
512 |
|
| 6 |
dsic.upv.es!jroman |
513 |
PetscFunctionReturn(0);
|
|
|
514 |
}
|
|
|
515 |
EXTERN_C_END
|