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; /* stashing places */ 19 PetscInt col_bs_id; 20 /* these 4 are all related to the method data and should be in the subctx */ 21 PetscInt data_sz; /* nloc*data_rows*data_cols */ 22 PetscInt data_cell_rows; 23 PetscInt data_cell_cols; 24 PetscReal *data; /* [data_sz] blocked vector of vertex data on fine grid (coordinates/nullspace) */ 25 PetscErrorCode (*graph)( PC, const Mat, Mat * ); 26 PetscErrorCode (*coarsen)( PC, const Mat, IS*, IS* ); 27 PetscErrorCode (*prolongator)( PC, const Mat, const Mat, IS, IS, Mat* ); 28 PetscErrorCode (*optprol)( PC, const Mat, Mat* ); 29 30 PetscErrorCode (*createdefaultdata)( PC ); /* for data methods that have a default (SA) */ 31 void *subctx; 32 } PC_GAMG; 33 34 /* #if defined(PETSC_USE_DYNAMIC_LIBRARIES) */ 35 /* # define PCGAMGRegisterDynamic(a,b,c,d) PCGAMGRegister(a,b,c,0) */ 36 /* #else */ 37 /* # define PCGAMGRegisterDynamic(a,b,c,d) PCGAMGRegister(a,b,c,d) */ 38 /* #endif */ 39 /* PetscErrorCode PCGAMGRegister(const char *implname,const char *path,const char *fname,PetscErrorCode (*cfunc)(PC)); */ 40 41 #define GAMGAGG "agg" 42 #define GAMGGEO "geo" 43 44 PetscErrorCode PCSetFromOptions_MG( PC ); 45 PetscErrorCode PCReset_MG( PC ); 46 47 /* hooks create derivied classes */ 48 PetscErrorCode PCCreateGAMG_GEO( PC pc ); 49 PetscErrorCode PCCreateGAMG_AGG( PC pc ); 50 51 PetscErrorCode PCSetFromOptions_GAMG( PC pc ); 52 PetscErrorCode PCDestroy_GAMG(PC pc); 53 54 /* helper methods */ 55 PetscErrorCode createSimpleGraph( const Mat, Mat * ); 56 PetscErrorCode scaleFilterGraph( Mat *, const PetscReal, const PetscBool, const PetscInt ); 57 PetscErrorCode getDataWithGhosts( const Mat a_Gmat, const PetscInt a_data_sz, const PetscReal a_data_in[], 58 PetscInt *a_stride, PetscReal **a_data_out ); 59 PetscErrorCode maxIndSetAgg( const IS, const Mat, const PetscBool, const PetscInt, IS *a_selected, IS *a_locals_llist ); 60 61 #if defined PETSC_USE_LOG 62 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}; 63 extern PetscLogEvent gamg_setup_events[NUM_SET]; 64 #endif 65 66 #endif 67 68