Actual source code: mfnimpl.h

  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2013, 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: #if !defined(_MFNIMPL)
 23: #define _MFNIMPL

 25: #include <slepcmfn.h>
 26: #include <slepc-private/slepcimpl.h>

 28: PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;

 30: typedef struct _MFNOps *MFNOps;

 32: struct _MFNOps {
 33:   PetscErrorCode (*solve)(MFN,Vec,Vec);
 34:   PetscErrorCode (*setup)(MFN);
 35:   PetscErrorCode (*setfromoptions)(MFN);
 36:   PetscErrorCode (*publishoptions)(MFN);
 37:   PetscErrorCode (*destroy)(MFN);
 38:   PetscErrorCode (*reset)(MFN);
 39:   PetscErrorCode (*view)(MFN,PetscViewer);
 40: };

 42: /*
 43:      Maximum number of monitors you can run with a single MFN
 44: */
 45: #define MAXMFNMONITORS 5

 47: /*
 48:    Defines the MFN data structure.
 49: */
 50: struct _p_MFN {
 51:   PETSCHEADER(struct _MFNOps);
 52:   /*------------------------- User parameters --------------------------*/
 53:   PetscInt        max_it;         /* maximum number of iterations */
 54:   PetscInt        ncv;            /* number of basis vectors */
 55:   PetscReal       tol;            /* tolerance */
 56:   SlepcFunction   function;       /* which function to compute */
 57:   PetscScalar     sfactor;        /* scaling factor */
 58:   PetscBool       errorifnotconverged;    /* error out if MFNSolve() does not converge */

 60:   /*------------------------- Working data --------------------------*/
 61:   Mat             A;              /* the problem matrix */
 62:   Vec             *V;             /* set of basis vectors */
 63:   PetscReal       errest;         /* error estimate */
 64:   IP              ip;             /* innerproduct object */
 65:   DS              ds;             /* direct solver object */
 66:   void            *data;          /* placeholder for misc stuff associated
 67:                                      with a particular solver */
 68:   PetscInt        its;            /* number of iterations so far computed */
 69:   PetscInt        nv;             /* size of current Schur decomposition */
 70:   PetscInt        n,nloc;         /* problem dimensions (global, local) */
 71:   PetscInt        allocated_ncv;  /* number of basis vectors allocated */
 72:   PetscRandom     rand;           /* random number generator */
 73:   Vec             t;              /* template vector */

 75:   /* ---------------- Default work-area and status vars -------------------- */
 76:   PetscInt       nwork;
 77:   Vec            *work;

 79:   PetscInt       setupcalled;
 80:   MFNConvergedReason reason;

 82:   PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*);
 83:   PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**);
 84:   void           *monitorcontext[MAXMFNMONITORS];
 85:   PetscInt       numbermonitors;
 86: };

 88: PETSC_INTERN PetscErrorCode MFNReset_Default(MFN);
 89: PETSC_INTERN PetscErrorCode MFNDefaultGetWork(MFN,PetscInt);
 90: PETSC_INTERN PetscErrorCode MFNDefaultFreeWork(MFN);
 91: PETSC_INTERN PetscErrorCode MFNAllocateSolution(MFN);
 92: PETSC_INTERN PetscErrorCode MFNFreeSolution(MFN);

 94: #endif