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