Subversion Repositories slepc-dev

Rev

Details | Compare with Previous | Last modification | View Log | RSS feed

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