LCOV - code coverage report
Current view: top level - eps/impls/davidson - dvdschm.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 35 35 100.0 %
Date: 2024-11-21 00:40:22 Functions: 2 2 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             : #include "davidson.h"
      12             : 
      13             : #define DVD_CHECKSUM(b) ((b)->max_size_V + (b)->max_size_oldX)
      14             : 
      15          97 : PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,KSP ksp,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscBool doubleexp)
      16             : {
      17          97 :   PetscInt       check_sum0,check_sum1;
      18             : 
      19          97 :   PetscFunctionBegin;
      20          97 :   PetscCall(PetscMemzero(b,sizeof(dvdBlackboard)));
      21          97 :   b->state = DVD_STATE_PRECONF;
      22             : 
      23         291 :   for (check_sum0=-1,check_sum1=DVD_CHECKSUM(b); check_sum0 != check_sum1; check_sum0 = check_sum1, check_sum1 = DVD_CHECKSUM(b)) {
      24             : 
      25             :     /* Setup basic management of V */
      26         194 :     PetscCall(dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals));
      27             : 
      28             :     /* Setup the initial subspace for V */
      29         194 :     PetscCall(dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE));
      30             : 
      31             :     /* Setup the convergence in order to use the SLEPc convergence test */
      32         194 :     PetscCall(dvd_testconv_slepc(d,b));
      33             : 
      34             :     /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
      35         194 :     PetscCall(dvd_calcpairs_qz(d,b,orth,PetscNot(harmMode==DVD_HARM_NONE)));
      36         194 :     if (harmMode != DVD_HARM_NONE) PetscCall(dvd_harm_conf(d,b,harmMode,PETSC_FALSE,0.0));
      37             : 
      38             :     /* Setup the method for improving the eigenvectors */
      39         194 :     if (doubleexp) PetscCall(dvd_improvex_gd2(d,b,ksp,bs));
      40             :     else {
      41         160 :       PetscCall(dvd_improvex_jd(d,b,ksp,bs,PETSC_FALSE));
      42         160 :       PetscCall(dvd_improvex_jd_proj_uv(d,b));
      43         194 :       PetscCall(dvd_improvex_jd_lit_const(d,b,0,0.0,0.0));
      44             :     }
      45             :   }
      46          97 :   PetscFunctionReturn(PETSC_SUCCESS);
      47             : }
      48             : 
      49          97 : PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,PetscBool fixedTarget,PetscScalar t,KSP ksp,PetscReal fix,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscBool dynamic,PetscBool doubleexp)
      50             : {
      51          97 :   PetscInt       check_sum0,check_sum1,maxits;
      52          97 :   PetscReal      tol;
      53             : 
      54          97 :   PetscFunctionBegin;
      55          97 :   b->state = DVD_STATE_CONF;
      56          97 :   check_sum0 = DVD_CHECKSUM(b);
      57             : 
      58             :   /* Setup basic management of V */
      59          97 :   PetscCall(dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals));
      60             : 
      61             :   /* Setup the initial subspace for V */
      62          97 :   PetscCall(dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE));
      63             : 
      64             :   /* Setup the convergence in order to use the SLEPc convergence test */
      65          97 :   PetscCall(dvd_testconv_slepc(d,b));
      66             : 
      67             :   /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
      68          97 :   PetscCall(dvd_calcpairs_qz(d,b,orth,PetscNot(harmMode==DVD_HARM_NONE)));
      69          97 :   if (harmMode != DVD_HARM_NONE) PetscCall(dvd_harm_conf(d,b,harmMode,fixedTarget,t));
      70             : 
      71             :   /* Setup the method for improving the eigenvectors */
      72          97 :   if (doubleexp) PetscCall(dvd_improvex_gd2(d,b,ksp,bs));
      73             :   else {
      74          80 :     PetscCall(dvd_improvex_jd(d,b,ksp,bs,dynamic));
      75          80 :     PetscCall(dvd_improvex_jd_proj_uv(d,b));
      76          80 :     PetscCall(KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits));
      77          80 :     PetscCall(dvd_improvex_jd_lit_const(d,b,maxits,tol,fix));
      78             :   }
      79             : 
      80          97 :   check_sum1 = DVD_CHECKSUM(b);
      81          97 :   PetscAssert(check_sum0==check_sum1,PETSC_COMM_SELF,PETSC_ERR_PLIB,"Something awful happened");
      82          97 :   PetscFunctionReturn(PETSC_SUCCESS);
      83             : }

Generated by: LCOV version 1.14