Actual source code: petschpddm.h

  1: #ifndef PETSCHPDDM_H
  2: #define PETSCHPDDM_H

  4: #include <petsc/private/kspimpl.h>

  6: #define PETSC_KSPHPDDM_DEFAULT_PRECISION \
  7:   (PetscDefined(USE_REAL_SINGLE) ? KSP_HPDDM_PRECISION_SINGLE : (PetscDefined(USE_REAL_DOUBLE) ? KSP_HPDDM_PRECISION_DOUBLE : (PetscDefined(USE_REAL___FLOAT128) ? KSP_HPDDM_PRECISION_QUADRUPLE : KSP_HPDDM_PRECISION_HALF)))
  8: #define PETSC_PCHPDDM_MAXLEVELS 9

 10: namespace HPDDM
 11: {
 12: template <class>
 13: class Schwarz; /* forward definitions of two needed HPDDM classes */
 14: class PETScOperator;
 15: } // namespace HPDDM

 17: struct PC_HPDDM_Level {
 18:   VecScatter                   scatter;   /* scattering from PETSc nonoverlapping numbering to HPDDM overlapping */
 19:   Vec                         *v[2];      /* working vectors */
 20:   Mat                          V[3];      /* working matrices */
 21:   KSP                          ksp;       /* KSP coupling the action of pc and P */
 22:   PC                           pc;        /* inner fine-level PC, acting like a multigrid smoother */
 23:   HPDDM::Schwarz<PetscScalar> *P;         /* coarse-level HPDDM solver */
 24:   Vec                          D;         /* partition of unity */
 25:   PetscReal                    threshold; /* threshold for selecting local deflation vectors */
 26:   PetscInt                     nu;        /* number of local deflation vectors */
 27:   const struct PC_HPDDM       *parent;    /* parent PC */
 28: };

 30: struct PC_HPDDM {
 31:   PC_HPDDM_Level            **levels;                                       /* array of shells */
 32:   Mat                         aux;                                          /* local auxiliary matrix defined at the finest level on PETSC_COMM_SELF */
 33:   Mat                         B;                                            /* right-hand side matrix defined at the finest level on PETSC_COMM_SELF */
 34:   Vec                         normal;                                       /* temporary Vec when preconditioning the normal equations with KSPLSQR */
 35:   IS                          is;                                           /* global numbering of the auxiliary matrix */
 36:   PetscInt                    N;                                            /* number of levels */
 37:   PCHPDDMCoarseCorrectionType correction;                                   /* type of coarse correction */
 38:   PetscBool3                  Neumann;                                      /* aux is the local Neumann matrix? */
 39:   PetscBool                   log_separate;                                 /* separate events for each level? */
 40:   PetscBool                   share;                                        /* shared subdomain KSP between SLEPc and PETSc? */
 41:   PetscBool                   deflation;                                    /* aux is the local deflation space? */
 42:   PetscErrorCode (*setup)(Mat, PetscReal, Vec, Vec, PetscReal, IS, void *); /* setup function for the auxiliary matrix */
 43:   void *setup_ctx;                                                          /* context for setup */
 44: };

 46: struct KSP_HPDDM {
 47:   HPDDM::PETScOperator *op;
 48:   PetscReal             rcntl[1];
 49:   int                   icntl[2];
 50:   unsigned short        scntl[2];
 51:   char                  cntl[5];
 52:   KSPHPDDMPrecision     precision;
 53: };

 55: PETSC_EXTERN PetscLogEvent  PC_HPDDM_PtAP;
 56: PETSC_EXTERN PetscLogEvent  PC_HPDDM_PtBP;
 57: PETSC_EXTERN PetscLogEvent  PC_HPDDM_Next;
 58: PETSC_INTERN PetscErrorCode HPDDMLoadDL_Private(PetscBool *);
 59: PETSC_INTERN const char     HPDDMCitation[];
 60: PETSC_INTERN PetscBool      HPDDMCite;
 61: #if PetscDefined(HAVE_CUDA) && PetscDefined(HAVE_HPDDM)
 62: PETSC_INTERN PetscErrorCode KSPSolve_HPDDM_CUDA_Private(KSP_HPDDM *, const PetscScalar *, PetscScalar *, PetscInt, MPI_Comm);
 63: #endif

 65: #include <HPDDM.hpp>

 67: #endif /* PETSCHPDDM_H */