1 #include <petsc/private/matimpl.h> 2 #include <htool/misc/petsc.hpp> 3 4 class WrapperHtool : public htool::IMatrix<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) : IMatrix(M,N), dim(sdim), kernel(g), ctx(kernelctx) { } 11 PetscScalar get_coef(const PetscInt& i,const PetscInt& j) const { return kernel(dim,i,j,ctx); } 12 }; 13 14 struct Mat_Htool { 15 PetscInt dim; 16 PetscReal *gcoords_target; 17 PetscReal *gcoords_source; 18 PetscScalar *work_target; 19 PetscScalar *work_source; 20 PetscScalar s; 21 PetscInt bs[2]; 22 PetscReal epsilon; 23 PetscReal eta; 24 PetscInt depth[2]; 25 MatHtoolCompressorType compressor; 26 MatHtoolKernel kernel; 27 void* kernelctx; 28 WrapperHtool *wrapper; 29 htool::HMatrixVirtual<PetscScalar> *hmatrix; 30 }; 31 32 struct MatHtoolKernelTranspose { 33 Mat A; 34 MatHtoolKernel kernel; 35 void* kernelctx; 36 }; 37