[petsc-users] Inquiry about the setup for multigrid as a preconditioner in Petsc.

Xiaodong Liu xliu29 at ncsu.edu
Thu Mar 12 16:13:28 CDT 2020


Hi, all,

I am practising multigrid as a preconditioner in Petsc. From the previous
resource, there are 2 main ways to set up the multigrid preconditioner,

1). For general cae,
KSPCreate(MPI Comm comm,KSP *ksp);
KSPGetPC(KSP ksp,PC *pc);
PCSetType(PC pc,PCMG);
PCMGSetLevels(pc,int levels,MPI Comm *comms);
PCMGSetType(PC pc,PCMGType mode);
PCMGSetCycleType(PC pc,PCMGCycleType ctype);
...
PCMGSetInterpolation(PC pc,int level,Mat P);
PCMGSetRestriction(PC pc,int level,Mat R);

The above means that I need to specify a lot details, e.g., cycletype.
interpolation and restriction matrix, coarse solver, etc.

2) For the case of structured mesh, (DMDA is enough)
Taking the following case as an example,
https://www.mcs.anl.gov/petsc/petsc-3.6/src/ksp/ksp/examples/tutorials/ex25.c.html

 50:   KSPCreate(PETSC_COMM_WORLD,&ksp);
 51:   DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,-3,1,1,0,&da);
 52:   KSPSetDM(ksp,da);
 53:   KSPSetComputeRHS(ksp,ComputeRHS,&user);
 54:   KSPSetComputeOperators(ksp,ComputeMatrix,&user);
 55:   KSPSetFromOptions(ksp);
 56:   KSPSolve(ksp,NULL,NULL);

DMDA handles all the multigrid setting automatically, e.g., interpolation
and restriction matrix.
If my understanding is right, *my question is where to find these source
file to define these default interpolation and restriction matrix. *

Thanks,S
Xiaodong Liu, PhD
X: Computational Physics Division
Los Alamos National Laboratory
P.O. Box 1663,
Los Alamos, NM 87544
505-709-0534
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200312/b5c6869e/attachment.html>


More information about the petsc-users mailing list