Actual source code: stimpl.h
slepc-3.13.2 2020-05-12
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-2020, Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
7: SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9: */
11: #if !defined(SLEPCSTIMPL_H)
12: #define SLEPCSTIMPL_H
14: #include <slepcst.h>
15: #include <slepc/private/slepcimpl.h>
17: SLEPC_EXTERN PetscBool STRegisterAllCalled;
18: SLEPC_EXTERN PetscErrorCode STRegisterAll(void);
19: SLEPC_EXTERN PetscLogEvent ST_SetUp,ST_ComputeOperator,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;
21: typedef struct _STOps *STOps;
23: struct _STOps {
24: PetscErrorCode (*apply)(ST,Vec,Vec);
25: PetscErrorCode (*applytrans)(ST,Vec,Vec);
26: PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);
27: PetscErrorCode (*setshift)(ST,PetscScalar);
28: PetscErrorCode (*getbilinearform)(ST,Mat*);
29: PetscErrorCode (*setup)(ST);
30: PetscErrorCode (*computeoperator)(ST);
31: PetscErrorCode (*setfromoptions)(PetscOptionItems*,ST);
32: PetscErrorCode (*postsolve)(ST);
33: PetscErrorCode (*destroy)(ST);
34: PetscErrorCode (*reset)(ST);
35: PetscErrorCode (*view)(ST,PetscViewer);
36: PetscErrorCode (*checknullspace)(ST,BV);
37: PetscErrorCode (*setdefaultksp)(ST);
38: };
40: /*
41: 'Updated' state means STSetUp must be called because matrices have been
42: modified, but the pattern is the same (hence reuse symbolic factorization)
43: */
44: typedef enum { ST_STATE_INITIAL,
45: ST_STATE_SETUP,
46: ST_STATE_UPDATED } STStateType;
48: struct _p_ST {
49: PETSCHEADER(struct _STOps);
50: /*------------------------- User parameters --------------------------*/
51: Mat *A; /* matrices that define the eigensystem */
52: PetscInt nmat; /* number of user-provided matrices */
53: PetscScalar sigma; /* value of the shift */
54: PetscScalar defsigma; /* default value of the shift */
55: STMatMode matmode; /* how the transformation matrix is handled */
56: MatStructure str; /* whether matrices have the same pattern or not */
57: PetscBool transform; /* whether transformed matrices are computed */
58: Vec D; /* diagonal matrix for balancing */
60: /*------------------------- Misc data --------------------------*/
61: KSP ksp; /* linear solver used in some ST's */
62: PetscBool usesksp; /* whether the KSP object is used or not */
63: PetscInt nwork; /* number of work vectors */
64: Vec *work; /* work vectors */
65: Vec wb; /* balancing requires an extra work vector */
66: Vec wht; /* extra work vector for hermitian transpose apply */
67: STStateType state; /* initial -> setup -> with updated matrices */
68: PetscObjectState *Astate; /* matrix state (to identify the original matrices) */
69: Mat *T; /* matrices resulting from transformation */
70: Mat Op; /* shell matrix for operator = alpha*D*inv(P)*M*inv(D) */
71: PetscBool opseized; /* whether Op has been seized by user */
72: PetscBool opready; /* whether Op is up-to-date or need be computed */
73: Mat P; /* matrix from which preconditioner is built */
74: Mat M; /* matrix corresponding to the non-inverted part of the operator */
75: PetscBool sigma_set; /* whether the user provided the shift or not */
76: PetscBool asymm; /* the user matrices are all symmetric */
77: PetscBool aherm; /* the user matrices are all hermitian */
78: void *data;
79: };
81: /*
82: Macros to test valid ST arguments
83: */
84: #if !defined(PETSC_USE_DEBUG)
86: #define STCheckMatrices(h,arg) do {} while (0)
87: #define STCheckNotSeized(h,arg) do {} while (0)
89: #else
91: #define STCheckMatrices(h,arg) \
92: do { \
93: if (!(h)->A) SETERRQ1(PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"ST matrices have not been set: Parameter #%d",arg); \
94: } while (0)
95: #define STCheckNotSeized(h,arg) \
96: do { \
97: if (h->opseized) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call STRestoreOperator() first: Parameter #%d",arg); \
98: } while (0)
100: #endif
102: SLEPC_INTERN PetscErrorCode STGetBilinearForm_Default(ST,Mat*);
103: SLEPC_INTERN PetscErrorCode STCheckNullSpace_Default(ST,BV);
104: SLEPC_INTERN PetscErrorCode STMatShellCreate(ST,PetscScalar,PetscInt,PetscInt*,PetscScalar*,Mat*);
105: SLEPC_INTERN PetscErrorCode STMatShellShift(Mat,PetscScalar);
106: SLEPC_INTERN PetscErrorCode STCheckFactorPackage(ST);
107: SLEPC_INTERN PetscErrorCode STMatMAXPY_Private(ST,PetscScalar,PetscScalar,PetscInt,PetscScalar*,PetscBool,Mat*);
108: SLEPC_INTERN PetscErrorCode STCoeffs_Monomial(ST,PetscScalar*);
109: SLEPC_INTERN PetscErrorCode STSetDefaultKSP(ST);
110: SLEPC_INTERN PetscErrorCode STSetDefaultKSP_Default(ST);
111: SLEPC_INTERN PetscErrorCode STIsInjective_Shell(ST,PetscBool*);
112: SLEPC_INTERN PetscErrorCode STComputeOperator(ST);
113: SLEPC_INTERN PetscErrorCode STGetOperator_Private(ST,Mat*);
114: SLEPC_INTERN PetscErrorCode STApply_Generic(ST,Vec,Vec);
115: SLEPC_INTERN PetscErrorCode STApplyTranspose_Generic(ST,Vec,Vec);
117: #endif