LCOV - code coverage report
Current view: top level - eps/impls/davidson/gd - gd.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 183 186 98.4 %
Date: 2020-12-03 06:49:52 Functions: 19 19 100.0 %

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-2020, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : /*
      11             :    SLEPc eigensolver: "gd"
      12             : 
      13             :    Method: Generalized Davidson
      14             : 
      15             :    Algorithm:
      16             : 
      17             :        Generalized Davidson with various subspace extraction and
      18             :        restart techniques.
      19             : 
      20             :    References:
      21             : 
      22             :        [1] E.R. Davidson, "Super-matrix methods", Comput. Phys. Commun.
      23             :            53(2):49-60, 1989.
      24             : 
      25             :        [2] E. Romero and J.E. Roman, "A parallel implementation of
      26             :            Davidson methods for large-scale eigenvalue problems in
      27             :            SLEPc", ACM Trans. Math. Software 40(2), Article 13, 2014.
      28             : */
      29             : 
      30             : #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
      31             : #include <../src/eps/impls/davidson/davidson.h>
      32             : 
      33          39 : PetscErrorCode EPSSetFromOptions_GD(PetscOptionItems *PetscOptionsObject,EPS eps)
      34             : {
      35             :   PetscErrorCode ierr;
      36             :   PetscBool      flg,flg2,op,orth;
      37             :   PetscInt       opi,opi0;
      38             : 
      39          39 :   PetscFunctionBegin;
      40          39 :   ierr = PetscOptionsHead(PetscOptionsObject,"EPS Generalized Davidson (GD) Options");CHKERRQ(ierr);
      41             : 
      42          39 :     ierr = EPSGDGetKrylovStart(eps,&op);CHKERRQ(ierr);
      43          39 :     ierr = PetscOptionsBool("-eps_gd_krylov_start","Start the search subspace with a Krylov basis","EPSGDSetKrylovStart",op,&op,&flg);CHKERRQ(ierr);
      44          39 :     if (flg) { ierr = EPSGDSetKrylovStart(eps,op);CHKERRQ(ierr); }
      45             : 
      46          39 :     ierr = EPSGDGetBOrth(eps,&orth);CHKERRQ(ierr);
      47          39 :     ierr = PetscOptionsBool("-eps_gd_borth","Use B-orthogonalization in the search subspace","EPSGDSetBOrth",op,&op,&flg);CHKERRQ(ierr);
      48          39 :     if (flg) { ierr = EPSGDSetBOrth(eps,op);CHKERRQ(ierr); }
      49             : 
      50          39 :     ierr = EPSGDGetBlockSize(eps,&opi);CHKERRQ(ierr);
      51          39 :     ierr = PetscOptionsInt("-eps_gd_blocksize","Number of vectors to add to the search subspace","EPSGDSetBlockSize",opi,&opi,&flg);CHKERRQ(ierr);
      52          39 :     if (flg) { ierr = EPSGDSetBlockSize(eps,opi);CHKERRQ(ierr); }
      53             : 
      54          39 :     ierr = EPSGDGetRestart(eps,&opi,&opi0);CHKERRQ(ierr);
      55          39 :     ierr = PetscOptionsInt("-eps_gd_minv","Size of the search subspace after restarting","EPSGDSetRestart",opi,&opi,&flg);CHKERRQ(ierr);
      56          39 :     ierr = PetscOptionsInt("-eps_gd_plusk","Number of eigenvectors saved from the previous iteration when restarting","EPSGDSetRestart",opi0,&opi0,&flg2);CHKERRQ(ierr);
      57          39 :     if (flg || flg2) { ierr = EPSGDSetRestart(eps,opi,opi0);CHKERRQ(ierr); }
      58             : 
      59          39 :     ierr = EPSGDGetInitialSize(eps,&opi);CHKERRQ(ierr);
      60          39 :     ierr = PetscOptionsInt("-eps_gd_initial_size","Initial size of the search subspace","EPSGDSetInitialSize",opi,&opi,&flg);CHKERRQ(ierr);
      61          39 :     if (flg) { ierr = EPSGDSetInitialSize(eps,opi);CHKERRQ(ierr); }
      62             : 
      63          39 :     ierr = PetscOptionsBool("-eps_gd_double_expansion","Use the doble-expansion variant of GD","EPSGDSetDoubleExpansion",PETSC_FALSE,&op,&flg);CHKERRQ(ierr);
      64          39 :     if (flg) { ierr = EPSGDSetDoubleExpansion(eps,op);CHKERRQ(ierr); }
      65             : 
      66          39 :   ierr = PetscOptionsTail();CHKERRQ(ierr);
      67          39 :   PetscFunctionReturn(0);
      68             : }
      69             : 
      70          64 : PetscErrorCode EPSSetUp_GD(EPS eps)
      71             : {
      72             :   PetscErrorCode ierr;
      73             :   PetscBool      t;
      74             :   KSP            ksp;
      75             : 
      76          64 :   PetscFunctionBegin;
      77             :   /* Setup common for all davidson solvers */
      78          64 :   ierr = EPSSetUp_XD(eps);CHKERRQ(ierr);
      79             : 
      80             :   /* Check some constraints */
      81          64 :   ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr);
      82          64 :   ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&t);CHKERRQ(ierr);
      83          64 :   if (!t) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPSGD only works with KSPPREONLY");
      84          64 :   PetscFunctionReturn(0);
      85             : }
      86             : 
      87           1 : PetscErrorCode EPSView_GD(EPS eps,PetscViewer viewer)
      88             : {
      89             :   PetscErrorCode ierr;
      90             :   PetscBool      isascii,opb;
      91             :   PetscInt       opi,opi0;
      92             :   PetscBool      borth;
      93           1 :   EPS_DAVIDSON   *data = (EPS_DAVIDSON*)eps->data;
      94             : 
      95           1 :   PetscFunctionBegin;
      96           1 :   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr);
      97           1 :   if (isascii) {
      98           1 :     if (data->doubleexp) {
      99           0 :       ierr = PetscViewerASCIIPrintf(viewer,"  using double expansion variant (GD2)\n");CHKERRQ(ierr);
     100             :     }
     101           1 :     ierr = EPSXDGetBOrth_XD(eps,&borth);CHKERRQ(ierr);
     102           1 :     if (borth) {
     103           0 :       ierr = PetscViewerASCIIPrintf(viewer,"  search subspace is B-orthogonalized\n");CHKERRQ(ierr);
     104             :     } else {
     105           1 :       ierr = PetscViewerASCIIPrintf(viewer,"  search subspace is orthogonalized\n");CHKERRQ(ierr);
     106             :     }
     107           1 :     ierr = EPSXDGetBlockSize_XD(eps,&opi);CHKERRQ(ierr);
     108           1 :     ierr = PetscViewerASCIIPrintf(viewer,"  block size=%D\n",opi);CHKERRQ(ierr);
     109           1 :     ierr = EPSXDGetKrylovStart_XD(eps,&opb);CHKERRQ(ierr);
     110           1 :     if (!opb) {
     111           1 :       ierr = PetscViewerASCIIPrintf(viewer,"  type of the initial subspace: non-Krylov\n");CHKERRQ(ierr);
     112             :     } else {
     113           0 :       ierr = PetscViewerASCIIPrintf(viewer,"  type of the initial subspace: Krylov\n");CHKERRQ(ierr);
     114             :     }
     115           1 :     ierr = EPSXDGetRestart_XD(eps,&opi,&opi0);CHKERRQ(ierr);
     116           1 :     ierr = PetscViewerASCIIPrintf(viewer,"  size of the subspace after restarting: %D\n",opi);CHKERRQ(ierr);
     117           1 :     ierr = PetscViewerASCIIPrintf(viewer,"  number of vectors after restarting from the previous iteration: %D\n",opi0);CHKERRQ(ierr);
     118             :   }
     119           1 :   PetscFunctionReturn(0);
     120             : }
     121             : 
     122          43 : PetscErrorCode EPSDestroy_GD(EPS eps)
     123             : {
     124             :   PetscErrorCode  ierr;
     125             : 
     126          43 :   PetscFunctionBegin;
     127          43 :   ierr = PetscFree(eps->data);CHKERRQ(ierr);
     128          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",NULL);CHKERRQ(ierr);
     129          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",NULL);CHKERRQ(ierr);
     130          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",NULL);CHKERRQ(ierr);
     131          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",NULL);CHKERRQ(ierr);
     132          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",NULL);CHKERRQ(ierr);
     133          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",NULL);CHKERRQ(ierr);
     134          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",NULL);CHKERRQ(ierr);
     135          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",NULL);CHKERRQ(ierr);
     136          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",NULL);CHKERRQ(ierr);
     137          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",NULL);CHKERRQ(ierr);
     138          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",NULL);CHKERRQ(ierr);
     139          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",NULL);CHKERRQ(ierr);
     140          43 :   PetscFunctionReturn(0);
     141             : }
     142             : 
     143             : /*@
     144             :    EPSGDSetKrylovStart - Activates or deactivates starting the searching
     145             :    subspace with a Krylov basis.
     146             : 
     147             :    Logically Collective on eps
     148             : 
     149             :    Input Parameters:
     150             : +  eps - the eigenproblem solver context
     151             : -  krylovstart - boolean flag
     152             : 
     153             :    Options Database Key:
     154             : .  -eps_gd_krylov_start - Activates starting the searching subspace with a
     155             :     Krylov basis
     156             : 
     157             :    Level: advanced
     158             : 
     159             : .seealso: EPSGDGetKrylovStart()
     160             : @*/
     161           3 : PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)
     162             : {
     163             :   PetscErrorCode ierr;
     164             : 
     165           3 :   PetscFunctionBegin;
     166           3 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     167           6 :   PetscValidLogicalCollectiveBool(eps,krylovstart,2);
     168           3 :   ierr = PetscTryMethod(eps,"EPSGDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));CHKERRQ(ierr);
     169           6 :   PetscFunctionReturn(0);
     170             : }
     171             : 
     172             : /*@
     173             :    EPSGDGetKrylovStart - Returns a flag indicating if the search subspace is started with a
     174             :    Krylov basis.
     175             : 
     176             :    Not Collective
     177             : 
     178             :    Input Parameter:
     179             : .  eps - the eigenproblem solver context
     180             : 
     181             :    Output Parameters:
     182             : .  krylovstart - boolean flag indicating if the search subspace is started
     183             :    with a Krylov basis
     184             : 
     185             :    Level: advanced
     186             : 
     187             : .seealso: EPSGDGetKrylovStart()
     188             : @*/
     189          39 : PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)
     190             : {
     191             :   PetscErrorCode ierr;
     192             : 
     193          39 :   PetscFunctionBegin;
     194          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     195          39 :   PetscValidBoolPointer(krylovstart,2);
     196          39 :   ierr = PetscUseMethod(eps,"EPSGDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));CHKERRQ(ierr);
     197          78 :   PetscFunctionReturn(0);
     198             : }
     199             : 
     200             : /*@
     201             :    EPSGDSetBlockSize - Sets the number of vectors to be added to the searching space
     202             :    in every iteration.
     203             : 
     204             :    Logically Collective on eps
     205             : 
     206             :    Input Parameters:
     207             : +  eps - the eigenproblem solver context
     208             : -  blocksize - number of vectors added to the search space in every iteration
     209             : 
     210             :    Options Database Key:
     211             : .  -eps_gd_blocksize - number of vectors added to the search space in every iteration
     212             : 
     213             :    Level: advanced
     214             : 
     215             : .seealso: EPSGDSetKrylovStart()
     216             : @*/
     217           2 : PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)
     218             : {
     219             :   PetscErrorCode ierr;
     220             : 
     221           2 :   PetscFunctionBegin;
     222           2 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     223           4 :   PetscValidLogicalCollectiveInt(eps,blocksize,2);
     224           2 :   ierr = PetscTryMethod(eps,"EPSGDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));CHKERRQ(ierr);
     225           4 :   PetscFunctionReturn(0);
     226             : }
     227             : 
     228             : /*@
     229             :    EPSGDGetBlockSize - Returns the number of vectors to be added to the searching space
     230             :    in every iteration.
     231             : 
     232             :    Not Collective
     233             : 
     234             :    Input Parameter:
     235             : .  eps - the eigenproblem solver context
     236             : 
     237             :    Output Parameter:
     238             : .  blocksize - number of vectors added to the search space in every iteration
     239             : 
     240             :    Level: advanced
     241             : 
     242             : .seealso: EPSGDSetBlockSize()
     243             : @*/
     244          39 : PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)
     245             : {
     246             :   PetscErrorCode ierr;
     247             : 
     248          39 :   PetscFunctionBegin;
     249          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     250          39 :   PetscValidIntPointer(blocksize,2);
     251          39 :   ierr = PetscUseMethod(eps,"EPSGDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));CHKERRQ(ierr);
     252          78 :   PetscFunctionReturn(0);
     253             : }
     254             : 
     255             : /*@
     256             :    EPSGDSetRestart - Sets the number of vectors of the searching space after
     257             :    restarting and the number of vectors saved from the previous iteration.
     258             : 
     259             :    Logically Collective on eps
     260             : 
     261             :    Input Parameters:
     262             : +  eps - the eigenproblem solver context
     263             : .  minv - number of vectors of the searching subspace after restarting
     264             : -  plusk - number of vectors saved from the previous iteration
     265             : 
     266             :    Options Database Keys:
     267             : +  -eps_gd_minv - number of vectors of the searching subspace after restarting
     268             : -  -eps_gd_plusk - number of vectors saved from the previous iteration
     269             : 
     270             :    Level: advanced
     271             : 
     272             : .seealso: EPSGDSetRestart()
     273             : @*/
     274           1 : PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
     275             : {
     276             :   PetscErrorCode ierr;
     277             : 
     278           1 :   PetscFunctionBegin;
     279           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     280           2 :   PetscValidLogicalCollectiveInt(eps,minv,2);
     281           3 :   PetscValidLogicalCollectiveInt(eps,plusk,2);
     282           1 :   ierr = PetscTryMethod(eps,"EPSGDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));CHKERRQ(ierr);
     283           2 :   PetscFunctionReturn(0);
     284             : }
     285             : 
     286             : /*@
     287             :    EPSGDGetRestart - Gets the number of vectors of the searching space after
     288             :    restarting and the number of vectors saved from the previous iteration.
     289             : 
     290             :    Not Collective
     291             : 
     292             :    Input Parameter:
     293             : .  eps - the eigenproblem solver context
     294             : 
     295             :    Output Parameter:
     296             : +  minv - number of vectors of the searching subspace after restarting
     297             : -  plusk - number of vectors saved from the previous iteration
     298             : 
     299             :    Level: advanced
     300             : 
     301             : .seealso: EPSGDSetRestart()
     302             : @*/
     303          39 : PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
     304             : {
     305             :   PetscErrorCode ierr;
     306             : 
     307          39 :   PetscFunctionBegin;
     308          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     309          39 :   ierr = PetscUseMethod(eps,"EPSGDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));CHKERRQ(ierr);
     310          78 :   PetscFunctionReturn(0);
     311             : }
     312             : 
     313             : /*@
     314             :    EPSGDSetInitialSize - Sets the initial size of the searching space.
     315             : 
     316             :    Logically Collective on eps
     317             : 
     318             :    Input Parameters:
     319             : +  eps - the eigenproblem solver context
     320             : -  initialsize - number of vectors of the initial searching subspace
     321             : 
     322             :    Options Database Key:
     323             : .  -eps_gd_initial_size - number of vectors of the initial searching subspace
     324             : 
     325             :    Notes:
     326             :    If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
     327             :    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
     328             :    provided vectors are not enough, the solver completes the subspace with
     329             :    random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
     330             :    gets the first vector provided by the user or, if not available, a random vector,
     331             :    and expands the Krylov basis up to initialsize vectors.
     332             : 
     333             :    Level: advanced
     334             : 
     335             : .seealso: EPSGDGetInitialSize(), EPSGDGetKrylovStart()
     336             : @*/
     337           1 : PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)
     338             : {
     339             :   PetscErrorCode ierr;
     340             : 
     341           1 :   PetscFunctionBegin;
     342           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     343           2 :   PetscValidLogicalCollectiveInt(eps,initialsize,2);
     344           1 :   ierr = PetscTryMethod(eps,"EPSGDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));CHKERRQ(ierr);
     345           2 :   PetscFunctionReturn(0);
     346             : }
     347             : 
     348             : /*@
     349             :    EPSGDGetInitialSize - Returns the initial size of the searching space.
     350             : 
     351             :    Not Collective
     352             : 
     353             :    Input Parameter:
     354             : .  eps - the eigenproblem solver context
     355             : 
     356             :    Output Parameter:
     357             : .  initialsize - number of vectors of the initial searching subspace
     358             : 
     359             :    Notes:
     360             :    If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
     361             :    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
     362             :    provided vectors are not enough, the solver completes the subspace with
     363             :    random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
     364             :    gets the first vector provided by the user or, if not available, a random vector,
     365             :    and expands the Krylov basis up to initialsize vectors.
     366             : 
     367             :    Level: advanced
     368             : 
     369             : .seealso: EPSGDSetInitialSize(), EPSGDGetKrylovStart()
     370             : @*/
     371          39 : PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)
     372             : {
     373             :   PetscErrorCode ierr;
     374             : 
     375          39 :   PetscFunctionBegin;
     376          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     377          39 :   PetscValidIntPointer(initialsize,2);
     378          39 :   ierr = PetscUseMethod(eps,"EPSGDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));CHKERRQ(ierr);
     379          78 :   PetscFunctionReturn(0);
     380             : }
     381             : 
     382             : /*@
     383             :    EPSGDSetBOrth - Selects the orthogonalization that will be used in the search
     384             :    subspace in case of generalized Hermitian problems.
     385             : 
     386             :    Logically Collective on eps
     387             : 
     388             :    Input Parameters:
     389             : +  eps   - the eigenproblem solver context
     390             : -  borth - whether to B-orthogonalize the search subspace
     391             : 
     392             :    Options Database Key:
     393             : .  -eps_gd_borth - Set the orthogonalization used in the search subspace
     394             : 
     395             :    Level: advanced
     396             : 
     397             : .seealso: EPSGDGetBOrth()
     398             : @*/
     399           1 : PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)
     400             : {
     401             :   PetscErrorCode ierr;
     402             : 
     403           1 :   PetscFunctionBegin;
     404           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     405           2 :   PetscValidLogicalCollectiveBool(eps,borth,2);
     406           1 :   ierr = PetscTryMethod(eps,"EPSGDSetBOrth_C",(EPS,PetscBool),(eps,borth));CHKERRQ(ierr);
     407           2 :   PetscFunctionReturn(0);
     408             : }
     409             : 
     410             : /*@
     411             :    EPSGDGetBOrth - Returns the orthogonalization used in the search
     412             :    subspace in case of generalized Hermitian problems.
     413             : 
     414             :    Not Collective
     415             : 
     416             :    Input Parameter:
     417             : .  eps - the eigenproblem solver context
     418             : 
     419             :    Output Parameters:
     420             : .  borth - whether to B-orthogonalize the search subspace
     421             : 
     422             :    Level: advanced
     423             : 
     424             : .seealso: EPSGDSetBOrth()
     425             : @*/
     426          39 : PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)
     427             : {
     428             :   PetscErrorCode ierr;
     429             : 
     430          39 :   PetscFunctionBegin;
     431          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     432          39 :   PetscValidBoolPointer(borth,2);
     433          39 :   ierr = PetscUseMethod(eps,"EPSGDGetBOrth_C",(EPS,PetscBool*),(eps,borth));CHKERRQ(ierr);
     434          78 :   PetscFunctionReturn(0);
     435             : }
     436             : 
     437          12 : static PetscErrorCode EPSGDSetDoubleExpansion_GD(EPS eps,PetscBool doubleexp)
     438             : {
     439          12 :   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;
     440             : 
     441          12 :   PetscFunctionBegin;
     442          12 :   data->doubleexp = doubleexp;
     443          12 :   PetscFunctionReturn(0);
     444             : }
     445             : 
     446             : /*@
     447             :    EPSGDSetDoubleExpansion - Activate a variant where the search subspace is
     448             :    expanded with K*[A*x B*x] (double expansion) instead of the classic K*r,
     449             :    where K is the preconditioner, x the selected approximate eigenvector and
     450             :    r its associated residual vector.
     451             : 
     452             :    Logically Collective on eps
     453             : 
     454             :    Input Parameters:
     455             : +  eps - the eigenproblem solver context
     456             : -  doubleexp - the boolean flag
     457             : 
     458             :    Options Database Keys:
     459             : .  -eps_gd_double_expansion - activate the double-expansion variant of GD
     460             : 
     461             :    Level: advanced
     462             : @*/
     463          12 : PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp)
     464             : {
     465             :   PetscErrorCode ierr;
     466             : 
     467          12 :   PetscFunctionBegin;
     468          12 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     469          24 :   PetscValidLogicalCollectiveBool(eps,doubleexp,2);
     470          12 :   ierr = PetscTryMethod(eps,"EPSGDSetDoubleExpansion_C",(EPS,PetscBool),(eps,doubleexp));CHKERRQ(ierr);
     471          24 :   PetscFunctionReturn(0);
     472             : }
     473             : 
     474           1 : static PetscErrorCode EPSGDGetDoubleExpansion_GD(EPS eps,PetscBool *doubleexp)
     475             : {
     476           1 :   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;
     477             : 
     478           1 :   PetscFunctionBegin;
     479           1 :   *doubleexp = data->doubleexp;
     480           1 :   PetscFunctionReturn(0);
     481             : }
     482             : 
     483             : /*@
     484             :    EPSGDGetDoubleExpansion - Gets a flag indicating whether the double
     485             :    expansion variant has been activated or not.
     486             : 
     487             :    Not Collective
     488             : 
     489             :    Input Parameter:
     490             : .  eps - the eigenproblem solver context
     491             : 
     492             :    Output Parameter:
     493             : .  doubleexp - the flag
     494             : 
     495             :    Level: advanced
     496             : 
     497             : .seealso: EPSGDSetDoubleExpansion()
     498             : @*/
     499           1 : PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp)
     500             : {
     501             :   PetscErrorCode ierr;
     502             : 
     503           1 :   PetscFunctionBegin;
     504           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     505           1 :   PetscValidBoolPointer(doubleexp,2);
     506           1 :   ierr = PetscUseMethod(eps,"EPSGDGetDoubleExpansion_C",(EPS,PetscBool*),(eps,doubleexp));CHKERRQ(ierr);
     507           2 :   PetscFunctionReturn(0);
     508             : }
     509             : 
     510          43 : SLEPC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps)
     511             : {
     512             :   PetscErrorCode  ierr;
     513             :   EPS_DAVIDSON    *data;
     514             : 
     515          43 :   PetscFunctionBegin;
     516          43 :   ierr = PetscNewLog(eps,&data);CHKERRQ(ierr);
     517          43 :   eps->data = (void*)data;
     518             : 
     519          43 :   data->blocksize   = 1;
     520          43 :   data->initialsize = 6;
     521          43 :   data->minv        = 6;
     522          43 :   data->plusk       = PETSC_DEFAULT;
     523          43 :   data->ipB         = PETSC_TRUE;
     524          43 :   data->fix         = 0.0;
     525          43 :   data->krylovstart = PETSC_FALSE;
     526          43 :   data->dynamic     = PETSC_FALSE;
     527             : 
     528          43 :   eps->useds = PETSC_TRUE;
     529          43 :   eps->categ = EPS_CATEGORY_PRECOND;
     530             : 
     531          43 :   eps->ops->solve          = EPSSolve_XD;
     532          43 :   eps->ops->setup          = EPSSetUp_GD;
     533          43 :   eps->ops->setupsort      = EPSSetUpSort_Default;
     534          43 :   eps->ops->setfromoptions = EPSSetFromOptions_GD;
     535          43 :   eps->ops->destroy        = EPSDestroy_GD;
     536          43 :   eps->ops->reset          = EPSReset_XD;
     537          43 :   eps->ops->view           = EPSView_GD;
     538          43 :   eps->ops->backtransform  = EPSBackTransform_Default;
     539          43 :   eps->ops->computevectors = EPSComputeVectors_XD;
     540          43 :   eps->ops->setdefaultst   = EPSSetDefaultST_Precond;
     541             : 
     542          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",EPSXDSetKrylovStart_XD);CHKERRQ(ierr);
     543          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",EPSXDGetKrylovStart_XD);CHKERRQ(ierr);
     544          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",EPSXDSetBOrth_XD);CHKERRQ(ierr);
     545          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",EPSXDGetBOrth_XD);CHKERRQ(ierr);
     546          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",EPSXDSetBlockSize_XD);CHKERRQ(ierr);
     547          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",EPSXDGetBlockSize_XD);CHKERRQ(ierr);
     548          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",EPSXDSetRestart_XD);CHKERRQ(ierr);
     549          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",EPSXDGetRestart_XD);CHKERRQ(ierr);
     550          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",EPSXDSetInitialSize_XD);CHKERRQ(ierr);
     551          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",EPSXDGetInitialSize_XD);CHKERRQ(ierr);
     552          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",EPSGDSetDoubleExpansion_GD);CHKERRQ(ierr);
     553          43 :   ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",EPSGDGetDoubleExpansion_GD);CHKERRQ(ierr);
     554          43 :   PetscFunctionReturn(0);
     555             : }
     556             : 

Generated by: LCOV version 1.13