Subversion Repositories slepc-dev

Rev

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