Date: 2013-07-02T14:47:32+00:00

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