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 { 13 #if !PetscDefined(HAVE_OPENMP) 14 PetscFunctionBegin; 15 #endif 16 PetscCallAbort(PETSC_COMM_SELF, kernel(dim, M, N, rows, cols, ptr, ctx)); 17 #if !PetscDefined(HAVE_OPENMP) 18 PetscFunctionReturnVoid(); 19 #endif 20 } 21 }; 22 23 struct Mat_Htool { 24 PetscInt dim; 25 PetscReal *gcoords_target; 26 PetscReal *gcoords_source; 27 PetscScalar *work_target; 28 PetscScalar *work_source; 29 PetscScalar s; 30 PetscInt bs[2]; 31 PetscReal epsilon; 32 PetscReal eta; 33 PetscInt depth[2]; 34 MatHtoolCompressorType compressor; 35 MatHtoolClusteringType clustering; 36 MatHtoolKernel kernel; 37 void *kernelctx; 38 WrapperHtool *wrapper; 39 htool::VirtualHMatrix<PetscScalar> *hmatrix; 40 }; 41 42 struct MatHtoolKernelTranspose { 43 Mat A; 44 MatHtoolKernel kernel; 45 void *kernelctx; 46 }; 47