Actual source code: lmproducts.h

      1: #pragma once
      2: #include "lmbasis.h"

      4: PETSC_INTERN PetscLogEvent LMPROD_Mult;
      5: PETSC_INTERN PetscLogEvent LMPROD_Solve;
      6: PETSC_INTERN PetscLogEvent LMPROD_Update;

      8: // Refers to blocks of LMProducts
      9: typedef enum {
     10:   LMBLOCK_DIAGONAL              = 0,
     11:   LMBLOCK_UPPER_TRIANGLE        = 1,
     12:   LMBLOCK_STRICT_UPPER_TRIANGLE = 2,
     13:   LMBLOCK_FULL                  = 3,
     14:   LMBLOCK_END,
     15: } LMBlockType;

     17: // inner-products of LMBasis vectors
     18: typedef struct _n_LMProducts *LMProducts;
     19: struct _n_LMProducts {
     20:   PetscInt         m;
     21:   PetscInt         k;
     22:   PetscInt         m_local; // rank 0 will have all values (m_local = m), others have none (m_local = 0)
     23:   Mat              full;
     24:   Vec              diagonal_dup;    // duplicated on each host process
     25:   Vec              diagonal_global; // matches the memory location and layout of an LMBasis
     26:   Vec              diagonal_local;  // matches the memory location and layout of an LMBasis
     27:   PetscBool        update_diagonal_global;
     28:   LMBlockType      block_type;
     29:   PetscObjectId    operator_id;
     30:   PetscObjectState operator_state;
     31:   PetscBool        debug;
     32:   Vec              rhs_local, lhs_local;
     33: };

     35: PETSC_INTERN PetscErrorCode LMProductsCreate(LMBasis, LMBlockType, LMProducts *);
     36: PETSC_INTERN PetscErrorCode LMProductsDestroy(LMProducts *);
     37: PETSC_INTERN PetscErrorCode LMProductsReset(LMProducts);
     38: PETSC_INTERN PetscErrorCode LMProductsPrepare(LMProducts, Mat, PetscInt, PetscInt);
     39: PETSC_INTERN PetscErrorCode LMProductsInsertNextDiagonalValue(LMProducts, PetscInt, PetscScalar);
     40: PETSC_INTERN PetscErrorCode LMProductsGetDiagonalValue(LMProducts, PetscInt, PetscScalar *);
     41: PETSC_INTERN PetscErrorCode LMProductsUpdate(LMProducts, LMBasis, LMBasis);
     42: PETSC_INTERN PetscErrorCode LMProductsCopy(LMProducts, LMProducts);
     43: PETSC_INTERN PetscErrorCode LMProductsScale(LMProducts, PetscScalar);
     44: PETSC_INTERN PetscErrorCode LMProductsGetLocalMatrix(LMProducts, Mat *, PetscInt *, PetscBool *);
     45: PETSC_INTERN PetscErrorCode LMProductsRestoreLocalMatrix(LMProducts, Mat *, PetscInt *);
     46: PETSC_INTERN PetscErrorCode LMProductsGetLocalDiagonal(LMProducts, Vec *);
     47: PETSC_INTERN PetscErrorCode LMProductsRestoreLocalDiagonal(LMProducts, Vec *);
     48: PETSC_INTERN PetscErrorCode LMProductsSolve(LMProducts, PetscInt, PetscInt, Vec, Vec, PetscBool);
     49: PETSC_INTERN PetscErrorCode LMProductsMult(LMProducts, PetscInt, PetscInt, PetscScalar, Vec, PetscScalar, Vec, PetscBool);
     50: PETSC_INTERN PetscErrorCode LMProductsMultHermitian(LMProducts, PetscInt, PetscInt, PetscScalar, Vec, PetscScalar, Vec);
     51: PETSC_INTERN PetscErrorCode LMProductsGetNextColumn(LMProducts, Vec *);
     52: PETSC_INTERN PetscErrorCode LMProductsRestoreNextColumn(LMProducts, Vec *);
     53: PETSC_INTERN PetscErrorCode LMProductsMakeHermitian(Mat, PetscInt, PetscInt);
     54: PETSC_INTERN PetscErrorCode LMProductsOnesOnUnusedDiagonal(Mat, PetscInt, PetscInt);