Date: 2016-03-29T14:58:05+00:00

Actual source code: dvdschm.c
slepc-3.6.3 2016-03-29
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2015, 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,Method_t method)
     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,harmMode==DVD_HARM_NONE?PETSC_FALSE:PETSC_TRUE,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,(harmMode==DVD_HARM_NONE)?PETSC_FALSE:PETSC_TRUE);
     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:     switch (method) {
     56:     case DVD_METH_GD:
     57:     case DVD_METH_JD:
     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:       break;
     62:     case DVD_METH_GD2:
     63:       dvd_improvex_gd2(d,b,ksp,bs);
     64:       break;
     65:     }
     66:   }
     67:   return(0);
     68: }

     72: 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,Method_t method)
     73: {
     74:   PetscInt       check_sum0,check_sum1,maxits;
     75:   PetscReal      tol;

     79:   b->state = DVD_STATE_CONF;
     80:   check_sum0 = DVD_CHECKSUM(b);

     82:   /* Setup basic management of V */
     83:   dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,(harmMode==DVD_HARM_NONE)?PETSC_FALSE:PETSC_TRUE,allResiduals);

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

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

     91:   /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
     92:   dvd_calcpairs_qz(d,b,orth,cX_proj,(harmMode==DVD_HARM_NONE)?PETSC_FALSE:PETSC_TRUE);
     93:   if (harmMode != DVD_HARM_NONE) {
     94:     dvd_harm_conf(d,b,harmMode,fixedTarget,t);
     95:   }

     97:   /* Setup the method for improving the eigenvectors */
     98:   switch (method) {
     99:     case DVD_METH_GD:
    100:     case DVD_METH_JD:
    101:       dvd_improvex_jd(d,b,ksp,bs,cX_impr,dynamic);
    102:       dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);
    103:       KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits);
    104:       dvd_improvex_jd_lit_const(d,b,maxits,tol,fix);
    105:       break;
    106:     case DVD_METH_GD2:
    107:       dvd_improvex_gd2(d,b,ksp,bs);
    108:       break;
    109:   }

    111:   check_sum1 = DVD_CHECKSUM(b);
    112:   if (check_sum0 != check_sum1) SETERRQ(PETSC_COMM_SELF,1, "Something awful happened");
    113:   return(0);
    114: }