# DMMGSetKSP

Sets the linear solver object that will use the grid hierarchy

### Synopsis

    #include "petscda.h"
    #include "petscksp.h"
    #include "petscmg.h"
    #include "petscdmmg.h"
    #include "petscpc.h"
    PetscErrorCode PETSCSNES_DLLEXPORT DMMGSetKSP(DMMG *dmmg,PetscErrorCode (*rhs)(DMMG,Vec),PetscErrorCode (*func)(DMMG,Mat,Mat))

Collective on DMMG

### Input Parameter

| dmmg | - the context
| func | - function to compute linear system matrix on each grid level
| rhs | - function to compute right hand side on each level (need only work on the finest grid if you do not use grid sequencing)

Notes: For linear problems my be called more than once, reevaluates the matrices if it is called more than once. Call DMMGSolve() directly several times to solve with the same matrix but different right hand sides.

### See Also

DMMGCreate(), DMMGDestroy, DMMGSetDM(), DMMGSolve(), DMMGSetMatType()

Level:advanced
Location: src/snes/utils/damg.c
Index of all DA routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex22.c.html
src/ksp/ksp/examples/tutorials/ex25.c.html
src/ksp/ksp/examples/tutorials/ex28.c.html
src/ksp/ksp/examples/tutorials/ex29.c.html
src/ksp/ksp/examples/tutorials/ex32.c.html
src/ksp/ksp/examples/tutorials/ex33.c.html
src/ksp/ksp/examples/tutorials/ex34.c.html
src/ksp/ksp/examples/tutorials/ex22f.F.html
src/snes/examples/tutorials/ex31.c.html