[petsc-users] Can you provide a basic example of using PCMG for multigrid applications?

Li, Zhisong (lizs) lizs at mail.uc.edu
Mon May 16 01:36:57 CDT 2011


 Hi, Petsc Team,

In my knowledge of Petsc, the PCMG object is the main tool for general multigrid calculations, as DMMG only works for simple constant matrix and RHS.  But it's difficult to find any example code for using PCMG.  I checked out the petsc-user mail archive on this topic but still not find a good description on it.  I encounter similar errors in the practice as some previous question-raisers did.

Here is my simple code implementing the PCMG based on my understanding from the user manual and tutorial.  It is supposed to have multigrid of only two levels (finest and coarsest grid).  The error message indicates SEGV segmentation violation because of this part of code.  Anything wrong with this implementation?


  DAGetMatrix(da, MATAIJ, &M);

  KSPCreate(PETSC_COMM_WORLD, &ksp);
  KSPSetType(ksp, KSPGMRES);
  KSPGetPC(ksp, &pcmg);
  PCSetType(pcmg, PCMG);

  PCMGSetLevels(pcmg, 2, &PETSC_COMM_WORLD);
  PCMGSetType(pcmg, PC_MG_MULTIPLICATIVE);
  PCMGSetCycleType(pcmg, PC_MG_CYCLE_W);
  PCMGSetCyclesOnLevel(pcmg, 0, 1);
  PCMGSetCyclesOnLevel(pcmg, 1, 1);

  PCMGGetCoarseSolve(pcmg, &ksp);

  PCMGGetSmoother(pcmg, 0, &ksp);
  PCMGGetSmoother(pcmg, 1, &ksp);
  PCMGSetInterpolation(pcmg, 1, M);
  PCMGSetRestriction(pcmg, 1, M);

  PCMGSetResidual(pcmg, 0, PCMGDefaultResidual, M);
  PCMGSetResidual(pcmg, 1, PCMGDefaultResidual, M);


 The mandatory remaining PCMGSetRhs( ), PCMGSetX( ) and PCMGSetR( ) functions should be generated by Petsc automatically.

It is tough to learn some Petsc functions when no detailed example and few guidance is provided.  I wish you can add some tutorials codes on PCMG usage in the future version of Petsc.


Thank you very much.


Zhisong Li



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110516/07c10c38/attachment.htm>


More information about the petsc-users mailing list