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