186a9fd05SPierre Jolivet #pragma once 286a9fd05SPierre Jolivet 386a9fd05SPierre Jolivet #include <petsc/private/matimpl.h> 486a9fd05SPierre Jolivet #include <petsc/private/vecimpl.h> 586a9fd05SPierre Jolivet 686a9fd05SPierre Jolivet struct _MatShellOps { 786a9fd05SPierre Jolivet /* 3 */ PetscErrorCode (*mult)(Mat, Vec, Vec); 886a9fd05SPierre Jolivet /* 5 */ PetscErrorCode (*multtranspose)(Mat, Vec, Vec); 986a9fd05SPierre Jolivet /* 17 */ PetscErrorCode (*getdiagonal)(Mat, Vec); 10a29b93afSAudic XU /* 32 */ PetscErrorCode (*getdiagonalblock)(Mat, Mat *); 1186a9fd05SPierre Jolivet /* 43 */ PetscErrorCode (*copy)(Mat, Mat, MatStructure); 1286a9fd05SPierre Jolivet /* 60 */ PetscErrorCode (*destroy)(Mat); 1386a9fd05SPierre Jolivet /* 121 */ PetscErrorCode (*multhermitiantranspose)(Mat, Vec, Vec); 1486a9fd05SPierre Jolivet }; 1586a9fd05SPierre Jolivet 1686a9fd05SPierre Jolivet struct _n_MatShellMatFunctionList { 1786a9fd05SPierre Jolivet PetscErrorCode (*symbolic)(Mat, Mat, Mat, void **); 1886a9fd05SPierre Jolivet PetscErrorCode (*numeric)(Mat, Mat, Mat, void *); 19*cc1eb50dSBarry Smith PetscCtxDestroyFn *destroy; 2086a9fd05SPierre Jolivet MatProductType ptype; 2186a9fd05SPierre Jolivet char *composedname; /* string to identify routine with double dispatch */ 2286a9fd05SPierre Jolivet char *resultname; /* result matrix type */ 2386a9fd05SPierre Jolivet 2486a9fd05SPierre Jolivet struct _n_MatShellMatFunctionList *next; 2586a9fd05SPierre Jolivet }; 2686a9fd05SPierre Jolivet typedef struct _n_MatShellMatFunctionList *MatShellMatFunctionList; 2786a9fd05SPierre Jolivet 2886a9fd05SPierre Jolivet typedef struct { 2986a9fd05SPierre Jolivet struct _MatShellOps ops[1]; 3086a9fd05SPierre Jolivet 3186a9fd05SPierre Jolivet /* The user will manage the scaling and shifts for the MATSHELL, not the default */ 3286a9fd05SPierre Jolivet PetscBool managescalingshifts; 3386a9fd05SPierre Jolivet 3486a9fd05SPierre Jolivet /* support for MatScale, MatShift and MatMultAdd */ 3586a9fd05SPierre Jolivet PetscScalar vscale, vshift; 3686a9fd05SPierre Jolivet Vec dshift; 3786a9fd05SPierre Jolivet Vec left, right; 3886a9fd05SPierre Jolivet Vec left_work, right_work; 3986a9fd05SPierre Jolivet Vec left_add_work, right_add_work; 4086a9fd05SPierre Jolivet 4186a9fd05SPierre Jolivet /* support for MatAXPY */ 4286a9fd05SPierre Jolivet Mat axpy; 4386a9fd05SPierre Jolivet PetscScalar axpy_vscale; 4486a9fd05SPierre Jolivet Vec axpy_left, axpy_right; 4586a9fd05SPierre Jolivet PetscObjectState axpy_state; 4686a9fd05SPierre Jolivet 4786a9fd05SPierre Jolivet /* support for ZeroRows/Columns operations */ 4886a9fd05SPierre Jolivet IS zrows; 4986a9fd05SPierre Jolivet IS zcols; 5086a9fd05SPierre Jolivet Vec zvals; 5186a9fd05SPierre Jolivet Vec zvals_w; 5286a9fd05SPierre Jolivet VecScatter zvals_sct_r; 5386a9fd05SPierre Jolivet VecScatter zvals_sct_c; 5486a9fd05SPierre Jolivet 5586a9fd05SPierre Jolivet /* MatMat operations */ 5686a9fd05SPierre Jolivet MatShellMatFunctionList matmat; 5786a9fd05SPierre Jolivet 5886a9fd05SPierre Jolivet /* user defined context */ 5986a9fd05SPierre Jolivet PetscContainer ctxcontainer; 6086a9fd05SPierre Jolivet } Mat_Shell; 6186a9fd05SPierre Jolivet 6286a9fd05SPierre Jolivet PETSC_INTERN PetscErrorCode MatAssemblyEnd_Shell(Mat X, MatAssemblyType assembly); 63