LCOV - code coverage report
Current view: top level - eps/impls/davidson - dvdschm.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 36 36 100.0 %
Date: 2019-10-20 05:41:02 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-2019, 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          90 : 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             :   PetscErrorCode ierr;
      18             :   PetscInt       check_sum0,check_sum1;
      19             : 
      20          90 :   PetscFunctionBegin;
      21          90 :   ierr = PetscMemzero(b,sizeof(dvdBlackboard));CHKERRQ(ierr);
      22          90 :   b->state = DVD_STATE_PRECONF;
      23             : 
      24         270 :   for (check_sum0=-1,check_sum1=DVD_CHECKSUM(b); check_sum0 != check_sum1; check_sum0 = check_sum1, check_sum1 = DVD_CHECKSUM(b)) {
      25             : 
      26             :     /* Setup basic management of V */
      27         180 :     ierr = dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);CHKERRQ(ierr);
      28             : 
      29             :     /* Setup the initial subspace for V */
      30         180 :     ierr = dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr);
      31             : 
      32             :     /* Setup the convergence in order to use the SLEPc convergence test */
      33         180 :     ierr = dvd_testconv_slepc(d,b);CHKERRQ(ierr);
      34             : 
      35             :     /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
      36         180 :     ierr = dvd_calcpairs_qz(d,b,orth,PetscNot(harmMode==DVD_HARM_NONE));CHKERRQ(ierr);
      37         180 :     if (harmMode != DVD_HARM_NONE) {
      38          42 :       ierr = dvd_harm_conf(d,b,harmMode,PETSC_FALSE,0.0);CHKERRQ(ierr);
      39             :     }
      40             : 
      41             :     /* Setup the method for improving the eigenvectors */
      42         180 :     if (doubleexp) {
      43          34 :       ierr = dvd_improvex_gd2(d,b,ksp,bs);CHKERRQ(ierr);
      44             :     } else {
      45         146 :       ierr = dvd_improvex_jd(d,b,ksp,bs,PETSC_FALSE);CHKERRQ(ierr);
      46         146 :       ierr = dvd_improvex_jd_proj_uv(d,b);CHKERRQ(ierr);
      47         146 :       ierr = dvd_improvex_jd_lit_const(d,b,0,0.0,0.0);CHKERRQ(ierr);
      48             :     }
      49             :   }
      50          90 :   PetscFunctionReturn(0);
      51             : }
      52             : 
      53          90 : 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)
      54             : {
      55             :   PetscInt       check_sum0,check_sum1,maxits;
      56             :   PetscReal      tol;
      57             :   PetscErrorCode ierr;
      58             : 
      59          90 :   PetscFunctionBegin;
      60          90 :   b->state = DVD_STATE_CONF;
      61          90 :   check_sum0 = DVD_CHECKSUM(b);
      62             : 
      63             :   /* Setup basic management of V */
      64          90 :   ierr = dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);CHKERRQ(ierr);
      65             : 
      66             :   /* Setup the initial subspace for V */
      67          90 :   ierr = dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr);
      68             : 
      69             :   /* Setup the convergence in order to use the SLEPc convergence test */
      70          90 :   ierr = dvd_testconv_slepc(d,b);CHKERRQ(ierr);
      71             : 
      72             :   /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
      73          90 :   ierr = dvd_calcpairs_qz(d,b,orth,PetscNot(harmMode==DVD_HARM_NONE));CHKERRQ(ierr);
      74          90 :   if (harmMode != DVD_HARM_NONE) {
      75          21 :     ierr = dvd_harm_conf(d,b,harmMode,fixedTarget,t);CHKERRQ(ierr);
      76             :   }
      77             : 
      78             :   /* Setup the method for improving the eigenvectors */
      79          90 :   if (doubleexp) {
      80          17 :     ierr = dvd_improvex_gd2(d,b,ksp,bs);CHKERRQ(ierr);
      81             :   } else {
      82          73 :     ierr = dvd_improvex_jd(d,b,ksp,bs,dynamic);CHKERRQ(ierr);
      83          73 :     ierr = dvd_improvex_jd_proj_uv(d,b);CHKERRQ(ierr);
      84          73 :     ierr = KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits);CHKERRQ(ierr);
      85          73 :     ierr = dvd_improvex_jd_lit_const(d,b,maxits,tol,fix);CHKERRQ(ierr);
      86             :   }
      87             : 
      88          90 :   check_sum1 = DVD_CHECKSUM(b);
      89          90 :   if (check_sum0 != check_sum1) SETERRQ(PETSC_COMM_SELF,1,"Something awful happened");
      90          90 :   PetscFunctionReturn(0);
      91             : }

Generated by: LCOV version 1.13