Actual source code: nepdefl.h

slepc-main 2024-12-17
Report Typos and Errors
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-, 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: */

 14: #pragma once

 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:   Mat          P;
 64:   BV           U;
 65:   PetscScalar  *A;
 66:   PetscScalar  *B;
 67:   PetscScalar  theta;
 68:   PetscInt     n;
 69:   NEP_EXT_OP   extop;
 70:   PetscBool    jacob;
 71:   Vec          w[2];
 72:   PetscScalar  *work;
 73:   PetscScalar  *hfj;
 74:   PetscScalar  *hfjp;
 75:   PetscBool    hfjset;
 76: } NEP_DEF_MATSHELL;

 78: struct _n_nep_def_project {
 79:   Mat          *V1pApX;
 80:   Mat          XpV1;
 81:   PetscScalar  *V2;
 82:   Vec          w;
 83:   BV           V1;
 84:   PetscInt     dim;
 85:   PetscScalar  *work;
 86:   PetscInt     lwork;
 87:   NEP_EXT_OP   extop;
 88: };

 90: #if 0
 91: typedef struct {
 92:   PC          pc;      /* basic preconditioner */
 93:   PetscScalar *M;
 94:   PetscScalar *ps;
 95:   PetscInt    ld;
 96:   Vec         *work;
 97:   BV          X;
 98:   PetscInt    n;
 99: } NEP_DEF_PCSHELL;
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);