LCOV - code coverage report
Current view: top level - eps/impls/davidson/gd - gd.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 190 191 99.5 %
Date: 2024-04-25 00:48:42 Functions: 19 19 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14