LCOV - code coverage report
Current view: top level - home/gitlab-runner/builds/q8svuz_Y/0/slepc/slepc/include/slepc/private - stimpl.h (source / functions) Hit Total Coverage
Test: SLEPc Lines: 11 11 100.0 %
Date: 2024-04-30 00:46:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : 
      11             : #pragma once
      12             : 
      13             : #include <slepcst.h>
      14             : #include <slepc/private/slepcimpl.h>
      15             : 
      16             : /* SUBMANSEC = ST */
      17             : 
      18             : SLEPC_EXTERN PetscBool STRegisterAllCalled;
      19             : SLEPC_EXTERN PetscErrorCode STRegisterAll(void);
      20             : SLEPC_EXTERN PetscLogEvent ST_SetUp,ST_ComputeOperator,ST_Apply,ST_ApplyTranspose,ST_ApplyHermitianTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;
      21             : 
      22             : typedef struct _STOps *STOps;
      23             : 
      24             : struct _STOps {
      25             :   PetscErrorCode (*apply)(ST,Vec,Vec);
      26             :   PetscErrorCode (*applymat)(ST,Mat,Mat);
      27             :   PetscErrorCode (*applytrans)(ST,Vec,Vec);
      28             :   PetscErrorCode (*applyhermtrans)(ST,Vec,Vec);
      29             :   PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);
      30             :   PetscErrorCode (*setshift)(ST,PetscScalar);
      31             :   PetscErrorCode (*getbilinearform)(ST,Mat*);
      32             :   PetscErrorCode (*setup)(ST);
      33             :   PetscErrorCode (*computeoperator)(ST);
      34             :   PetscErrorCode (*setfromoptions)(ST,PetscOptionItems*);
      35             :   PetscErrorCode (*postsolve)(ST);
      36             :   PetscErrorCode (*destroy)(ST);
      37             :   PetscErrorCode (*reset)(ST);
      38             :   PetscErrorCode (*view)(ST,PetscViewer);
      39             :   PetscErrorCode (*checknullspace)(ST,BV);
      40             :   PetscErrorCode (*setdefaultksp)(ST);
      41             : };
      42             : 
      43             : /*
      44             :      'Updated' state means STSetUp must be called because matrices have been
      45             :      modified, but the pattern is the same (hence reuse symbolic factorization)
      46             : */
      47             : typedef enum { ST_STATE_INITIAL,
      48             :                ST_STATE_SETUP,
      49             :                ST_STATE_UPDATED } STStateType;
      50             : 
      51             : struct _p_ST {
      52             :   PETSCHEADER(struct _STOps);
      53             :   /*------------------------- User parameters --------------------------*/
      54             :   Mat              *A;               /* matrices that define the eigensystem */
      55             :   PetscInt         nmat;             /* number of user-provided matrices */
      56             :   PetscScalar      sigma;            /* value of the shift */
      57             :   PetscScalar      defsigma;         /* default value of the shift */
      58             :   STMatMode        matmode;          /* how the transformation matrix is handled */
      59             :   MatStructure     str;              /* whether matrices have the same pattern or not */
      60             :   PetscBool        transform;        /* whether transformed matrices are computed */
      61             :   Vec              D;                /* diagonal matrix for balancing */
      62             :   Mat              Pmat;             /* user-provided preconditioner matrix */
      63             :   PetscBool        Pmat_set;         /* whether the user provided a preconditioner matrix or not  */
      64             :   Mat              *Psplit;          /* matrices for the split preconditioner */
      65             :   PetscInt         nsplit;           /* number of split preconditioner matrices */
      66             :   MatStructure     strp;             /* pattern of split preconditioner matrices */
      67             : 
      68             :   /*------------------------- Misc data --------------------------*/
      69             :   KSP              ksp;              /* linear solver used in some ST's */
      70             :   PetscBool        usesksp;          /* whether the KSP object is used or not */
      71             :   PetscInt         nwork;            /* number of work vectors */
      72             :   Vec              *work;            /* work vectors */
      73             :   Vec              wb;               /* balancing requires an extra work vector */
      74             :   Vec              wht;              /* extra work vector for hermitian transpose apply */
      75             :   STStateType      state;            /* initial -> setup -> with updated matrices */
      76             :   PetscObjectState *Astate;          /* matrix state (to identify the original matrices) */
      77             :   Mat              *T;               /* matrices resulting from transformation */
      78             :   Mat              Op;               /* shell matrix for operator = alpha*D*inv(P)*M*inv(D) */
      79             :   PetscBool        opseized;         /* whether Op has been seized by user */
      80             :   PetscBool        opready;          /* whether Op is up-to-date or need be computed  */
      81             :   Mat              P;                /* matrix from which preconditioner is built */
      82             :   Mat              M;                /* matrix corresponding to the non-inverted part of the operator */
      83             :   PetscBool        sigma_set;        /* whether the user provided the shift or not */
      84             :   PetscBool        asymm;            /* the user matrices are all symmetric */
      85             :   PetscBool        aherm;            /* the user matrices are all hermitian */
      86             :   void             *data;
      87             : };
      88             : 
      89             : /*
      90             :     Macros to test valid ST arguments
      91             : */
      92             : #if !defined(PETSC_USE_DEBUG)
      93             : 
      94             : #define STCheckMatrices(h,arg) do {(void)(h);} while (0)
      95             : #define STCheckNotSeized(h,arg) do {(void)(h);} while (0)
      96             : 
      97             : #else
      98             : 
      99             : #define STCheckMatrices(h,arg) \
     100             :   do { \
     101             :     PetscCheck((h)->A,PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"ST matrices have not been set: Parameter #%d",arg); \
     102             :   } while (0)
     103             : #define STCheckNotSeized(h,arg) \
     104             :   do { \
     105             :     PetscCheck(!(h)->opseized,PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"Must call STRestoreOperator() first: Parameter #%d",arg); \
     106             :   } while (0)
     107             : 
     108             : #endif
     109             : 
     110             : SLEPC_INTERN PetscErrorCode STGetBilinearForm_Default(ST,Mat*);
     111             : SLEPC_INTERN PetscErrorCode STCheckNullSpace_Default(ST,BV);
     112             : SLEPC_INTERN PetscErrorCode STMatShellCreate(ST,PetscScalar,PetscInt,PetscInt*,PetscScalar*,Mat*);
     113             : SLEPC_INTERN PetscErrorCode STMatShellShift(Mat,PetscScalar);
     114             : SLEPC_INTERN PetscErrorCode STCheckFactorPackage(ST);
     115             : SLEPC_INTERN PetscErrorCode STMatMAXPY_Private(ST,PetscScalar,PetscScalar,PetscInt,PetscScalar*,PetscBool,PetscBool,Mat*);
     116             : SLEPC_INTERN PetscErrorCode STCoeffs_Monomial(ST,PetscScalar*);
     117             : SLEPC_INTERN PetscErrorCode STSetDefaultKSP(ST);
     118             : SLEPC_INTERN PetscErrorCode STSetDefaultKSP_Default(ST);
     119             : SLEPC_INTERN PetscErrorCode STIsInjective_Shell(ST,PetscBool*);
     120             : SLEPC_INTERN PetscErrorCode STComputeOperator(ST);
     121             : SLEPC_INTERN PetscErrorCode STGetOperator_Private(ST,Mat*);
     122             : SLEPC_INTERN PetscErrorCode STApply_Generic(ST,Vec,Vec);
     123             : SLEPC_INTERN PetscErrorCode STApplyMat_Generic(ST,Mat,Mat);
     124             : SLEPC_INTERN PetscErrorCode STApplyTranspose_Generic(ST,Vec,Vec);
     125             : SLEPC_INTERN PetscErrorCode STApplyHermitianTranspose_Generic(ST,Vec,Vec);
     126             : 
     127             : /*
     128             :   ST_KSPSetOperators - Sets the KSP matrices
     129             : */
     130        1122 : static inline PetscErrorCode ST_KSPSetOperators(ST st,Mat A,Mat B)
     131             : {
     132        1122 :   const char     *prefix;
     133             : 
     134        1122 :   PetscFunctionBegin;
     135        1122 :   if (!st->ksp) PetscCall(STGetKSP(st,&st->ksp));
     136        1122 :   PetscCall(STCheckFactorPackage(st));
     137        1122 :   PetscCall(KSPSetOperators(st->ksp,A,B));
     138        1122 :   PetscCall(MatGetOptionsPrefix(B,&prefix));
     139        1122 :   if (!prefix) {
     140             :     /* set Mat prefix to be the same as KSP to enable setting command-line options (e.g. MUMPS)
     141             :        only applies if the Mat has no user-defined prefix */
     142         524 :     PetscCall(KSPGetOptionsPrefix(st->ksp,&prefix));
     143         524 :     PetscCall(MatSetOptionsPrefix(B,prefix));
     144             :   }
     145        1122 :   PetscFunctionReturn(PETSC_SUCCESS);
     146             : }

Generated by: LCOV version 1.14