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