Subversion Repositories slepc-dev

Rev

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

Rev Author Line No. Line
1976 eromero 1
/*
2110 jroman 2
  SLEPc eigensolver: "jd"
1976 eromero 3
 
2110 jroman 4
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5
   SLEPc - Scalable Library for Eigenvalue Problem Computations
2575 eromero 6
   Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain
1976 eromero 7
 
2110 jroman 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/>.
21
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1976 eromero 22
*/
23
 
2283 jroman 24
#include <private/epsimpl.h>                /*I "slepceps.h" I*/
25
#include <private/stimpl.h>                 /*I "slepcst.h" I*/
26
#include <../src/eps/impls/davidson/common/davidson.h>
27
#include <slepcblaslapack.h>
1976 eromero 28
 
2003 eromero 29
PetscErrorCode EPSSetUp_JD(EPS eps);
1994 eromero 30
PetscErrorCode EPSDestroy_JD(EPS eps);
1976 eromero 31
 
32
EXTERN_C_BEGIN
33
#undef __FUNCT__  
1994 eromero 34
#define __FUNCT__ "EPSSetFromOptions_JD"
35
PetscErrorCode EPSSetFromOptions_JD(EPS eps)
1976 eromero 36
{
2317 jroman 37
  PetscErrorCode ierr;
38
  PetscBool      flg,op;
39
  PetscInt       opi,opi0;
40
  PetscReal      opf;
2616 eromero 41
  KSP            ksp;
1976 eromero 42
 
43
  PetscFunctionBegin;
2384 jroman 44
  ierr = PetscOptionsHead("EPS Jacobi-Davidson (JD) Options");CHKERRQ(ierr);
1976 eromero 45
 
2331 jroman 46
  ierr = EPSJDGetKrylovStart(eps,&op);CHKERRQ(ierr);
2330 jroman 47
  ierr = PetscOptionsBool("-eps_jd_krylov_start","Start the searching subspace with a krylov basis","EPSJDSetKrylovStart",op,&op,&flg);CHKERRQ(ierr);
2331 jroman 48
  if(flg) { ierr = EPSJDSetKrylovStart(eps,op);CHKERRQ(ierr); }
1976 eromero 49
 
2331 jroman 50
  ierr = EPSJDGetBlockSize(eps,&opi);CHKERRQ(ierr);
2330 jroman 51
  ierr = PetscOptionsInt("-eps_jd_blocksize","Number vectors add to the searching subspace","EPSJDSetBlockSize",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 52
  if(flg) { ierr = EPSJDSetBlockSize(eps,opi);CHKERRQ(ierr); }
1976 eromero 53
 
2331 jroman 54
  ierr = EPSJDGetRestart(eps,&opi,&opi0);CHKERRQ(ierr);
2330 jroman 55
  ierr = PetscOptionsInt("-eps_jd_minv","Set the size of the searching subspace after restarting","EPSJDSetRestart",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 56
  if(flg) { ierr = EPSJDSetRestart(eps,opi,opi0);CHKERRQ(ierr); }
1976 eromero 57
 
2330 jroman 58
  ierr = PetscOptionsInt("-eps_jd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSJDSetRestart",opi0,&opi0,&flg);CHKERRQ(ierr);
2331 jroman 59
  if(flg) { ierr = EPSJDSetRestart(eps,opi,opi0);CHKERRQ(ierr); }
1976 eromero 60
 
2331 jroman 61
  ierr = EPSJDGetInitialSize(eps,&opi);CHKERRQ(ierr);
2330 jroman 62
  ierr = PetscOptionsInt("-eps_jd_initial_size","Set the initial size of the searching subspace","EPSJDSetInitialSize",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 63
  if(flg) { ierr = EPSJDSetInitialSize(eps,opi);CHKERRQ(ierr); }
1980 eromero 64
 
2331 jroman 65
  ierr = EPSJDGetFix(eps,&opf);CHKERRQ(ierr);
2330 jroman 66
  ierr = PetscOptionsReal("-eps_jd_fix","Set the tolerance for changing the target in the correction equation","EPSJDSetFix",opf,&opf,&flg);CHKERRQ(ierr);
2331 jroman 67
  if(flg) { ierr = EPSJDSetFix(eps,opf);CHKERRQ(ierr); }
1994 eromero 68
 
2608 eromero 69
  ierr = EPSJDGetConstantCorrectionTolerance(eps,&op);CHKERRQ(ierr);
2611 eromero 70
  ierr = PetscOptionsBool("-eps_jd_constant_correction_tolerance","Disable the dynamic stopping criterion when solving the correction equation","EPSJDSetConstantCorrectionTolerance",op,&op,&flg);CHKERRQ(ierr);
2608 eromero 71
  if(flg) { ierr = EPSJDSetConstantCorrectionTolerance(eps,op);CHKERRQ(ierr); }
72
 
2611 eromero 73
  ierr = EPSJDGetWindowSizes(eps,&opi,&opi0);CHKERRQ(ierr);
2630 eromero 74
  ierr = PetscOptionsInt("-eps_jd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSJDSetWindowSizes",opi,&opi,&flg);CHKERRQ(ierr);
2611 eromero 75
  if(flg) { ierr = EPSJDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); }
76
 
2630 eromero 77
  ierr = PetscOptionsInt("-eps_jd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSJDSetWindowSizes",opi0,&opi0,&flg);CHKERRQ(ierr);
2611 eromero 78
  if(flg) { ierr = EPSJDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); }
79
 
2384 jroman 80
  ierr = PetscOptionsTail();CHKERRQ(ierr);
2616 eromero 81
 
82
  /* Set STPrecond as the default ST */
83
  if (!((PetscObject)eps->OP)->type_name) {
84
    ierr = STSetType(eps->OP,STPRECOND);CHKERRQ(ierr);
85
  }
86
  ierr = STPrecondSetKSPHasMat(eps->OP,PETSC_FALSE);CHKERRQ(ierr);
87
 
88
  /* Set the default options of the KSP */
89
  ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
90
  if (!((PetscObject)ksp)->type_name) {
91
    ierr = KSPSetType(ksp,KSPGMRES);CHKERRQ(ierr);
92
    ierr = KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);CHKERRQ(ierr);
93
  }
94
 
1976 eromero 95
  PetscFunctionReturn(0);
96
}  
97
EXTERN_C_END
98
 
99
#undef __FUNCT__  
2003 eromero 100
#define __FUNCT__ "EPSSetUp_JD"
101
PetscErrorCode EPSSetUp_JD(EPS eps)
102
{
2317 jroman 103
  PetscErrorCode ierr;
104
  PetscBool      t;
105
  KSP            ksp;
2003 eromero 106
 
107
  PetscFunctionBegin;
2616 eromero 108
 
2104 eromero 109
  /* Setup common for all davidson solvers */
2330 jroman 110
  ierr = EPSSetUp_Davidson(eps);CHKERRQ(ierr);
2104 eromero 111
 
2616 eromero 112
  /* Set the default options of the KSP */
113
  ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
114
  if (!((PetscObject)ksp)->type_name) {
115
    ierr = KSPSetType(ksp,KSPGMRES);CHKERRQ(ierr);
116
    ierr = KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);CHKERRQ(ierr);
117
  }
118
 
2003 eromero 119
  /* Check some constraints */
2331 jroman 120
  ierr = PetscTypeCompare((PetscObject)ksp,KSPPREONLY,&t);CHKERRQ(ierr);
121
  if (t) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_SUP,"EPSJD does not work with KSPPREONLY");
2003 eromero 122
  PetscFunctionReturn(0);
123
}
124
 
125
EXTERN_C_BEGIN
126
#undef __FUNCT__  
1994 eromero 127
#define __FUNCT__ "EPSCreate_JD"
2317 jroman 128
PetscErrorCode EPSCreate_JD(EPS eps)
129
{
130
  PetscErrorCode ierr;
1976 eromero 131
 
132
  PetscFunctionBegin;
2324 jroman 133
  /* Load the Davidson solver */
2330 jroman 134
  ierr = EPSCreate_Davidson(eps);CHKERRQ(ierr);
1976 eromero 135
 
1994 eromero 136
  /* Overload the JD properties */
137
  eps->ops->setfromoptions       = EPSSetFromOptions_JD;
2003 eromero 138
  eps->ops->setup                = EPSSetUp_JD;
1994 eromero 139
  eps->ops->destroy              = EPSDestroy_JD;
1976 eromero 140
 
2324 jroman 141
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetKrylovStart_C","EPSDavidsonSetKrylovStart_Davidson",EPSDavidsonSetKrylovStart_Davidson);CHKERRQ(ierr);
142
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetKrylovStart_C","EPSDavidsonGetKrylovStart_Davidson",EPSDavidsonGetKrylovStart_Davidson);CHKERRQ(ierr);
143
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetBlockSize_C","EPSDavidsonSetBlockSize_Davidson",EPSDavidsonSetBlockSize_Davidson);CHKERRQ(ierr);
144
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetBlockSize_C","EPSDavidsonGetBlockSize_Davidson",EPSDavidsonGetBlockSize_Davidson);CHKERRQ(ierr);
145
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetRestart_C","EPSDavidsonSetRestart_Davidson",EPSDavidsonSetRestart_Davidson);CHKERRQ(ierr);
146
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetRestart_C","EPSDavidsonGetRestart_Davidson",EPSDavidsonGetRestart_Davidson);CHKERRQ(ierr);
147
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetInitialSize_C","EPSDavidsonSetInitialSize_Davidson",EPSDavidsonSetInitialSize_Davidson);CHKERRQ(ierr);
148
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetInitialSize_C","EPSDavidsonGetInitialSize_Davidson",EPSDavidsonGetInitialSize_Davidson);CHKERRQ(ierr);
149
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetFix_C","EPSDavidsonSetFix_Davidson",EPSDavidsonSetFix_Davidson);CHKERRQ(ierr);
150
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetFix_C","EPSDavidsonGetFix_Davidson",EPSDavidsonGetFix_Davidson);CHKERRQ(ierr);
2608 eromero 151
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetConstantCorrectionTolerance_C","EPSDavidsonSetConstantCorrectionTolerance_Davidson",EPSDavidsonSetConstantCorrectionTolerance_Davidson);CHKERRQ(ierr);
152
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetConstantCorrectionTolerance_C","EPSDavidsonGetConstantCorrectionTolerance_Davidson",EPSDavidsonGetConstantCorrectionTolerance_Davidson);CHKERRQ(ierr);
2611 eromero 153
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetWindowSizes_C","EPSDavidsonSetWindowSizes_Davidson",EPSDavidsonSetWindowSizes_Davidson);CHKERRQ(ierr);
154
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetWindowSizes_C","EPSDavidsonGetWindowSizes_Davidson",EPSDavidsonGetWindowSizes_Davidson);CHKERRQ(ierr);
1976 eromero 155
  PetscFunctionReturn(0);
156
}
157
EXTERN_C_END
158
 
1980 eromero 159
#undef __FUNCT__  
1994 eromero 160
#define __FUNCT__ "EPSDestroy_JD"
161
PetscErrorCode EPSDestroy_JD(EPS eps)
1992 eromero 162
{
1980 eromero 163
  PetscErrorCode  ierr;
1976 eromero 164
 
1980 eromero 165
  PetscFunctionBegin;
2348 jroman 166
  ierr = PetscFree(eps->data);CHKERRQ(ierr);
1994 eromero 167
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetKrylovStart_C","",PETSC_NULL);CHKERRQ(ierr);
168
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetKrylovStart_C","",PETSC_NULL);CHKERRQ(ierr);
169
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetBlockSize_C","",PETSC_NULL);CHKERRQ(ierr);
170
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetBlockSize_C","",PETSC_NULL);CHKERRQ(ierr);
171
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetRestart_C","",PETSC_NULL);CHKERRQ(ierr);
172
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetRestart_C","",PETSC_NULL);CHKERRQ(ierr);
173
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetInitialSize_C","",PETSC_NULL);CHKERRQ(ierr);
174
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetInitialSize_C","",PETSC_NULL);CHKERRQ(ierr);
175
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetFix_C","",PETSC_NULL);CHKERRQ(ierr);
176
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetFix_C","",PETSC_NULL);CHKERRQ(ierr);
2608 eromero 177
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetConstantCorrectionTolerance_C","",PETSC_NULL);CHKERRQ(ierr);
178
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetConstantCorrectionTolerance_C","",PETSC_NULL);CHKERRQ(ierr);
2611 eromero 179
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDSetWindowSizes_C","",PETSC_NULL);CHKERRQ(ierr);
180
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSJDGetWindowSizes_C","",PETSC_NULL);CHKERRQ(ierr);
1980 eromero 181
  PetscFunctionReturn(0);
182
}
183
 
1976 eromero 184
#undef __FUNCT__  
1994 eromero 185
#define __FUNCT__ "EPSJDSetKrylovStart"
1976 eromero 186
/*@
1994 eromero 187
   EPSJDSetKrylovStart - Activates or deactivates starting the searching
1976 eromero 188
   subspace with a Krylov basis.
189
 
2328 jroman 190
   Logically Collective on EPS
1976 eromero 191
 
192
   Input Parameters:
193
+  eps - the eigenproblem solver context
194
-  krylovstart - boolean flag
195
 
196
   Options Database Key:
1994 eromero 197
.  -eps_jd_krylov_start - Activates starting the searching subspace with a
1976 eromero 198
    Krylov basis
199
 
200
   Level: advanced
201
 
1994 eromero 202
.seealso: EPSJDGetKrylovStart()
1976 eromero 203
@*/
2216 jroman 204
PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart)
1980 eromero 205
{
2221 jroman 206
  PetscErrorCode ierr;
1976 eromero 207
 
1980 eromero 208
  PetscFunctionBegin;
2213 jroman 209
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 210
  PetscValidLogicalCollectiveBool(eps,krylovstart,2);
2221 jroman 211
  ierr = PetscTryMethod(eps,"EPSJDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));CHKERRQ(ierr);
1980 eromero 212
  PetscFunctionReturn(0);
213
}
1976 eromero 214
 
215
#undef __FUNCT__  
1994 eromero 216
#define __FUNCT__ "EPSJDGetKrylovStart"
1985 eromero 217
/*@
2328 jroman 218
   EPSJDGetKrylovStart - Returns a flag indicating if the searching subspace is started with a
1976 eromero 219
   Krylov basis.
220
 
2328 jroman 221
   Not Collective
1976 eromero 222
 
223
   Input Parameter:
224
.  eps - the eigenproblem solver context
225
 
1994 eromero 226
   Output Parameters:
2328 jroman 227
.  krylovstart - boolean flag indicating if the searching subspace is started
228
   with a Krylov basis
1976 eromero 229
 
230
   Level: advanced
231
 
1994 eromero 232
.seealso: EPSJDGetKrylovStart()
1976 eromero 233
@*/
2216 jroman 234
PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart)
1980 eromero 235
{
2221 jroman 236
  PetscErrorCode ierr;
1976 eromero 237
 
1980 eromero 238
  PetscFunctionBegin;
2213 jroman 239
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 240
  PetscValidPointer(krylovstart,2);
2221 jroman 241
  ierr = PetscTryMethod(eps,"EPSJDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));CHKERRQ(ierr);
1980 eromero 242
  PetscFunctionReturn(0);
243
}
244
 
1976 eromero 245
#undef __FUNCT__  
1994 eromero 246
#define __FUNCT__ "EPSJDSetBlockSize"
1976 eromero 247
/*@
2328 jroman 248
   EPSJDSetBlockSize - Sets the number of vectors to be added to the searching space
249
   in every iteration.
1976 eromero 250
 
2328 jroman 251
   Logically Collective on EPS
1976 eromero 252
 
253
   Input Parameters:
254
+  eps - the eigenproblem solver context
2328 jroman 255
-  blocksize - number of vectors added to the search space in every iteration
1976 eromero 256
 
257
   Options Database Key:
2328 jroman 258
.  -eps_jd_blocksize - number of vectors added to the searching space every iteration
1976 eromero 259
 
260
   Level: advanced
261
 
1994 eromero 262
.seealso: EPSJDSetKrylovStart()
1976 eromero 263
@*/
1994 eromero 264
PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize)
1980 eromero 265
{
2221 jroman 266
  PetscErrorCode ierr;
1976 eromero 267
 
1980 eromero 268
  PetscFunctionBegin;
2213 jroman 269
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 270
  PetscValidLogicalCollectiveInt(eps,blocksize,2);
2221 jroman 271
  ierr = PetscTryMethod(eps,"EPSJDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));CHKERRQ(ierr);
1980 eromero 272
  PetscFunctionReturn(0);
273
}
274
 
1976 eromero 275
#undef __FUNCT__  
1994 eromero 276
#define __FUNCT__ "EPSJDGetBlockSize"
1985 eromero 277
/*@
2328 jroman 278
   EPSJDGetBlockSize - Returns the number of vectors to be added to the searching space
279
   in every iteration.
1976 eromero 280
 
2328 jroman 281
   Not Collective
1976 eromero 282
 
283
   Input Parameter:
284
.  eps - the eigenproblem solver context
285
 
1994 eromero 286
   Output Parameter:
2328 jroman 287
.  blocksize - number of vectors added to the search space in every iteration
1976 eromero 288
 
289
   Level: advanced
290
 
1994 eromero 291
.seealso: EPSJDSetBlockSize()
1976 eromero 292
@*/
1994 eromero 293
PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize)
1980 eromero 294
{
2221 jroman 295
  PetscErrorCode ierr;
1976 eromero 296
 
1980 eromero 297
  PetscFunctionBegin;
2213 jroman 298
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 299
  PetscValidIntPointer(blocksize,2);
2221 jroman 300
  ierr = PetscTryMethod(eps,"EPSJDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));CHKERRQ(ierr);
1980 eromero 301
  PetscFunctionReturn(0);
302
}
303
 
1976 eromero 304
#undef __FUNCT__  
1994 eromero 305
#define __FUNCT__ "EPSJDGetRestart"
1985 eromero 306
/*@
1994 eromero 307
   EPSJDGetRestart - Gets the number of vectors of the searching space after
1976 eromero 308
   restarting and the number of vectors saved from the previous iteration.
309
 
2328 jroman 310
   Not Collective
1976 eromero 311
 
312
   Input Parameter:
313
.  eps - the eigenproblem solver context
314
 
1994 eromero 315
   Output Parameter:
2328 jroman 316
+  minv - number of vectors of the searching subspace after restarting
317
-  plusk - number of vectors saved from the previous iteration  
1976 eromero 318
 
319
   Level: advanced
320
 
1994 eromero 321
.seealso: EPSJDSetRestart()
1976 eromero 322
@*/
1994 eromero 323
PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
1980 eromero 324
{
2221 jroman 325
  PetscErrorCode ierr;
1976 eromero 326
 
1980 eromero 327
  PetscFunctionBegin;
2213 jroman 328
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 329
  PetscValidIntPointer(minv,2);
330
  PetscValidIntPointer(plusk,3);
2221 jroman 331
  ierr = PetscTryMethod(eps,"EPSJDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));CHKERRQ(ierr);
1980 eromero 332
  PetscFunctionReturn(0);
333
}
334
 
1976 eromero 335
#undef __FUNCT__  
1994 eromero 336
#define __FUNCT__ "EPSJDSetRestart"
1976 eromero 337
/*@
1994 eromero 338
   EPSJDSetRestart - Sets the number of vectors of the searching space after
1976 eromero 339
   restarting and the number of vectors saved from the previous iteration.
340
 
2328 jroman 341
   Logically Collective on EPS
1976 eromero 342
 
343
   Input Parameters:
344
+  eps - the eigenproblem solver context
2328 jroman 345
.  minv - number of vectors of the searching subspace after restarting
346
-  plusk - number of vectors saved from the previous iteration  
1976 eromero 347
 
2328 jroman 348
   Options Database Keys:
349
+  -eps_jd_minv - number of vectors of the searching subspace after restarting
350
-  -eps_jd_plusk - number of vectors saved from the previous iteration  
1976 eromero 351
 
352
   Level: advanced
353
 
1994 eromero 354
.seealso: EPSJDGetRestart()
1976 eromero 355
@*/
1994 eromero 356
PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
1980 eromero 357
{
2221 jroman 358
  PetscErrorCode ierr;
1976 eromero 359
 
1980 eromero 360
  PetscFunctionBegin;
2213 jroman 361
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 362
  PetscValidLogicalCollectiveInt(eps,minv,2);
363
  PetscValidLogicalCollectiveInt(eps,plusk,3);
2221 jroman 364
  ierr = PetscTryMethod(eps,"EPSJDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));CHKERRQ(ierr);
1980 eromero 365
  PetscFunctionReturn(0);
366
}
1976 eromero 367
 
1980 eromero 368
#undef __FUNCT__  
1994 eromero 369
#define __FUNCT__ "EPSJDGetInitialSize"
1985 eromero 370
/*@
2328 jroman 371
   EPSJDGetInitialSize - Returns the initial size of the searching space.
1980 eromero 372
 
2328 jroman 373
   Not Collective
1980 eromero 374
 
375
   Input Parameter:
376
.  eps - the eigenproblem solver context
377
 
1994 eromero 378
   Output Parameter:
2328 jroman 379
.  initialsize - number of vectors of the initial searching subspace
1980 eromero 380
 
2328 jroman 381
   Notes:
382
   If EPSGDGetKrylovStart is PETSC_FALSE and the user provides vectors with
383
   EPSSetInitialSpace, up to initialsize vectors will be used; and if the
384
   provided vectors are not enough, the solver completes the subspace with
385
   random vectors. In the case of EPSGDGetKrylovStart being PETSC_TRUE, the solver
386
   gets the first vector provided by the user or, if not available, a random vector,
387
   and expands the Krylov basis up to initialsize vectors.
388
 
1980 eromero 389
   Level: advanced
390
 
2242 jroman 391
.seealso: EPSJDSetInitialSize(), EPSJDGetKrylovStart()
1980 eromero 392
@*/
1994 eromero 393
PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize)
1980 eromero 394
{
2221 jroman 395
  PetscErrorCode ierr;
1980 eromero 396
 
397
  PetscFunctionBegin;
2213 jroman 398
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 399
  PetscValidIntPointer(initialsize,2);
2221 jroman 400
  ierr = PetscTryMethod(eps,"EPSJDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));CHKERRQ(ierr);
1980 eromero 401
  PetscFunctionReturn(0);
402
}
403
 
404
#undef __FUNCT__  
1994 eromero 405
#define __FUNCT__ "EPSJDSetInitialSize"
1980 eromero 406
/*@
2328 jroman 407
   EPSJDSetInitialSize - Sets the initial size of the searching space.
1980 eromero 408
 
2328 jroman 409
   Logically Collective on EPS
1980 eromero 410
 
1994 eromero 411
   Input Parameters:
412
+  eps - the eigenproblem solver context
2328 jroman 413
-  initialsize - number of vectors of the initial searching subspace
1980 eromero 414
 
415
   Options Database Key:
2328 jroman 416
.  -eps_jd_initial_size - number of vectors of the initial searching subspace
1980 eromero 417
 
2328 jroman 418
   Notes:
419
   If EPSGDGetKrylovStart is PETSC_FALSE and the user provides vectors with
420
   EPSSetInitialSpace, up to initialsize vectors will be used; and if the
421
   provided vectors are not enough, the solver completes the subspace with
422
   random vectors. In the case of EPSGDGetKrylovStart being PETSC_TRUE, the solver
423
   gets the first vector provided by the user or, if not available, a random vector,
424
   and expands the Krylov basis up to initialsize vectors.
425
 
1980 eromero 426
   Level: advanced
427
 
2242 jroman 428
.seealso: EPSJDGetInitialSize(), EPSJDGetKrylovStart()
1980 eromero 429
@*/
1994 eromero 430
PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize)
1980 eromero 431
{
2221 jroman 432
  PetscErrorCode ierr;
1980 eromero 433
 
434
  PetscFunctionBegin;
2213 jroman 435
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 436
  PetscValidLogicalCollectiveInt(eps,initialsize,2);
2221 jroman 437
  ierr = PetscTryMethod(eps,"EPSJDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));CHKERRQ(ierr);
1980 eromero 438
  PetscFunctionReturn(0);
439
}
440
 
1994 eromero 441
#undef __FUNCT__  
442
#define __FUNCT__ "EPSJDGetFix"
443
/*@
2328 jroman 444
   EPSJDGetFix - Returns the threshold for changing the target in the correction
445
   equation.
1994 eromero 446
 
2328 jroman 447
   Not Collective
1994 eromero 448
 
2328 jroman 449
   Input Parameter:
450
.  eps - the eigenproblem solver context
1994 eromero 451
 
2328 jroman 452
   Output Parameter:
453
.  fix - threshold for changing the target
454
 
455
   Note:
456
   The target in the correction equation is fixed at the first iterations.
457
   When the norm of the residual vector is lower than the fix value,
458
   the target is set to the corresponding eigenvalue.
459
 
1994 eromero 460
   Level: advanced
461
 
462
.seealso: EPSJDSetFix()
463
@*/
464
PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix)
465
{
2221 jroman 466
  PetscErrorCode ierr;
1994 eromero 467
 
468
  PetscFunctionBegin;
2213 jroman 469
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 470
  PetscValidPointer(fix,2);
2221 jroman 471
  ierr = PetscTryMethod(eps,"EPSJDGetFix_C",(EPS,PetscReal*),(eps,fix));CHKERRQ(ierr);
1994 eromero 472
  PetscFunctionReturn(0);
473
}
474
 
475
#undef __FUNCT__  
476
#define __FUNCT__ "EPSJDSetFix"
477
/*@
478
   EPSJDSetFix - Sets the threshold for changing the target in the correction
2328 jroman 479
   equation.
1994 eromero 480
 
2328 jroman 481
   Logically Collective on EPS
1994 eromero 482
 
2328 jroman 483
   Input Parameters:
484
+  eps - the eigenproblem solver context
485
-  fix - threshold for changing the target
1994 eromero 486
 
487
   Options Database Key:
2328 jroman 488
.  -eps_jd_fix - the fix value
1994 eromero 489
 
2328 jroman 490
   Note:
491
   The target in the correction equation is fixed at the first iterations.
492
   When the norm of the residual vector is lower than the fix value,
493
   the target is set to the corresponding eigenvalue.
494
 
1994 eromero 495
   Level: advanced
496
 
497
.seealso: EPSJDGetFix()
498
@*/
499
PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix)
500
{
2221 jroman 501
  PetscErrorCode ierr;
1994 eromero 502
 
503
  PetscFunctionBegin;
2213 jroman 504
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 505
  PetscValidLogicalCollectiveReal(eps,fix,2);
2221 jroman 506
  ierr = PetscTryMethod(eps,"EPSJDSetFix_C",(EPS,PetscReal),(eps,fix));CHKERRQ(ierr);
1994 eromero 507
  PetscFunctionReturn(0);
508
}
2608 eromero 509
 
510
#undef __FUNCT__  
511
#define __FUNCT__ "EPSJDSetConstantCorrectionTolerance"
512
/*@
2611 eromero 513
   EPSJDSetConstantCorrectionTolerance - If true, deactivates the dynamic stopping criterion (also called Newton) that sets the KSP relative tolerance
2608 eromero 514
   to 0.5**i, where i is the number of EPS iterations from the last converged value.
515
 
516
   Logically Collective on EPS
517
 
518
   Input Parameters:
519
+  eps - the eigenproblem solver context
2611 eromero 520
-  constant - if false, the KSP relative tolerance is set to 0.5**i.
2608 eromero 521
 
522
   Options Database Key:
2611 eromero 523
.  -eps_jd_constant_correction_tolerance - Deactivates the dynamic stopping criterion.
2608 eromero 524
 
525
   Level: advanced
526
 
527
.seealso: EPSJDGetConstantCorrectionTolerance()
528
@*/
2611 eromero 529
PetscErrorCode EPSJDSetConstantCorrectionTolerance(EPS eps,PetscBool constant)
2608 eromero 530
{
531
  PetscErrorCode ierr;
532
 
533
  PetscFunctionBegin;
534
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2611 eromero 535
  PetscValidLogicalCollectiveBool(eps,constant,2);
536
  ierr = PetscTryMethod(eps,"EPSJDSetConstantCorrectionTolerance_C",(EPS,PetscBool),(eps,constant));CHKERRQ(ierr);
2608 eromero 537
  PetscFunctionReturn(0);
538
}
539
 
540
#undef __FUNCT__  
541
#define __FUNCT__ "EPSJDGetConstantCorrectionTolerance"
542
/*@
543
   EPSJDGetConstantCorrectionTolerance - Returns a flag indicating if the dynamic stopping is being used for
2611 eromero 544
   solving the correction equation. If the flag is false the KSP relative tolerance is set
2608 eromero 545
   to 0.5**i, where i is the number of EPS iterations from the last converged value.
546
 
547
   Not Collective
548
 
549
   Input Parameter:
550
.  eps - the eigenproblem solver context
551
 
552
   Output Parameters:
2611 eromero 553
.  constant - boolean flag indicating if the dynamic stopping criterion is not being used.
2608 eromero 554
 
555
   Level: advanced
556
 
557
.seealso: EPSJDGetConstantCorrectionTolerance()
558
@*/
2611 eromero 559
PetscErrorCode EPSJDGetConstantCorrectionTolerance(EPS eps,PetscBool *constant)
2608 eromero 560
{
561
  PetscErrorCode ierr;
562
 
563
  PetscFunctionBegin;
564
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2611 eromero 565
  PetscValidPointer(constant,2);
566
  ierr = PetscTryMethod(eps,"EPSJDGetConstantCorrectionTolerance",(EPS,PetscBool*),(eps,constant));CHKERRQ(ierr);
2608 eromero 567
  PetscFunctionReturn(0);
568
}
2611 eromero 569
 
570
#undef __FUNCT__  
571
#define __FUNCT__ "EPSJDGetWindowSizes"
572
/*@
573
   EPSJDGetWindowSizes - Gets the number of converged vectors in the projected
574
   problem (or Rayleigh quotient) and in the projector employed in the correction
575
   equation.
576
 
577
   Not Collective
578
 
579
   Input Parameter:
580
.  eps - the eigenproblem solver context
581
 
582
   Output Parameter:
583
+  pwindow - number of converged vectors in the projector
584
-  qwindow - number of converged vectors in the projected problem
585
 
586
   Level: advanced
587
 
588
.seealso: EPSJDSetWindowSizes()
589
@*/
590
PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
591
{
592
  PetscErrorCode ierr;
593
 
594
  PetscFunctionBegin;
595
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
596
  PetscValidIntPointer(pwindow,2);
597
  PetscValidIntPointer(qwindow,3);
598
  ierr = PetscTryMethod(eps,"EPSJDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));CHKERRQ(ierr);
599
  PetscFunctionReturn(0);
600
}
601
 
602
#undef __FUNCT__  
603
#define __FUNCT__ "EPSJDSetWindowSizes"
604
/*@
605
   EPSJDSetWindowSizes - Sets the number of converged vectors in the projected
606
   problem (or Rayleigh quotient) and in the projector employed in the correction
607
   equation.
608
 
609
   Logically Collective on EPS
610
 
611
   Input Parameters:
612
+  eps - the eigenproblem solver context
613
.  pwindow - number of converged vectors in the projector
614
-  qwindow - number of converged vectors in the projected problem
615
 
616
   Options Database Keys:
617
+  -eps_jd_pwindow - set the number of converged vectors in the projector
618
-  -eps_jd_qwindow - set the number of converged vectors in the projected problem  
619
 
620
   Level: advanced
621
 
622
.seealso: EPSJDGetWindowSizes()
623
@*/
624
PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
625
{
626
  PetscErrorCode ierr;
627
 
628
  PetscFunctionBegin;
629
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
630
  PetscValidLogicalCollectiveInt(eps,pwindow,2);
631
  PetscValidLogicalCollectiveInt(eps,qwindow,3);
632
  ierr = PetscTryMethod(eps,"EPSJDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));CHKERRQ(ierr);
633
  PetscFunctionReturn(0);
634
}