Actual source code: dvd_testconv.c

  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: test for convergence

  6:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  8:    Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain

 10:    This file is part of SLEPc.
 11:       
 12:    SLEPc is free software: you can redistribute it and/or modify it under  the
 13:    terms of version 3 of the GNU Lesser General Public License as published by
 14:    the Free Software Foundation.

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

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

 26:  #include davidson.h

 28: PetscTruth dvd_testconv_basic_0(dvdDashboard *d, PetscScalar eigvr,
 29:                                 PetscScalar eigvi, PetscReal r,
 30:                                 PetscReal *err);
 31: PetscTruth dvd_testconv_slepc_0(dvdDashboard *d, PetscScalar eigvr,
 32:                                 PetscScalar eigvi, PetscReal r,
 33:                                 PetscReal *err);

 37: PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b)
 38: {
 39:   PetscErrorCode  ierr;


 43:   /* Setup the step */
 44:   if (b->state >= DVD_STATE_CONF) {
 45:     if (d->testConv_data) {
 46:       PetscFree(d->testConv_data);
 47:     }
 48:     d->testConv_data = PETSC_NULL;
 49:     d->testConv = dvd_testconv_basic_0;
 50:   }

 52:   return(0);
 53: }

 57: PetscTruth dvd_testconv_basic_0(dvdDashboard *d, PetscScalar eigvr,
 58:                                 PetscScalar eigvi, PetscReal r,
 59:                                 PetscReal *err)
 60: {
 61:   PetscTruth      conv;
 62:   PetscReal       eig_norm, errest;


 66:   eig_norm = SlepcAbsEigenvalue(eigvr, eigvi);
 67:   //errest = (r < eig_norm) ? r/eig_norm : r;
 68:   errest = r/eig_norm;
 69:   conv = (errest <= d->tol) ? PETSC_TRUE : PETSC_FALSE;
 70:   if (err) *err = errest;

 72:   PetscFunctionReturn(conv);
 73: }

 77: PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b)
 78: {
 79:   PetscErrorCode  ierr;


 83:   /* Setup the step */
 84:   if (b->state >= DVD_STATE_CONF) {
 85:     if (d->testConv_data) {
 86:       PetscFree(d->testConv_data);
 87:     }
 88:     d->testConv_data = PETSC_NULL;
 89:     d->testConv = dvd_testconv_slepc_0;
 90:   }

 92:   return(0);
 93: }

 97: PetscTruth dvd_testconv_slepc_0(dvdDashboard *d, PetscScalar eigvr,
 98:                                 PetscScalar eigvi, PetscReal r,
 99:                                 PetscReal *err)
100: {
101:   PetscErrorCode  ierr;


105:   (*d->eps->conv_func)(d->eps, eigvr, eigvi, r, err,
106:                               d->eps->conv_ctx);
107:   CHKERRABORT(((PetscObject)d->eps)->comm, ierr);

109:   PetscFunctionReturn(*err<d->eps->tol ? PETSC_TRUE : PETSC_FALSE);
110: }