1: /*
2: Data structure used for Multigrid preconditioner.
3: */
6: #include private/pcimpl.h
7: #include petscmg.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: PetscTruth galerkin; /* use Galerkin process to compute coarser matrices */
19: PetscTruth galerkinused; /* destroy the Mat created by the Galerkin process */
20: Vec b; /* Right hand side */
21: Vec x; /* Solution */
22: Vec r; /* Residual */
23: PetscErrorCode (*residual)(Mat,Vec,Vec,Vec);
24: Mat A; /* matrix used in forming residual*/
25: KSP smoothd; /* pre smoother */
26: KSP smoothu; /* post smoother */
27: Mat interpolate;
28: Mat restrct; /* restrict is a reserved word on the Cray!!!*/
29: } PC_MG_Levels;
31: /*
32: This data structure is shared by all the levels.
33: */
34: typedef struct {
35: PCMGType am; /* Multiplicative, additive or full */
36: PetscInt cyclesperpcapply; /* Number of cycles to use in each PCApply(), multiplicative only*/
37: PetscInt maxlevels; /* total number of levels allocated */
39: PetscInt nlevels;
40: PC_MG_Levels **levels;
41: PetscInt default_smoothu; /* number of smooths per level if not over-ridden */
42: PetscInt default_smoothd; /* with calls to KSPSetTolerances() */
43: PetscReal rtol,abstol,dtol,ttol; /* tolerances for when running with PCApplyRichardson_MG */
44: PetscLogEvent eventsmoothsetup; /* if logging times for each level */
45: PetscLogEvent eventsmoothsolve;
46: PetscLogEvent eventresidual;
47: PetscLogEvent eventinterprestrict;
48: void *innerctx; /* optional data for preconditioner, like PCEXOTIC that inherits off of PCMG */
49: } PC_MG;
56: #endif