Actual source code: mgimpl.h

  1: /*
  2:       Data structure used for Multigrid preconditioner.
  3: */
  6: #include <private/pcimpl.h>
  7: #include <petscpcmg.h>
  8: #include <petscksp.h>

 10: /*
 11:      Each level has its own copy of this data.
 12:      Level (0) is always the coarsest level and Level (levels-1) is the finest.
 13: */
 14: typedef struct {
 15:   PetscInt       cycles;                       /* Type of cycle to run: 1 V 2 W */
 16:   PetscInt       level;                        /* level = 0 coarsest level */
 17:   PetscInt       levels;                       /* number of active levels used */
 18:   Vec            b;                            /* Right hand side */
 19:   Vec            x;                            /* Solution */
 20:   Vec            r;                            /* Residual */
 21:   PetscErrorCode (*residual)(Mat,Vec,Vec,Vec);
 22:   Mat            A;                            /* matrix used in forming residual*/
 23:   KSP            smoothd;                      /* pre smoother */
 24:   KSP            smoothu;                      /* post smoother */
 25:   Mat            interpolate;
 26:   Mat            restrct;                      /* restrict is a reserved word in C99 and on Cray */
 27:   Vec            rscale;                       /* scaling of restriction matrix */
 28:   PetscLogEvent  eventsmoothsetup;             /* if logging times for each level */
 29:   PetscLogEvent  eventsmoothsolve;
 30:   PetscLogEvent  eventresidual;
 31:   PetscLogEvent  eventinterprestrict;
 32: } PC_MG_Levels;

 34: /*
 35:     This data structure is shared by all the levels.
 36: */
 37: typedef struct {
 38:   PCMGType      am;                           /* Multiplicative, additive or full */
 39:   PetscInt      cyclesperpcapply;             /* Number of cycles to use in each PCApply(), multiplicative only*/
 40:   PetscInt      maxlevels;                    /* total number of levels allocated */
 41:   PetscInt      galerkin;                     /* use Galerkin process to compute coarser matrices, 0=no, 1=yes, 2=yes but computed externally */
 42:   PetscBool     usedmfornumberoflevels;       /* sets the number of levels by getting this information out of the DM */

 44:   PetscInt      nlevels;
 45:   PC_MG_Levels  **levels;
 46:   PetscInt      default_smoothu;              /* number of smooths per level if not over-ridden */
 47:   PetscInt      default_smoothd;              /*  with calls to KSPSetTolerances() */
 48:   PetscReal     rtol,abstol,dtol,ttol;        /* tolerances for when running with PCApplyRichardson_MG */

 50:   void          *innerctx;                   /* optional data for preconditioner, like PCEXOTIC that inherits off of PCMG */
 51: } PC_MG;


 58: #endif