Actual source code: petscfunc.h

  1: /* $Id: petscfunc.h,v 1.4 2001/09/07 20:13:00 bsmith Exp $ */
  2: #ifndef PETSCFUNC_H
  3: #define PETSCFUNC_H

 5:  #include petscksp.h

  7: /*..KSP monitoring routines..*/
  8: extern int KSPMonitorWriteConvHist(KSP ksp,int n,double rnorm,void* ctx);
  9: extern int KSPMonitorAmg(KSP ksp,int n,double rnorm,void* ctx);
 10: extern int KSPMonitorWriteResVecs(KSP ksp,int n,double rnorm,void* ctx);

 12: /*..KSP convergence criteria routines..*/
 13: typedef struct{
 14:     double BNRM2;
 15:     int    NUMNODES;
 16: }CONVHIST;

 18: extern int ConvhistCtxCreate(CONVHIST **convhist);
 19: extern int ConvhistCtxDestroy(CONVHIST *convhist);
 20: extern int MyConvTest(KSP ksp,int n, double rnorm, KSPConvergedReason *reason, 
 21:                       void* ctx);

 23: /*..Functions defined for block preconditioners..*/
 24: extern int ReorderSubmatrices(PC pc,int nsub,IS *row,IS *col,
 25:                               Mat *submat,void *dummy);
 26: extern int PrintSubMatrices(PC pc,int nsub,IS *row,IS *col,
 27:                             Mat *submat,void *dummy);
 28: extern int ViewSubMatrices(PC pc,int nsub,IS *row,IS *col,
 29:                            Mat *submat,void *dummy);
 30: extern int KSPMonitorWriteConvHistOnFem(KSP ksp,int n,double rnorm,void* ctx);

 32: /*..Viewing and printing matrices and vectors..*/
 33: extern int MyMatView(Mat mat,void *dummy);
 34: extern int PrintMatrix(Mat mat, char* path, char* base);
 35: extern int PrintVector(Vec vec, char* path, char* base);

 37: /*..From the MatCreateFcts collection..*/
 38: extern int MatMatMult(Mat Fact1, Mat Fact2, Mat* Prod);
 39: extern int MatSubstract(Mat Term1, Mat Term2, Mat* Diff);

 41: /*..Structure used in the interface to RAMG..*/
 42: typedef struct{
 43:     PetscTruth        arraysset; /* indicates the arrays have already been allocated
 44:                                     they will be deleted in the next setup call */
 45:     double            *A;
 46:     int               *IA;
 47:     int               *JA;
 48:     double            *U_APPROX;
 49:     double            *RHS;
 50:     int               *IG;
 51:     struct RAMG_PARAM *PARAM;
 52: } RamgShellPC;

 54: /*..interface to RAMG..*/
 55: extern int RamgShellPCCreate(RamgShellPC **shell);
 56: extern int RamgShellPCSetUp(RamgShellPC *shell, Mat pmat);
 57: extern int RamgShellPCApply(void *ctx, Vec r, Vec z);
 58: extern int RamgShellPCDestroy(RamgShellPC *shell);
 59: extern int RamgGetParam(Mat A,struct RAMG_PARAM *ramg_param);

 61: /*..Structure used in the interface to SAMG..*/
 62: typedef struct{
 63:     double *A;
 64:     int    *IA;
 65:     int    *JA;
 66:     struct SAMG_PARAM *PARAM;
 67:     int    LEVELS;           /* Number of levels created */
 68: } SamgShellPC;

 70: /*..Interface to SAMG..*/
 71: extern int SamgShellPCCreate(SamgShellPC **shell);
 72: extern int SamgShellPCSetUp(SamgShellPC *shell, Mat pmat);
 73: extern int SamgShellPCApply(void *ctx, Vec r, Vec z);
 74: extern int SamgShellPCDestroy(SamgShellPC *shell);
 75: extern int SamgGetParam(struct SAMG_PARAM *samg_param);

 77: /*..Multigrid structure for PETSc..*/

 79: /*....Maximum number of levels to be used in SAMG....*/
 80: #define MAX_LEVELS 25 

 82: typedef struct{
 83:   /*..Implementation notes
 84:     1 - The menber A is not stored on level 1 (the finest level in SAMG 
 85:         ordering) to avoid unnecessary memory useage. 
 86:   */
 87:   KSP ksp_pre;
 88:   KSP ksp_post;
 89:   Mat  A, B, C;
 90:   Mat  Interp;
 91:   Vec  x, b, upd_b, r, y, b_y, r_y;
 92:   int  size; /*..Number of variables on level..*/
 93:   /*  int  debug; */
 94: } GridCtx;

 96: /*..Level 2 routine to get coarser level matrices..*/
 97: extern int SamgGetCoarseMat(int level, int ia_shift, int ja_shift, 
 98:                             Mat* coarsemat, void* ctx);
 99: /*..Level 2 routine to get interpolation operators..*/
100: extern int SamgGetInterpolation(int level, int iw_shift, int jw_shift,
101:                                 Mat* interpolation, void* ctx) ;

103: /*..Parse SAMG hierarchy to PETSc..*/
104: extern int SamgGetGrid(int levels, int numnodes, int numnonzero, 
105:                        GridCtx* grid, void* ctx);
106: /*..Check parsing..*/
107: extern int SamgCheckGalerkin(int levels, Mat A, GridCtx* grid, 
108:                       void* ctx);

110: #endif//PETSCFUNC_H