xref: /petsc/src/ksp/pc/impls/telescope/telescope.h (revision 9371c9d470a9602b6d10a8bf50c9b2280a79e45a)
11e07b27eSBarry Smith 
226bd1501SBarry Smith #ifndef PETSCPC_TELESCOPE_H
326bd1501SBarry Smith #define PETSCPC_TELESCOPE_H
41e07b27eSBarry Smith 
51e07b27eSBarry Smith /* Telescope */
6*9371c9d4SSatish Balay typedef enum {
7*9371c9d4SSatish Balay   TELESCOPE_DEFAULT = 0,
8*9371c9d4SSatish Balay   TELESCOPE_DMDA,
9*9371c9d4SSatish Balay   TELESCOPE_DMPLEX,
10*9371c9d4SSatish Balay   TELESCOPE_COARSEDM
11*9371c9d4SSatish Balay } PCTelescopeType;
121e07b27eSBarry Smith 
131e07b27eSBarry Smith typedef struct _PC_Telescope *PC_Telescope;
141e07b27eSBarry Smith struct _PC_Telescope {
151e07b27eSBarry Smith   PetscSubcomm     psubcomm;
1648a10b22SPatrick Sanan   PetscSubcommType subcommtype;
172a22aa42SDave May   MPI_Comm         subcomm;
181e07b27eSBarry Smith   PetscInt         redfactor; /* factor to reduce comm size by */
191e07b27eSBarry Smith   KSP              ksp;
201e07b27eSBarry Smith   IS               isin;
211e07b27eSBarry Smith   VecScatter       scatter;
221e07b27eSBarry Smith   Vec              xred, yred, xtmp;
231e07b27eSBarry Smith   Mat              Bred;
248d9f7141SDave May   PetscBool        ignore_dm, ignore_kspcomputeoperators, use_coarse_dm;
251e07b27eSBarry Smith   PCTelescopeType  sr_type;
261e07b27eSBarry Smith   void            *dm_ctx;
271e07b27eSBarry Smith   PetscErrorCode (*pctelescope_setup_type)(PC, PC_Telescope);
281e07b27eSBarry Smith   PetscErrorCode (*pctelescope_matcreate_type)(PC, PC_Telescope, MatReuse, Mat *);
29392968a1SPatrick Sanan   PetscErrorCode (*pctelescope_matnullspacecreate_type)(PC, PC_Telescope, Mat);
301e07b27eSBarry Smith   PetscErrorCode (*pctelescope_reset_type)(PC);
31e3acf2f7SBarry Smith };
321e07b27eSBarry Smith 
331e07b27eSBarry Smith /* DMDA */
341e07b27eSBarry Smith typedef struct {
351e07b27eSBarry Smith   DM        dmrepart;
361e07b27eSBarry Smith   Mat       permutation;
371e07b27eSBarry Smith   Vec       xp;
381e07b27eSBarry Smith   PetscInt  Mp_re, Np_re, Pp_re;
391e07b27eSBarry Smith   PetscInt *range_i_re, *range_j_re, *range_k_re;
401e07b27eSBarry Smith   PetscInt *start_i_re, *start_j_re, *start_k_re;
411e07b27eSBarry Smith } PC_Telescope_DMDACtx;
421e07b27eSBarry Smith 
43*9371c9d4SSatish Balay static inline PetscBool PetscSubcomm_isActiveRank(PetscSubcomm scomm) {
4457f12427SDave May   if (scomm->color == 0) return (PETSC_TRUE);
4557f12427SDave May   else return (PETSC_FALSE);
4657f12427SDave May }
471e07b27eSBarry Smith 
48*9371c9d4SSatish Balay static inline PetscBool PCTelescope_isActiveRank(PC_Telescope sred) {
4957f12427SDave May   if (sred->psubcomm) return (PetscSubcomm_isActiveRank(sred->psubcomm));
5057f12427SDave May   else {
5157f12427SDave May     if (sred->subcomm != MPI_COMM_NULL) return (PETSC_TRUE);
5257f12427SDave May     else return (PETSC_FALSE);
5357f12427SDave May   }
5457f12427SDave May }
551e07b27eSBarry Smith 
561e07b27eSBarry Smith PetscErrorCode PCTelescopeSetUp_dmda(PC, PC_Telescope);
571e07b27eSBarry Smith PetscErrorCode PCTelescopeMatCreate_dmda(PC, PC_Telescope, MatReuse, Mat *);
58392968a1SPatrick Sanan PetscErrorCode PCTelescopeMatNullSpaceCreate_dmda(PC, PC_Telescope, Mat);
591e07b27eSBarry Smith PetscErrorCode PCApply_Telescope_dmda(PC, Vec, Vec);
608d9f7141SDave May PetscErrorCode PCApplyRichardson_Telescope_dmda(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
611e07b27eSBarry Smith PetscErrorCode PCReset_Telescope_dmda(PC);
628d9f7141SDave May PetscErrorCode PCTelescopeSetUp_CoarseDM(PC, PC_Telescope);
638d9f7141SDave May PetscErrorCode PCApply_Telescope_CoarseDM(PC, Vec, Vec);
648d9f7141SDave May PetscErrorCode PCTelescopeMatNullSpaceCreate_CoarseDM(PC, PC_Telescope, Mat);
658d9f7141SDave May PetscErrorCode PCReset_Telescope_CoarseDM(PC);
668d9f7141SDave May PetscErrorCode PCApplyRichardson_Telescope_CoarseDM(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
678ef9ca65SPatrick Sanan PetscErrorCode DMView_DA_Short(DM, PetscViewer);
681e07b27eSBarry Smith 
691e07b27eSBarry Smith #endif
70