1 #if !defined(__GAMG_IMPL) 2 #define __GAMG_IMPL 3 #include <petsc-private/pcimpl.h> 4 #include <../src/ksp/pc/impls/mg/mgimpl.h> /*I "petscksp.h" I*/ 5 #include <../src/mat/impls/aij/seq/aij.h> 6 #include <../src/mat/impls/aij/mpi/mpiaij.h> 7 8 /* Private context for the GAMG preconditioner */ 9 typedef struct gamg_TAG { 10 PetscInt Nlevels; 11 PetscInt setup_count; 12 PetscBool repart; 13 PetscBool reuse_prol; 14 PetscBool use_aggs_in_gasm; 15 PetscInt min_eq_proc; 16 PetscInt coarse_eq_limit; 17 PetscReal threshold; /* common quatity to many AMG methods so keep it up here */ 18 PetscInt verbose; 19 PetscInt emax_id; /* stashing places */ 20 21 /* these 4 are all related to the method data and should be in the subctx */ 22 PetscInt data_sz; /* nloc*data_rows*data_cols */ 23 PetscInt data_cell_rows; 24 PetscInt data_cell_cols; 25 PetscInt orig_data_cell_rows; 26 PetscInt orig_data_cell_cols; 27 PetscReal eigtarget[2]; 28 PetscReal *data; /* [data_sz] blocked vector of vertex data on fine grid (coordinates/nullspace) */ 29 PetscReal *orig_data; /* cache data */ 30 31 PetscErrorCode (*graph)(PC, const Mat, Mat*); 32 PetscErrorCode (*coarsen)(PC, Mat*, PetscCoarsenData**); 33 PetscErrorCode (*prolongator)(PC, const Mat, const Mat, PetscCoarsenData*, Mat*); 34 PetscErrorCode (*optprol)(PC, const Mat, Mat*); 35 PetscErrorCode (*formkktprol)(PC, const Mat, const Mat, Mat*); 36 PetscErrorCode (*createdefaultdata)(PC, Mat); /* for data methods that have a default (SA) */ 37 38 void *subctx; 39 } PC_GAMG; 40 41 PetscErrorCode PCSetFromOptions_MG(PC); 42 PetscErrorCode PCReset_MG(PC); 43 44 /* hooks create derivied classes */ 45 PetscErrorCode PCCreateGAMG_GEO(PC pc); 46 PetscErrorCode PCCreateGAMG_AGG(PC pc); 47 48 PetscErrorCode PCSetFromOptions_GAMG(PC pc); 49 PetscErrorCode PCDestroy_GAMG(PC pc); 50 51 /* helper methods */ 52 PetscErrorCode PCGAMGCreateGraph(const Mat, Mat*); 53 PetscErrorCode PCGAMGFilterGraph(Mat*, const PetscReal, const PetscBool, const PetscInt); 54 PetscErrorCode PCGAMGGetDataWithGhosts(const Mat a_Gmat, const PetscInt a_data_sz, const PetscReal a_data_in[],PetscInt *a_stride, PetscReal **a_data_out); 55 56 #if defined PETSC_USE_LOG 57 /* #define PETSC_GAMG_USE_LOG */ 58 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}; 59 #if defined PETSC_GAMG_USE_LOG 60 PETSC_INTERN PetscLogEvent petsc_gamg_setup_events[NUM_SET]; 61 #endif 62 PETSC_INTERN PetscLogEvent PC_GAMGGgraph_AGG; 63 PETSC_INTERN PetscLogEvent PC_GAMGGgraph_GEO; 64 PETSC_INTERN PetscLogEvent PC_GAMGCoarsen_AGG; 65 PETSC_INTERN PetscLogEvent PC_GAMGCoarsen_GEO; 66 PETSC_INTERN PetscLogEvent PC_GAMGProlongator_AGG; 67 PETSC_INTERN PetscLogEvent PC_GAMGProlongator_GEO; 68 PETSC_INTERN PetscLogEvent PC_GAMGOptprol_AGG; 69 PETSC_INTERN PetscLogEvent PC_GAMGKKTProl_AGG; 70 #endif 71 72 typedef struct _GAMGHashTable { 73 PetscInt *table; 74 PetscInt *data; 75 PetscInt size; 76 } GAMGHashTable; 77 78 PETSC_EXTERN PetscErrorCode GAMGTableCreate(PetscInt a_size, GAMGHashTable *a_tab); 79 PETSC_EXTERN PetscErrorCode GAMGTableDestroy(GAMGHashTable*); 80 PETSC_EXTERN PetscErrorCode GAMGTableAdd(GAMGHashTable *a_tab, PetscInt a_key, PetscInt a_data); 81 PETSC_EXTERN PetscErrorCode GAMGTableFind(GAMGHashTable *a_tab, PetscInt a_key, PetscInt *a_data); 82 83 #endif 84 85