1 #pragma once 2 3 #include <petsc/private/kspimpl.h> 4 5 #define PETSC_PCHPDDM_MAXLEVELS 9 6 7 #define PETSC_KSPHPDDM_DEFAULT_PRECISION PETSC_DEPRECATED_MACRO(3, 25, 0, "PETSC_SCALAR_PRECISION", ) PETSC_SCALAR_PRECISION 8 9 namespace HPDDM 10 { 11 template <class> 12 class Schwarz; /* forward definitions of two needed HPDDM classes */ 13 class PETScOperator; 14 } // namespace HPDDM 15 16 struct PC_HPDDM_Level { 17 VecScatter scatter; /* scattering from PETSc nonoverlapping numbering to HPDDM overlapping */ 18 Vec *v[2]; /* working vectors */ 19 Mat V[3]; /* working matrices */ 20 KSP ksp; /* KSP coupling the action of pc and P */ 21 PC pc; /* inner fine-level PC, acting like a multigrid smoother */ 22 HPDDM::Schwarz<PetscScalar> *P; /* coarse-level HPDDM solver */ 23 Vec D; /* partition of unity */ 24 PetscReal threshold; /* threshold for selecting local deflation vectors */ 25 PetscInt nu; /* number of local deflation vectors */ 26 const struct PC_HPDDM *parent; /* parent PC */ 27 }; 28 29 struct PC_HPDDM { 30 PC_HPDDM_Level **levels; /* array of shells */ 31 Mat aux; /* local auxiliary matrix defined at the finest level on PETSC_COMM_SELF */ 32 Mat B; /* right-hand side matrix defined at the finest level on PETSC_COMM_SELF */ 33 Vec normal; /* temporary Vec when preconditioning the normal equations with KSPLSQR */ 34 IS is; /* global numbering of the auxiliary matrix */ 35 PetscInt N; /* number of levels */ 36 PCHPDDMCoarseCorrectionType correction; /* type of coarse correction */ 37 PetscBool3 Neumann; /* aux is the local Neumann matrix? */ 38 PetscBool log_separate; /* separate events for each level? */ 39 PetscBool share; /* shared subdomain KSP between SLEPc and PETSc? */ 40 PetscBool deflation; /* aux is the local deflation space? */ 41 PetscErrorCode (*setup)(Mat, PetscReal, Vec, Vec, PetscReal, IS, void *); /* setup function for the auxiliary matrix */ 42 void *setup_ctx; /* context for setup */ 43 }; 44 45 struct KSP_HPDDM { 46 HPDDM::PETScOperator *op; 47 PetscReal rcntl[1]; 48 int icntl[2]; 49 unsigned short scntl[2]; 50 char cntl[5]; 51 PetscPrecision precision; 52 }; 53 54 typedef struct _n_Harmonic *Harmonic; 55 struct _n_Harmonic { 56 KSP ksp; 57 Mat *A; 58 Vec v; 59 IS *is; 60 }; 61 62 PETSC_EXTERN PetscLogEvent PC_HPDDM_PtAP; 63 PETSC_EXTERN PetscLogEvent PC_HPDDM_PtBP; 64 PETSC_EXTERN PetscLogEvent PC_HPDDM_Next; 65 PETSC_INTERN PetscErrorCode HPDDMLoadDL_Private(PetscBool *); 66 PETSC_INTERN const char HPDDMCitation[]; 67 PETSC_INTERN PetscBool HPDDMCite; 68 #if PetscDefined(HAVE_CUDA) && PetscDefined(HAVE_HPDDM) 69 PETSC_INTERN PetscErrorCode KSPSolve_HPDDM_CUDA_Private(KSP_HPDDM *, const PetscScalar *, PetscScalar *, PetscInt, MPI_Comm); 70 #endif 71 72 #include <HPDDM.hpp> 73