Actual source code: nepdefl.h
slepc-3.16.0 2021-09-30
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-2021, 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: */
10: /*
11: Private header for Deflation in NEP
12: */
13: #if !defined(SLEPC_NEPDEFL_H)
14: #define SLEPC_NEPDEFL_H
16: # define MAX_MINIDX 1
18: typedef struct _n_nep_ext_op *NEP_EXT_OP;
19: typedef struct _n_nep_def_fun_solve *NEP_DEF_FUN_SOLVE;
20: typedef struct _n_nep_def_project *NEP_DEF_PROJECT;
22: /* Structure characterizing a deflation context */
23: struct _n_nep_ext_op {
24: NEP nep;
25: PetscScalar *H; /* invariant pair (X,H) */
26: BV X; /* locked eigenvectors */
27: PetscScalar *bc; /* polinomial basis roots */
28: RG rg;
29: PetscInt midx; /* minimality index */
30: PetscInt max_midx;
31: PetscInt szd; /* maximum size for deflation */
32: PetscInt n; /* invariant pair size */
33: PetscBool ref; /* refine with original size */
34: Mat MF; /* function shell matrix */
35: Mat MJ; /* Jacobian shell matrix */
36: PetscBool simpU; /* the way U is computed */
37: NEP_DEF_FUN_SOLVE solve; /* MatSolve context for the operator */
38: NEP_DEF_PROJECT proj; /* context for the projected eigenproblem */
39: /* auxiliary computations */
40: BV W;
41: PetscScalar *Hj; /* matrix containing the powers of the invariant pair matrix */
42: PetscScalar *XpX; /* X^*X */
43: DS ds;
44: Vec w;
45: };
47: struct _n_nep_def_fun_solve {
48: KSP ksp; /* */
49: PetscBool sincf;
50: Mat T;
51: PetscScalar theta;
52: PetscInt n;
53: PetscScalar *M;
54: PetscScalar *work;
55: Vec w[2];
56: BV T_1U;
57: NEP_EXT_OP extop;
58: };
60: typedef struct {
61: NEP nep;
62: Mat T;
63: BV U;
64: PetscScalar *A;
65: PetscScalar *B;
66: PetscScalar theta;
67: PetscInt n;
68: NEP_EXT_OP extop;
69: PetscBool jacob;
70: Vec w[2];
71: PetscScalar *work;
72: PetscScalar *hfj;
73: PetscScalar *hfjp;
74: PetscBool hfjset;
75: } NEP_DEF_MATSHELL;
77: struct _n_nep_def_project {
78: Mat *V1pApX;
79: Mat XpV1;
80: PetscScalar *V2;
81: Vec w;
82: BV V1;
83: PetscInt dim;
84: PetscScalar *work;
85: PetscInt lwork;
86: NEP_EXT_OP extop;
87: };
89: #if 0
90: typedef struct {
91: PC pc; /* basic preconditioner */
92: PetscScalar *M;
93: PetscScalar *ps;
94: PetscInt ld;
95: Vec *work;
96: BV X;
97: PetscInt n;
98: } NEP_DEF_PCSHELL;
99: #endif
100: #endif
102: SLEPC_INTERN PetscErrorCode NEPDeflationCopyToExtendedVec(NEP_EXT_OP,Vec,PetscScalar*,Vec,PetscBool);
103: SLEPC_INTERN PetscErrorCode NEPDeflationReset(NEP_EXT_OP);
104: SLEPC_INTERN PetscErrorCode NEPDeflationInitialize(NEP,BV,KSP,PetscBool,PetscInt,NEP_EXT_OP*);
105: SLEPC_INTERN PetscErrorCode NEPDeflationCreateVec(NEP_EXT_OP,Vec*);
106: SLEPC_INTERN PetscErrorCode NEPDeflationComputeFunction(NEP_EXT_OP,PetscScalar,Mat*);
107: SLEPC_INTERN PetscErrorCode NEPDeflationComputeJacobian(NEP_EXT_OP,PetscScalar,Mat*);
108: SLEPC_INTERN PetscErrorCode NEPDeflationSolveSetUp(NEP_EXT_OP,PetscScalar);
109: SLEPC_INTERN PetscErrorCode NEPDeflationFunctionSolve(NEP_EXT_OP,Vec,Vec);
110: SLEPC_INTERN PetscErrorCode NEPDeflationGetInvariantPair(NEP_EXT_OP,BV*,Mat*);
111: SLEPC_INTERN PetscErrorCode NEPDeflationLocking(NEP_EXT_OP,Vec,PetscScalar);
112: SLEPC_INTERN PetscErrorCode NEPDeflationSetRandomVec(NEP_EXT_OP,Vec);
113: SLEPC_INTERN PetscErrorCode NEPDeflationProjectOperator(NEP_EXT_OP,BV,DS,PetscInt,PetscInt);
114: SLEPC_INTERN PetscErrorCode NEPDeflationCreateBV(NEP_EXT_OP,PetscInt,BV*);
115: SLEPC_INTERN PetscErrorCode NEPDeflationSetRefine(NEP_EXT_OP,PetscBool);
116: SLEPC_INTERN PetscErrorCode NEPDeflationExtractEigenpair(NEP_EXT_OP,PetscInt,Vec,PetscScalar,DS);