1 #if !defined(__GAMG_IMPL) 2 #define __GAMG_IMPL 3 #include <private/pcimpl.h> /*I "petscpc.h" I*/ 4 #include <../src/ksp/pc/impls/mg/mgimpl.h> /*I "petscpcmg.h" I*/ 5 #include <../src/mat/impls/aij/seq/aij.h> 6 #include <../src/mat/impls/aij/mpi/mpiaij.h> 7 #include <assert.h> 8 9 /* Private context for the GAMG preconditioner */ 10 typedef struct gamg_TAG{ 11 PetscInt Nlevels; 12 PetscInt setup_count; 13 PetscBool repart; 14 PetscInt min_eq_proc; 15 PetscInt coarse_eq_limit; 16 PetscReal threshold; /* common quatity to many AMG methods so keep it up here */ 17 PetscInt verbose; 18 PetscInt emax_id; 19 PetscInt col_bs_id; 20 PetscInt data_sz; /* these 4 things are all related to the method data and should be in the subctx */ 21 PetscInt data_rows; 22 PetscInt data_cols; 23 PetscReal *data; /* blocked vector of vertex data on fine grid (coordinates) */ 24 PetscErrorCode (*createprolongator)( PC, const Mat A, const PetscReal [], Mat *P, PetscReal** ); 25 PetscErrorCode (*createdefaultdata)( PC ); 26 27 void *subctx; 28 } PC_GAMG; 29 30 #define PCGAMGType char* 31 32 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 33 # define PCGAMGRegisterDynamic(a,b,c,d) PCGAMGRegister(a,b,c,0) 34 #else 35 # define PCGAMGRegisterDynamic(a,b,c,d) PCGAMGRegister(a,b,c,d) 36 #endif 37 38 PetscErrorCode PCGAMGRegister(const char *implname,const char *path,const char *fname,PetscErrorCode (*cfunc)(PC)); 39 40 PetscErrorCode PCGAMGSetType( PC,const PCGAMGType ); 41 42 #define GAMGAGG "agg" 43 #define GAMGGEO "geo" 44 45 /* Private context for the GAMG preconditioner */ 46 typedef struct{ 47 PetscInt lid; /* local vertex index */ 48 PetscInt degree; /* vertex degree */ 49 } GAMGNode; 50 51 PetscErrorCode PCSetFromOptions_MG(PC); 52 PetscErrorCode PCReset_MG(PC); 53 54 /* hooks create derivied classes */ 55 PetscErrorCode PCCreateGAMG_GEO( PC pc ); 56 PetscErrorCode PCCreateGAMG_AGG( PC pc ); 57 58 PetscErrorCode PCSetFromOptions_GAMG( PC pc ); 59 PetscErrorCode PCDestroy_GAMG(PC pc); 60 61 PetscErrorCode PCGAMGcreateProl_AGG( PC, const Mat, const PetscReal [], Mat *, PetscReal **); 62 PetscErrorCode PCGAMGcreateProl_GEO( PC, const Mat, const PetscReal [], Mat *, PetscReal **); 63 /* helper methods */ 64 PetscErrorCode getDataWithGhosts( const Mat a_Gmat, const PetscInt a_data_sz, const PetscReal a_data_in[], 65 PetscInt *a_stride, PetscReal **a_data_out ); 66 PetscErrorCode maxIndSetAgg( const IS a_perm, const Mat a_Gmat, const Mat a_Auxmat, 67 const PetscBool a_strict_aggs, IS *a_selected, IS *a_locals_llist ); 68 PetscErrorCode createGraph(PC a_pc, const Mat a_Amat, Mat *, Mat *, IS * ); 69 70 #if defined PETSC_USE_LOG 71 enum tag {SET1,SET2,GRAPH,GRAPH_MAT,GRAPH_FILTER,GRAPH_SQR,SET4,SET5,SET6,FIND_V,SET7,SET8,SET9,SET10,SET11,SET12,SET13,SET14,SET15,SET16,NUM_SET}; 72 extern PetscLogEvent gamg_setup_events[NUM_SET]; 73 #endif 74 75 #endif 76 77