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: "gd"
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
 
2291 jroman 24
#include "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_GD(EPS eps);
1992 eromero 28
PetscErrorCode EPSDestroy_GD(EPS eps);
1976 eromero 29
 
30
EXTERN_C_BEGIN
31
#undef __FUNCT__  
32
#define __FUNCT__ "EPSSetFromOptions_GD"
33
PetscErrorCode EPSSetFromOptions_GD(EPS eps)
34
{
2317 jroman 35
  PetscErrorCode ierr;
36
  PetscBool      flg,op;
37
  PetscInt       opi,opi0;
2616 eromero 38
  KSP            ksp;
1976 eromero 39
 
40
  PetscFunctionBegin;
2384 jroman 41
  ierr = PetscOptionsHead("EPS Generalized Davidson (GD) Options");CHKERRQ(ierr);
1976 eromero 42
 
2331 jroman 43
  ierr = EPSGDGetKrylovStart(eps,&op);CHKERRQ(ierr);
2330 jroman 44
  ierr = PetscOptionsBool("-eps_gd_krylov_start","Start the searching subspace with a krylov basis","EPSGDSetKrylovStart",op,&op,&flg);CHKERRQ(ierr);
2331 jroman 45
  if(flg) { ierr = EPSGDSetKrylovStart(eps,op);CHKERRQ(ierr); }
2555 eromero 46
 
47
  ierr = EPSGDGetBOrth(eps,&op);CHKERRQ(ierr);
48
  ierr = PetscOptionsBool("-eps_gd_borth","B-orthogonalize the searching subspace basis","EPSGDSetBOrth",op,&op,&flg);CHKERRQ(ierr);
49
  if(flg) { ierr = EPSGDSetBOrth(eps,op);CHKERRQ(ierr); }
1976 eromero 50
 
2331 jroman 51
  ierr = EPSGDGetBlockSize(eps,&opi);CHKERRQ(ierr);
2330 jroman 52
  ierr = PetscOptionsInt("-eps_gd_blocksize","Number vectors add to the searching subspace","EPSGDSetBlockSize",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 53
  if(flg) { ierr = EPSGDSetBlockSize(eps,opi);CHKERRQ(ierr); }
1976 eromero 54
 
2331 jroman 55
  ierr = EPSGDGetRestart(eps,&opi,&opi0);CHKERRQ(ierr);
2330 jroman 56
  ierr = PetscOptionsInt("-eps_gd_minv","Set the size of the searching subspace after restarting","EPSGDSetRestart",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 57
  if(flg) { ierr = EPSGDSetRestart(eps,opi,opi0);CHKERRQ(ierr); }
1976 eromero 58
 
2330 jroman 59
  ierr = PetscOptionsInt("-eps_gd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSGDSetRestart",opi0,&opi0,&flg);CHKERRQ(ierr);
2331 jroman 60
  if(flg) { ierr = EPSGDSetRestart(eps,opi,opi0);CHKERRQ(ierr); }
1976 eromero 61
 
2331 jroman 62
  ierr = EPSGDGetInitialSize(eps,&opi);CHKERRQ(ierr);
2330 jroman 63
  ierr = PetscOptionsInt("-eps_gd_initial_size","Set the initial size of the searching subspace","EPSGDSetInitialSize",opi,&opi,&flg);CHKERRQ(ierr);
2331 jroman 64
  if(flg) { ierr = EPSGDSetInitialSize(eps,opi);CHKERRQ(ierr); }
1980 eromero 65
 
2611 eromero 66
  ierr = EPSGDGetWindowSizes(eps,&opi,&opi0);CHKERRQ(ierr);
2630 eromero 67
  ierr = PetscOptionsInt("-eps_gd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSGDSetWindowSizes",opi,&opi,&flg);CHKERRQ(ierr);
2611 eromero 68
  if(flg) { ierr = EPSGDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); }
69
 
2630 eromero 70
  ierr = PetscOptionsInt("-eps_gd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSGDSetWindowSizes",opi0,&opi0,&flg);CHKERRQ(ierr);
2611 eromero 71
  if(flg) { ierr = EPSGDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); }
72
 
2384 jroman 73
  ierr = PetscOptionsTail();CHKERRQ(ierr);
2616 eromero 74
 
75
  /* Set STPrecond as the default ST */
76
  if (!((PetscObject)eps->OP)->type_name) {
77
    ierr = STSetType(eps->OP,STPRECOND);CHKERRQ(ierr);
78
  }
79
  ierr = STPrecondSetKSPHasMat(eps->OP,PETSC_FALSE);CHKERRQ(ierr);
80
 
81
  /* Set the default options of the KSP */
82
  ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
83
  if (!((PetscObject)ksp)->type_name) {
84
    ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr);
85
  }
86
 
1976 eromero 87
  PetscFunctionReturn(0);
88
}  
89
EXTERN_C_END
90
 
91
#undef __FUNCT__  
2003 eromero 92
#define __FUNCT__ "EPSSetUp_GD"
93
PetscErrorCode EPSSetUp_GD(EPS eps)
94
{
2317 jroman 95
  PetscErrorCode ierr;
96
  PetscBool      t;
97
  KSP            ksp;
2003 eromero 98
 
99
  PetscFunctionBegin;
2104 eromero 100
  /* Setup common for all davidson solvers */
2330 jroman 101
  ierr = EPSSetUp_Davidson(eps);CHKERRQ(ierr);
2104 eromero 102
 
2616 eromero 103
  /* Set KSPPREONLY as default */
104
  ierr = STGetKSP(eps->OP,&ksp);CHKERRQ(ierr);
105
  if (!((PetscObject)ksp)->type_name) {
106
    ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr);
107
  }
108
 
2003 eromero 109
  /* Check some constraints */
2331 jroman 110
  ierr = PetscTypeCompare((PetscObject)ksp,KSPPREONLY,&t);CHKERRQ(ierr);
111
  if (!t) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_SUP,"EPSGD only works with KSPPREONLY");
2003 eromero 112
  PetscFunctionReturn(0);
113
}
114
 
115
EXTERN_C_BEGIN
116
#undef __FUNCT__  
1976 eromero 117
#define __FUNCT__ "EPSCreate_GD"
2317 jroman 118
PetscErrorCode EPSCreate_GD(EPS eps)
119
{
1976 eromero 120
  PetscErrorCode  ierr;
121
 
122
  PetscFunctionBegin;
2324 jroman 123
  /* Load the Davidson solver */
2330 jroman 124
  ierr = EPSCreate_Davidson(eps);CHKERRQ(ierr);
1976 eromero 125
 
1982 eromero 126
  /* Overload the GD properties */
1976 eromero 127
  eps->ops->setfromoptions       = EPSSetFromOptions_GD;
2003 eromero 128
  eps->ops->setup                = EPSSetUp_GD;
1992 eromero 129
  eps->ops->destroy              = EPSDestroy_GD;
1976 eromero 130
 
2324 jroman 131
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetKrylovStart_C","EPSDavidsonSetKrylovStart_Davidson",EPSDavidsonSetKrylovStart_Davidson);CHKERRQ(ierr);
132
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetKrylovStart_C","EPSDavidsonGetKrylovStart_Davidson",EPSDavidsonGetKrylovStart_Davidson);CHKERRQ(ierr);
2555 eromero 133
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetBOrth_C","EPSDavidsonSetBOrth_Davidson",EPSDavidsonSetBOrth_Davidson);CHKERRQ(ierr);
134
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetBOrth_C","EPSDavidsonGetBOrth_Davidson",EPSDavidsonGetBOrth_Davidson);CHKERRQ(ierr);
2324 jroman 135
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetBlockSize_C","EPSDavidsonSetBlockSize_Davidson",EPSDavidsonSetBlockSize_Davidson);CHKERRQ(ierr);
136
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetBlockSize_C","EPSDavidsonGetBlockSize_Davidson",EPSDavidsonGetBlockSize_Davidson);CHKERRQ(ierr);
137
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetRestart_C","EPSDavidsonSetRestart_Davidson",EPSDavidsonSetRestart_Davidson);CHKERRQ(ierr);
138
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetRestart_C","EPSDavidsonGetRestart_Davidson",EPSDavidsonGetRestart_Davidson);CHKERRQ(ierr);
139
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetInitialSize_C","EPSDavidsonSetInitialSize_Davidson",EPSDavidsonSetInitialSize_Davidson);CHKERRQ(ierr);
140
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetInitialSize_C","EPSDavidsonGetInitialSize_Davidson",EPSDavidsonGetInitialSize_Davidson);CHKERRQ(ierr);
2611 eromero 141
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetWindowSizes_C","EPSDavidsonSetWindowSizes_Davidson",EPSDavidsonSetWindowSizes_Davidson);CHKERRQ(ierr);
142
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetWindowSizes_C","EPSDavidsonGetWindowSizes_Davidson",EPSDavidsonGetWindowSizes_Davidson);CHKERRQ(ierr);
1976 eromero 143
  PetscFunctionReturn(0);
144
}
145
EXTERN_C_END
146
 
1980 eromero 147
#undef __FUNCT__  
1992 eromero 148
#define __FUNCT__ "EPSDestroy_GD"
149
PetscErrorCode EPSDestroy_GD(EPS eps)
150
{
1980 eromero 151
  PetscErrorCode  ierr;
1976 eromero 152
 
1980 eromero 153
  PetscFunctionBegin;
2348 jroman 154
  ierr = PetscFree(eps->data);CHKERRQ(ierr);
1980 eromero 155
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetKrylovStart_C","",PETSC_NULL);CHKERRQ(ierr);
156
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetKrylovStart_C","",PETSC_NULL);CHKERRQ(ierr);
2555 eromero 157
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetBOrth_C","",PETSC_NULL);CHKERRQ(ierr);
158
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetBOrth_C","",PETSC_NULL);CHKERRQ(ierr);
1980 eromero 159
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetBlockSize_C","",PETSC_NULL);CHKERRQ(ierr);
160
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetBlockSize_C","",PETSC_NULL);CHKERRQ(ierr);
161
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetRestart_C","",PETSC_NULL);CHKERRQ(ierr);
162
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetRestart_C","",PETSC_NULL);CHKERRQ(ierr);
163
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetInitialSize_C","",PETSC_NULL);CHKERRQ(ierr);
164
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetInitialSize_C","",PETSC_NULL);CHKERRQ(ierr);
2611 eromero 165
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDSetWindowSizes_C","",PETSC_NULL);CHKERRQ(ierr);
166
  ierr = PetscObjectComposeFunctionDynamic((PetscObject)eps,"EPSGDGetWindowSizes_C","",PETSC_NULL);CHKERRQ(ierr);
1980 eromero 167
  PetscFunctionReturn(0);
168
}
169
 
1976 eromero 170
#undef __FUNCT__  
171
#define __FUNCT__ "EPSGDSetKrylovStart"
172
/*@
173
   EPSGDSetKrylovStart - Activates or deactivates starting the searching
174
   subspace with a Krylov basis.
175
 
2328 jroman 176
   Logically Collective on EPS
1976 eromero 177
 
178
   Input Parameters:
179
+  eps - the eigenproblem solver context
180
-  krylovstart - boolean flag
181
 
182
   Options Database Key:
2328 jroman 183
.  -eps_gd_krylov_start - Activates starting the searching subspace with a
1976 eromero 184
    Krylov basis
185
 
186
   Level: advanced
187
 
188
.seealso: EPSGDGetKrylovStart()
189
@*/
2216 jroman 190
PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)
1980 eromero 191
{
2221 jroman 192
  PetscErrorCode ierr;
1976 eromero 193
 
1980 eromero 194
  PetscFunctionBegin;
2213 jroman 195
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 196
  PetscValidLogicalCollectiveBool(eps,krylovstart,2);
2221 jroman 197
  ierr = PetscTryMethod(eps,"EPSGDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));CHKERRQ(ierr);
1980 eromero 198
  PetscFunctionReturn(0);
199
}
1976 eromero 200
 
201
#undef __FUNCT__  
202
#define __FUNCT__ "EPSGDGetKrylovStart"
1985 eromero 203
/*@
2328 jroman 204
   EPSGDGetKrylovStart - Returns a flag indicating if the search subspace is started with a
1976 eromero 205
   Krylov basis.
206
 
2328 jroman 207
   Not Collective
1976 eromero 208
 
209
   Input Parameter:
210
.  eps - the eigenproblem solver context
211
 
1994 eromero 212
   Output Parameters:
2328 jroman 213
.  krylovstart - boolean flag indicating if the search subspace is started
214
   with a Krylov basis
1976 eromero 215
 
216
   Level: advanced
217
 
218
.seealso: EPSGDGetKrylovStart()
219
@*/
2216 jroman 220
PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)
1980 eromero 221
{
2221 jroman 222
  PetscErrorCode ierr;
1976 eromero 223
 
1980 eromero 224
  PetscFunctionBegin;
2213 jroman 225
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 226
  PetscValidPointer(krylovstart,2);
2221 jroman 227
  ierr = PetscTryMethod(eps,"EPSGDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));CHKERRQ(ierr);
1980 eromero 228
  PetscFunctionReturn(0);
229
}
230
 
1976 eromero 231
#undef __FUNCT__  
232
#define __FUNCT__ "EPSGDSetBlockSize"
233
/*@
2328 jroman 234
   EPSGDSetBlockSize - Sets the number of vectors to be added to the searching space
235
   in every iteration.
1976 eromero 236
 
2328 jroman 237
   Logically Collective on EPS
1976 eromero 238
 
239
   Input Parameters:
240
+  eps - the eigenproblem solver context
2328 jroman 241
-  blocksize - number of vectors added to the search space in every iteration
1976 eromero 242
 
243
   Options Database Key:
2328 jroman 244
.  -eps_gd_blocksize - number of vectors added to the search space in every iteration
1976 eromero 245
 
246
   Level: advanced
247
 
248
.seealso: EPSGDSetKrylovStart()
249
@*/
1980 eromero 250
PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)
251
{
2221 jroman 252
  PetscErrorCode ierr;
1976 eromero 253
 
1980 eromero 254
  PetscFunctionBegin;
2213 jroman 255
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 256
  PetscValidLogicalCollectiveInt(eps,blocksize,2);
2221 jroman 257
  ierr = PetscTryMethod(eps,"EPSGDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));CHKERRQ(ierr);
1980 eromero 258
  PetscFunctionReturn(0);
259
}
260
 
1976 eromero 261
#undef __FUNCT__  
262
#define __FUNCT__ "EPSGDGetBlockSize"
1985 eromero 263
/*@
2328 jroman 264
   EPSGDGetBlockSize - Returns the number of vectors to be added to the searching space
265
   in every iteration.
1976 eromero 266
 
2328 jroman 267
   Not Collective
1976 eromero 268
 
269
   Input Parameter:
270
.  eps - the eigenproblem solver context
271
 
1994 eromero 272
   Output Parameter:
2328 jroman 273
.  blocksize - number of vectors added to the search space in every iteration
1976 eromero 274
 
275
   Level: advanced
276
 
277
.seealso: EPSGDSetBlockSize()
278
@*/
1980 eromero 279
PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)
280
{
2221 jroman 281
  PetscErrorCode ierr;
1976 eromero 282
 
1980 eromero 283
  PetscFunctionBegin;
2213 jroman 284
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 285
  PetscValidIntPointer(blocksize,2);
2221 jroman 286
  ierr = PetscTryMethod(eps,"EPSGDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));CHKERRQ(ierr);
1980 eromero 287
  PetscFunctionReturn(0);
288
}
289
 
1976 eromero 290
#undef __FUNCT__  
291
#define __FUNCT__ "EPSGDGetRestart"
1985 eromero 292
/*@
1976 eromero 293
   EPSGDGetRestart - Gets the number of vectors of the searching space after
294
   restarting and the number of vectors saved from the previous iteration.
295
 
2328 jroman 296
   Not Collective
1976 eromero 297
 
298
   Input Parameter:
299
.  eps - the eigenproblem solver context
300
 
1994 eromero 301
   Output Parameter:
2328 jroman 302
+  minv - number of vectors of the searching subspace after restarting
303
-  plusk - number of vectors saved from the previous iteration  
1976 eromero 304
 
305
   Level: advanced
306
 
307
.seealso: EPSGDSetRestart()
308
@*/
1980 eromero 309
PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
310
{
2221 jroman 311
  PetscErrorCode ierr;
1976 eromero 312
 
1980 eromero 313
  PetscFunctionBegin;
2213 jroman 314
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 315
  PetscValidIntPointer(minv,2);
316
  PetscValidIntPointer(plusk,3);
2221 jroman 317
  ierr = PetscTryMethod(eps,"EPSGDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));CHKERRQ(ierr);
1980 eromero 318
  PetscFunctionReturn(0);
319
}
320
 
1976 eromero 321
#undef __FUNCT__  
322
#define __FUNCT__ "EPSGDSetRestart"
323
/*@
324
   EPSGDSetRestart - Sets the number of vectors of the searching space after
325
   restarting and the number of vectors saved from the previous iteration.
326
 
2328 jroman 327
   Logically Collective on EPS
1976 eromero 328
 
329
   Input Parameters:
330
+  eps - the eigenproblem solver context
2328 jroman 331
.  minv - number of vectors of the searching subspace after restarting
332
-  plusk - number of vectors saved from the previous iteration  
1976 eromero 333
 
2328 jroman 334
   Options Database Keys:
335
+  -eps_gd_minv - number of vectors of the searching subspace after restarting
336
-  -eps_gd_plusk - number of vectors saved from the previous iteration  
1976 eromero 337
 
338
   Level: advanced
339
 
340
.seealso: EPSGDSetRestart()
341
@*/
1980 eromero 342
PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
343
{
2221 jroman 344
  PetscErrorCode ierr;
1976 eromero 345
 
1980 eromero 346
  PetscFunctionBegin;
2213 jroman 347
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 348
  PetscValidLogicalCollectiveInt(eps,minv,2);
349
  PetscValidLogicalCollectiveInt(eps,plusk,2);
2221 jroman 350
  ierr = PetscTryMethod(eps,"EPSGDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));CHKERRQ(ierr);
1980 eromero 351
  PetscFunctionReturn(0);
352
}
1976 eromero 353
 
1980 eromero 354
#undef __FUNCT__  
355
#define __FUNCT__ "EPSGDGetInitialSize"
1985 eromero 356
/*@
2328 jroman 357
   EPSGDGetInitialSize - Returns the initial size of the searching space.
1980 eromero 358
 
2328 jroman 359
   Not Collective
1980 eromero 360
 
361
   Input Parameter:
362
.  eps - the eigenproblem solver context
363
 
1994 eromero 364
   Output Parameter:
2328 jroman 365
.  initialsize - number of vectors of the initial searching subspace
1980 eromero 366
 
2328 jroman 367
   Notes:
2644 jroman 368
   If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
369
   EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
2328 jroman 370
   provided vectors are not enough, the solver completes the subspace with
2644 jroman 371
   random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
2328 jroman 372
   gets the first vector provided by the user or, if not available, a random vector,
373
   and expands the Krylov basis up to initialsize vectors.
374
 
1980 eromero 375
   Level: advanced
376
 
2242 jroman 377
.seealso: EPSGDSetInitialSize(), EPSGDGetKrylovStart()
1980 eromero 378
@*/
379
PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)
380
{
2221 jroman 381
  PetscErrorCode ierr;
1980 eromero 382
 
383
  PetscFunctionBegin;
2213 jroman 384
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 385
  PetscValidIntPointer(initialsize,2);
2221 jroman 386
  ierr = PetscTryMethod(eps,"EPSGDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));CHKERRQ(ierr);
1980 eromero 387
  PetscFunctionReturn(0);
388
}
389
 
390
#undef __FUNCT__  
391
#define __FUNCT__ "EPSGDSetInitialSize"
392
/*@
2328 jroman 393
   EPSGDSetInitialSize - Sets the initial size of the searching space.
1980 eromero 394
 
2328 jroman 395
   Logically Collective on EPS
1980 eromero 396
 
1994 eromero 397
   Input Parameters:
398
+  eps - the eigenproblem solver context
2328 jroman 399
-  initialsize - number of vectors of the initial searching subspace
1980 eromero 400
 
401
   Options Database Key:
2328 jroman 402
.  -eps_gd_initial_size - number of vectors of the initial searching subspace
1980 eromero 403
 
2328 jroman 404
   Notes:
2644 jroman 405
   If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
406
   EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
2328 jroman 407
   provided vectors are not enough, the solver completes the subspace with
2644 jroman 408
   random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
2328 jroman 409
   gets the first vector provided by the user or, if not available, a random vector,
410
   and expands the Krylov basis up to initialsize vectors.
411
 
1980 eromero 412
   Level: advanced
413
 
2242 jroman 414
.seealso: EPSGDGetInitialSize(), EPSGDGetKrylovStart()
1980 eromero 415
@*/
416
PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)
417
{
2221 jroman 418
  PetscErrorCode ierr;
1980 eromero 419
 
420
  PetscFunctionBegin;
2213 jroman 421
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 422
  PetscValidLogicalCollectiveInt(eps,initialsize,2);
2221 jroman 423
  ierr = PetscTryMethod(eps,"EPSGDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));CHKERRQ(ierr);
1980 eromero 424
  PetscFunctionReturn(0);
425
}
426
 
2555 eromero 427
#undef __FUNCT__  
428
#define __FUNCT__ "EPSGDSetBOrth"
429
/*@
430
   EPSGDSetBOrth - Activates or deactivates the B-orthogonalizetion of the searching
431
   subspace in case of generalized Hermitian problems.
432
 
433
   Logically Collective on EPS
434
 
435
   Input Parameters:
436
+  eps - the eigenproblem solver context
437
-  borth - boolean flag
438
 
439
   Options Database Key:
440
.  -eps_gd_borth - Activates the B-orthogonalization of the searching subspace
441
 
442
   Level: advanced
443
 
444
.seealso: EPSGDGetBOrth()
445
@*/
446
PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)
447
{
448
  PetscErrorCode ierr;
449
 
450
  PetscFunctionBegin;
451
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
452
  PetscValidLogicalCollectiveBool(eps,borth,2);
453
  ierr = PetscTryMethod(eps,"EPSGDSetBOrth_C",(EPS,PetscBool),(eps,borth));CHKERRQ(ierr);
454
  PetscFunctionReturn(0);
455
}
456
 
457
#undef __FUNCT__  
458
#define __FUNCT__ "EPSGDGetBOrth"
459
/*@
460
   EPSGDGetBOrth - Returns a flag indicating if the search subspace basis is
461
   B-orthogonalized.
462
 
463
   Not Collective
464
 
465
   Input Parameter:
466
.  eps - the eigenproblem solver context
467
 
468
   Output Parameters:
469
.  borth - the boolean flag
470
 
471
   Level: advanced
472
 
473
.seealso: EPSGDGetKrylovStart()
474
@*/
475
PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)
476
{
477
  PetscErrorCode ierr;
478
 
479
  PetscFunctionBegin;
480
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
481
  PetscValidPointer(borth,2);
482
  ierr = PetscTryMethod(eps,"EPSGDGetBOrth_C",(EPS,PetscBool*),(eps,borth));CHKERRQ(ierr);
483
  PetscFunctionReturn(0);
484
}
2611 eromero 485
 
486
#undef __FUNCT__  
487
#define __FUNCT__ "EPSGDGetWindowSizes"
488
/*@
489
   EPSGDGetWindowSizes - Gets the number of converged vectors in the projected
490
   problem (or Rayleigh quotient) and in the projector employed in the correction
491
   equation.
492
 
493
   Not Collective
494
 
495
   Input Parameter:
496
.  eps - the eigenproblem solver context
497
 
498
   Output Parameter:
499
+  pwindow - number of converged vectors in the projector
500
-  qwindow - number of converged vectors in the projected problem
501
 
502
   Level: advanced
503
 
504
.seealso: EPSGDSetWindowSizes()
505
@*/
506
PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
507
{
508
  PetscErrorCode ierr;
509
 
510
  PetscFunctionBegin;
511
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
512
  PetscValidIntPointer(pwindow,2);
513
  PetscValidIntPointer(qwindow,3);
514
  ierr = PetscTryMethod(eps,"EPSGDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));CHKERRQ(ierr);
515
  PetscFunctionReturn(0);
516
}
517
 
518
#undef __FUNCT__  
519
#define __FUNCT__ "EPSGDSetWindowSizes"
520
/*@
521
   EPSGDSetWindowSizes - Sets the number of converged vectors in the projected
522
   problem (or Rayleigh quotient) and in the projector employed in the correction
523
   equation.
524
 
525
   Logically Collective on EPS
526
 
527
   Input Parameters:
528
+  eps - the eigenproblem solver context
529
.  pwindow - number of converged vectors in the projector
530
-  qwindow - number of converged vectors in the projected problem
531
 
532
   Options Database Keys:
533
+  -eps_gd_pwindow - set the number of converged vectors in the projector
534
-  -eps_gd_qwindow - set the number of converged vectors in the projected problem  
535
 
536
   Level: advanced
537
 
538
.seealso: EPSGDGetWindowSizes()
539
@*/
540
PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
541
{
542
  PetscErrorCode ierr;
543
 
544
  PetscFunctionBegin;
545
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
546
  PetscValidLogicalCollectiveInt(eps,pwindow,2);
547
  PetscValidLogicalCollectiveInt(eps,qwindow,3);
548
  ierr = PetscTryMethod(eps,"EPSGDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));CHKERRQ(ierr);
549
  PetscFunctionReturn(0);
550
}