1 #include <petsc/private/matimpl.h> 2 #include <htool/misc/petsc.hpp> 3 4 class WrapperHtool : public htool::VirtualGenerator<PetscScalar> { 5 PetscInt dim; 6 MatHtoolKernel& kernel; 7 void* ctx; 8 9 public: 10 WrapperHtool(PetscInt M,PetscInt N,PetscInt sdim,MatHtoolKernel& g,void* kernelctx) : VirtualGenerator(M,N), dim(sdim), kernel(g), ctx(kernelctx) { } 11 void copy_submatrix(PetscInt M, PetscInt N, const PetscInt *rows, const PetscInt *cols, PetscScalar *ptr) const { 12 PetscFunctionBegin; 13 PetscCallAbort(PETSC_COMM_SELF,kernel(dim,M,N,rows,cols,ptr,ctx)); 14 PetscFunctionReturnVoid(); 15 } 16 }; 17 18 struct Mat_Htool { 19 PetscInt dim; 20 PetscReal *gcoords_target; 21 PetscReal *gcoords_source; 22 PetscScalar *work_target; 23 PetscScalar *work_source; 24 PetscScalar s; 25 PetscInt bs[2]; 26 PetscReal epsilon; 27 PetscReal eta; 28 PetscInt depth[2]; 29 MatHtoolCompressorType compressor; 30 MatHtoolClusteringType clustering; 31 MatHtoolKernel kernel; 32 void* kernelctx; 33 WrapperHtool *wrapper; 34 htool::VirtualHMatrix<PetscScalar> *hmatrix; 35 }; 36 37 struct MatHtoolKernelTranspose { 38 Mat A; 39 MatHtoolKernel kernel; 40 void* kernelctx; 41 }; 42