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