Actual source code: dvdschm.c

slepc-3.7.3 2016-09-29
Report Typos and Errors
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

  6:    This file is part of SLEPc.

  8:    SLEPc is free software: you can redistribute it and/or modify it under  the
  9:    terms of version 3 of the GNU Lesser General Public License as published by
 10:    the Free Software Foundation.

 12:    SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 13:    WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 14:    FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 15:    more details.

 17:    You  should have received a copy of the GNU Lesser General  Public  License
 18:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 19:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 20: */

 22:  #include davidson.h

 24: #define DVD_CHECKSUM(b) ((b)->max_size_V + (b)->max_size_oldX)

 28: 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,PetscInt cX_proj,PetscInt cX_impr,PetscBool doubleexp)
 29: {
 31:   PetscInt       check_sum0,check_sum1;

 34:   PetscMemzero(b,sizeof(dvdBlackboard));
 35:   b->state = DVD_STATE_PRECONF;

 37:   for (check_sum0=-1,check_sum1=DVD_CHECKSUM(b); check_sum0 != check_sum1; check_sum0 = check_sum1, check_sum1 = DVD_CHECKSUM(b)) {

 39:     /* Setup basic management of V */
 40:     dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);

 42:     /* Setup the initial subspace for V */
 43:     dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);

 45:     /* Setup the convergence in order to use the SLEPc convergence test */
 46:     dvd_testconv_slepc(d,b);

 48:     /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
 49:     dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));
 50:     if (harmMode != DVD_HARM_NONE) {
 51:       dvd_harm_conf(d,b,harmMode,PETSC_FALSE,0.0);
 52:     }

 54:     /* Setup the method for improving the eigenvectors */
 55:     if (doubleexp) {
 56:       dvd_improvex_gd2(d,b,ksp,bs);
 57:     } else {
 58:       dvd_improvex_jd(d,b,ksp,bs,cX_impr,PETSC_FALSE);
 59:       dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);
 60:       dvd_improvex_jd_lit_const(d,b,0,0.0,0.0);
 61:     }
 62:   }
 63:   return(0);
 64: }

 68: 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,PetscInt cX_proj,PetscInt cX_impr,PetscBool dynamic,PetscBool doubleexp)
 69: {
 70:   PetscInt       check_sum0,check_sum1,maxits;
 71:   PetscReal      tol;

 75:   b->state = DVD_STATE_CONF;
 76:   check_sum0 = DVD_CHECKSUM(b);

 78:   /* Setup basic management of V */
 79:   dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);

 81:   /* Setup the initial subspace for V */
 82:   dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);

 84:   /* Setup the convergence in order to use the SLEPc convergence test */
 85:   dvd_testconv_slepc(d,b);

 87:   /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
 88:   dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));
 89:   if (harmMode != DVD_HARM_NONE) {
 90:     dvd_harm_conf(d,b,harmMode,fixedTarget,t);
 91:   }

 93:   /* Setup the method for improving the eigenvectors */
 94:   if (doubleexp) {
 95:     dvd_improvex_gd2(d,b,ksp,bs);
 96:   } else {
 97:     dvd_improvex_jd(d,b,ksp,bs,cX_impr,dynamic);
 98:     dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);
 99:     KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits);
100:     dvd_improvex_jd_lit_const(d,b,maxits,tol,fix);
101:   }

103:   check_sum1 = DVD_CHECKSUM(b);
104:   if (check_sum0 != check_sum1) SETERRQ(PETSC_COMM_SELF,1, "Something awful happened");
105:   return(0);
106: }