Actual source code: htool.hpp
1: #pragma once
3: #include <petsc/private/matimpl.h>
4: #include <htool/misc/petsc.hpp>
6: class WrapperHtool : public htool::VirtualGenerator<PetscScalar> {
7: PetscInt dim;
8: MatHtoolKernelFn *&kernel;
9: void *ctx;
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: };
25: struct Mat_Htool {
26: PetscInt dim;
27: PetscReal *gcoords_target;
28: PetscReal *gcoords_source;
29: PetscScalar *work_target;
30: PetscScalar *work_source;
31: PetscScalar s;
32: PetscInt bs[2];
33: PetscReal epsilon;
34: PetscReal eta;
35: PetscInt depth[2];
36: MatHtoolCompressorType compressor;
37: MatHtoolClusteringType clustering;
38: MatHtoolKernelFn *kernel;
39: void *kernelctx;
40: WrapperHtool *wrapper;
41: htool::VirtualHMatrix<PetscScalar> *hmatrix;
42: };
44: struct MatHtoolKernelTranspose {
45: Mat A;
46: MatHtoolKernelFn *kernel;
47: void *kernelctx;
48: };