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: #if !defined(_MFNIMPL)
23: #define _MFNIMPL 25: #include <slepcmfn.h>
26: #include <slepc/private/slepcimpl.h>
28: PETSC_EXTERN PetscBool MFNRegisterAllCalled;
29: PETSC_EXTERN PetscErrorCode MFNRegisterAll(void);
30: PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;
32: typedef struct _MFNOps *MFNOps;
34: struct _MFNOps {
35: PetscErrorCode (*solve)(MFN,Vec,Vec);
36: PetscErrorCode (*setup)(MFN);
37: PetscErrorCode (*setfromoptions)(PetscOptions*,MFN);
38: PetscErrorCode (*publishoptions)(MFN);
39: PetscErrorCode (*destroy)(MFN);
40: PetscErrorCode (*reset)(MFN);
41: PetscErrorCode (*view)(MFN,PetscViewer);
42: };
44: /*
45: Maximum number of monitors you can run with a single MFN 46: */
47: #define MAXMFNMONITORS 5 49: /*
50: Defines the MFN data structure.
51: */
52: struct _p_MFN {
53: PETSCHEADER(struct _MFNOps);
54: /*------------------------- User parameters ---------------------------*/
55: Mat A; /* the problem matrix */
56: FN fn; /* which function to compute */
57: PetscInt max_it; /* maximum number of iterations */
58: PetscInt ncv; /* number of basis vectors */
59: PetscReal tol; /* tolerance */
60: PetscScalar sfactor; /* scaling factor */
61: PetscBool errorifnotconverged; /* error out if MFNSolve() does not converge */
63: /*-------------- User-provided functions and contexts -----------------*/
64: PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*);
65: PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**);
66: void *monitorcontext[MAXMFNMONITORS];
67: PetscInt numbermonitors;
69: /*----------------- Child objects and working data -------------------*/
70: BV V; /* set of basis vectors */
71: PetscRandom rand; /* random number generator */
72: PetscInt nwork; /* number of work vectors */
73: Vec *work; /* work vectors */
74: void *data; /* placeholder for solver-specific stuff */
76: /* ----------------------- Status variables -------------------------- */
77: PetscInt its; /* number of iterations so far computed */
78: PetscInt nv; /* size of current Schur decomposition */
79: PetscReal errest; /* error estimate */
80: PetscInt setupcalled;
81: MFNConvergedReason reason;
82: };
84: #endif