xref: /petsc/src/ksp/pc/impls/telescope/telescope.h (revision 21e3ffae2f3b73c0bd738cf6d0a809700fc04bb0)
1 
2 #ifndef PETSCPC_TELESCOPE_H
3 #define PETSCPC_TELESCOPE_H
4 
5 /* Telescope */
6 typedef enum {
7   TELESCOPE_DEFAULT = 0,
8   TELESCOPE_DMDA,
9   TELESCOPE_DMPLEX,
10   TELESCOPE_COARSEDM
11 } PCTelescopeType;
12 
13 typedef struct _PC_Telescope *PC_Telescope;
14 struct _PC_Telescope {
15   PetscSubcomm     psubcomm;
16   PetscSubcommType subcommtype;
17   MPI_Comm         subcomm;
18   PetscInt         redfactor; /* factor to reduce comm size by */
19   KSP              ksp;
20   IS               isin;
21   VecScatter       scatter;
22   Vec              xred, yred, xtmp;
23   Mat              Bred;
24   PetscBool        ignore_dm, ignore_kspcomputeoperators, use_coarse_dm;
25   PCTelescopeType  sr_type;
26   void            *dm_ctx;
27   PetscErrorCode (*pctelescope_setup_type)(PC, PC_Telescope);
28   PetscErrorCode (*pctelescope_matcreate_type)(PC, PC_Telescope, MatReuse, Mat *);
29   PetscErrorCode (*pctelescope_matnullspacecreate_type)(PC, PC_Telescope, Mat);
30   PetscErrorCode (*pctelescope_reset_type)(PC);
31 };
32 
33 /* DMDA */
34 typedef struct {
35   DM        dmrepart;
36   Mat       permutation;
37   Vec       xp;
38   PetscInt  Mp_re, Np_re, Pp_re;
39   PetscInt *range_i_re, *range_j_re, *range_k_re;
40   PetscInt *start_i_re, *start_j_re, *start_k_re;
41 } PC_Telescope_DMDACtx;
42 
43 static inline PetscBool PetscSubcomm_isActiveRank(PetscSubcomm scomm)
44 {
45   if (scomm->color == 0) return (PETSC_TRUE);
46   else return (PETSC_FALSE);
47 }
48 
49 static inline PetscBool PCTelescope_isActiveRank(PC_Telescope sred)
50 {
51   if (sred->psubcomm) return (PetscSubcomm_isActiveRank(sred->psubcomm));
52   else {
53     if (sred->subcomm != MPI_COMM_NULL) return (PETSC_TRUE);
54     else return (PETSC_FALSE);
55   }
56 }
57 
58 PetscErrorCode PCTelescopeSetUp_dmda(PC, PC_Telescope);
59 PetscErrorCode PCTelescopeMatCreate_dmda(PC, PC_Telescope, MatReuse, Mat *);
60 PetscErrorCode PCTelescopeMatNullSpaceCreate_dmda(PC, PC_Telescope, Mat);
61 PetscErrorCode PCApply_Telescope_dmda(PC, Vec, Vec);
62 PetscErrorCode PCApplyRichardson_Telescope_dmda(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
63 PetscErrorCode PCReset_Telescope_dmda(PC);
64 PetscErrorCode PCTelescopeSetUp_CoarseDM(PC, PC_Telescope);
65 PetscErrorCode PCApply_Telescope_CoarseDM(PC, Vec, Vec);
66 PetscErrorCode PCTelescopeMatNullSpaceCreate_CoarseDM(PC, PC_Telescope, Mat);
67 PetscErrorCode PCReset_Telescope_CoarseDM(PC);
68 PetscErrorCode PCApplyRichardson_Telescope_CoarseDM(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *);
69 PetscErrorCode DMView_DA_Short(DM, PetscViewer);
70 
71 #endif
72