xref: /petsc/src/ksp/pc/impls/telescope/telescope.h (revision d71ae5a4db6382e7f06317b8d368875286fe9008)
11e07b27eSBarry Smith 
226bd1501SBarry Smith #ifndef PETSCPC_TELESCOPE_H
326bd1501SBarry Smith #define PETSCPC_TELESCOPE_H
41e07b27eSBarry Smith 
51e07b27eSBarry Smith /* Telescope */
69371c9d4SSatish Balay typedef enum {
79371c9d4SSatish Balay   TELESCOPE_DEFAULT = 0,
89371c9d4SSatish Balay   TELESCOPE_DMDA,
99371c9d4SSatish Balay   TELESCOPE_DMPLEX,
109371c9d4SSatish Balay   TELESCOPE_COARSEDM
119371c9d4SSatish 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*d71ae5a4SJacob Faibussowitsch static inline PetscBool PetscSubcomm_isActiveRank(PetscSubcomm scomm)
44*d71ae5a4SJacob Faibussowitsch {
4557f12427SDave May   if (scomm->color == 0) return (PETSC_TRUE);
4657f12427SDave May   else return (PETSC_FALSE);
4757f12427SDave May }
481e07b27eSBarry Smith 
49*d71ae5a4SJacob Faibussowitsch static inline PetscBool PCTelescope_isActiveRank(PC_Telescope sred)
50*d71ae5a4SJacob Faibussowitsch {
5157f12427SDave May   if (sred->psubcomm) return (PetscSubcomm_isActiveRank(sred->psubcomm));
5257f12427SDave May   else {
5357f12427SDave May     if (sred->subcomm != MPI_COMM_NULL) return (PETSC_TRUE);
5457f12427SDave May     else return (PETSC_FALSE);
5557f12427SDave May   }
5657f12427SDave May }
571e07b27eSBarry Smith 
581e07b27eSBarry Smith PetscErrorCode PCTelescopeSetUp_dmda(PC, PC_Telescope);
591e07b27eSBarry Smith PetscErrorCode PCTelescopeMatCreate_dmda(PC, PC_Telescope, MatReuse, Mat *);
60392968a1SPatrick Sanan PetscErrorCode PCTelescopeMatNullSpaceCreate_dmda(PC, PC_Telescope, Mat);
611e07b27eSBarry Smith PetscErrorCode PCApply_Telescope_dmda(PC, Vec, Vec);
628d9f7141SDave May PetscErrorCode PCApplyRichardson_Telescope_dmda(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
631e07b27eSBarry Smith PetscErrorCode PCReset_Telescope_dmda(PC);
648d9f7141SDave May PetscErrorCode PCTelescopeSetUp_CoarseDM(PC, PC_Telescope);
658d9f7141SDave May PetscErrorCode PCApply_Telescope_CoarseDM(PC, Vec, Vec);
668d9f7141SDave May PetscErrorCode PCTelescopeMatNullSpaceCreate_CoarseDM(PC, PC_Telescope, Mat);
678d9f7141SDave May PetscErrorCode PCReset_Telescope_CoarseDM(PC);
688d9f7141SDave May PetscErrorCode PCApplyRichardson_Telescope_CoarseDM(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
698ef9ca65SPatrick Sanan PetscErrorCode DMView_DA_Short(DM, PetscViewer);
701e07b27eSBarry Smith 
711e07b27eSBarry Smith #endif
72