Actual source code: petschpddm.h

  1: #pragma once

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

  5: #define PETSC_PCHPDDM_MAXLEVELS 9

  7: #define PETSC_KSPHPDDM_DEFAULT_PRECISION PETSC_DEPRECATED_MACRO(3, 25, 0, "PETSC_SCALAR_PRECISION", ) PETSC_SCALAR_PRECISION

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

 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: };

 29: struct PC_HPDDM {
 30:   PC_HPDDM_Level            **levels;                                       /* array of shells */
 31:   Mat                         aux;                                          /* local auxiliary matrix, or deflation matrix if the PetscBool deflation is PETSC_TRUE, 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:   Vec                         scaling;                                      /* user-supplied scaling in the ordering of the IS is, defined at the finest level on PETSC_COMM_SELF */
 35:   IS                          is;                                           /* global numbering of the rows of the Mat aux and of the entries of the Vec scaling */
 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:   PetscPrecision        precision;
 53: };

 55: typedef struct _n_Harmonic *Harmonic;
 56: struct _n_Harmonic {
 57:   KSP  ksp;
 58:   Mat *A;
 59:   Vec  v;
 60:   IS  *is;
 61: };

 63: PETSC_EXTERN PetscLogEvent  PC_HPDDM_PtAP;
 64: PETSC_EXTERN PetscLogEvent  PC_HPDDM_PtBP;
 65: PETSC_EXTERN PetscLogEvent  PC_HPDDM_Next;
 66: PETSC_INTERN PetscErrorCode HPDDMLoadDL_Private(PetscBool *);
 67: PETSC_INTERN const char     HPDDMCitation[];
 68: PETSC_INTERN PetscBool      HPDDMCite;
 69: #if PetscDefined(HAVE_CUDA) && PetscDefined(HAVE_HPDDM)
 70: PETSC_INTERN PetscErrorCode KSPSolve_HPDDM_CUDA_Private(KSP_HPDDM *, const PetscScalar *, PetscScalar *, PetscInt, MPI_Comm);
 71: #endif

 73: #include <HPDDM.hpp>