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 if (scomm->color == 0) return (PETSC_TRUE); 45 else return (PETSC_FALSE); 46 } 47 48 static inline PetscBool PCTelescope_isActiveRank(PC_Telescope sred) { 49 if (sred->psubcomm) return (PetscSubcomm_isActiveRank(sred->psubcomm)); 50 else { 51 if (sred->subcomm != MPI_COMM_NULL) return (PETSC_TRUE); 52 else return (PETSC_FALSE); 53 } 54 } 55 56 PetscErrorCode PCTelescopeSetUp_dmda(PC, PC_Telescope); 57 PetscErrorCode PCTelescopeMatCreate_dmda(PC, PC_Telescope, MatReuse, Mat *); 58 PetscErrorCode PCTelescopeMatNullSpaceCreate_dmda(PC, PC_Telescope, Mat); 59 PetscErrorCode PCApply_Telescope_dmda(PC, Vec, Vec); 60 PetscErrorCode PCApplyRichardson_Telescope_dmda(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *); 61 PetscErrorCode PCReset_Telescope_dmda(PC); 62 PetscErrorCode PCTelescopeSetUp_CoarseDM(PC, PC_Telescope); 63 PetscErrorCode PCApply_Telescope_CoarseDM(PC, Vec, Vec); 64 PetscErrorCode PCTelescopeMatNullSpaceCreate_CoarseDM(PC, PC_Telescope, Mat); 65 PetscErrorCode PCReset_Telescope_CoarseDM(PC); 66 PetscErrorCode PCApplyRichardson_Telescope_CoarseDM(PC, Vec, Vec, Vec, PetscReal, PetscReal, PetscReal, PetscInt, PetscBool, PetscInt *, PCRichardsonConvergedReason *); 67 PetscErrorCode DMView_DA_Short(DM, PetscViewer); 68 69 #endif 70