[petsc-users] PCMG and DMMG

Barry Smith bsmith at mcs.anl.gov
Mon Feb 9 11:09:16 CST 2015


  Looks like you are looking at a very old PETSc. You should be using version 3.5.3 and nothing earlier. DMMG has been gone from PETSc for a long time.

  Here is the easiest way to provide the information:  Loop over the levels yourself and provide the matrices, function pointers etc. See for example src/ksp/ksp/examples/tests/ex19.c This example only sets up MG for two levels but you can see the pattern from the code. It creates the matrix operator for each level and vectors, and sets it for the level,

  ierr = FormJacobian_Grid(&user,&user.coarse,&user.coarse.J);CHKERRQ(ierr);
  ierr = FormJacobian_Grid(&user,&user.fine,&user.fine.J);CHKERRQ(ierr);

  /* Create coarse level */
  ierr = PCMGGetCoarseSolve(pc,&user.ksp_coarse);CHKERRQ(ierr);
  ierr = KSPSetOptionsPrefix(user.ksp_coarse,"coarse_");CHKERRQ(ierr);
  ierr = KSPSetFromOptions(user.ksp_coarse);CHKERRQ(ierr);
  ierr = KSPSetOperators(user.ksp_coarse,user.coarse.J,user.coarse.J);CHKERRQ(ierr);
  ierr = PCMGSetX(pc,COARSE_LEVEL,user.coarse.x);CHKERRQ(ierr);
  ierr = PCMGSetRhs(pc,COARSE_LEVEL,user.coarse.b);CHKERRQ(ierr);

  /* Create fine level */
  ierr = PCMGGetSmoother(pc,FINE_LEVEL,&ksp_fine);CHKERRQ(ierr);
  ierr = KSPSetOptionsPrefix(ksp_fine,"fine_");CHKERRQ(ierr);
  ierr = KSPSetFromOptions(ksp_fine);CHKERRQ(ierr);
  ierr = KSPSetOperators(ksp_fine,user.fine.J,user.fine.J);CHKERRQ(ierr);
  ierr = PCMGSetR(pc,FINE_LEVEL,user.fine.r);CHKERRQ(ierr);

  and it creates the interpolation and sets it
  /* Create interpolation between the levels */
  ierr = DMCreateInterpolation(user.coarse.da,user.fine.da,&user.Ii,NULL);CHKERRQ(ierr);
  ierr = PCMGSetInterpolation(pc,FINE_LEVEL,user.Ii);CHKERRQ(ierr);
  ierr = PCMGSetRestriction(pc,FINE_LEVEL,user.Ii);CHKERRQ(ierr);

  Note that PETSc by default uses the transpose of the interpolation for the restriction so even though it looks strange to set the same operator for both PETSc automatically uses the transpose when needed.

  Barry


> On Feb 9, 2015, at 10:09 AM, DU Yongle <yongle.du at gmail.com> wrote:
> 
> Good morning, everyone:
> 
> I have an existing general CFD solver with multigrid implemented. All functions (initialization, restriction, prolong/interpolation, coarse/fine grids solver......) are working correctly. Now I am trying to rewrite it with PETSc. I found that the manual provides very little information about this and is difficult to follow. I found another lecture notes by Barry Smith on web, which is:
> http://www.mcs.anl.gov/petsc/documentation/tutorials/Columbia04/DDandMultigrid.pdf
> 
> However, it is still not clear the difference and connection between PCMG and DMMG. Some questions are:
> 
> 1. Should DMMG be used to initialize the coarse grids (and boundary conditions) before PCMG could be used? If not, how does PCMG know all information on coarse grids?
> 
> 2. Due to the customized boundary conditions, indices of the grids, boundary conditions, grid dimensions on each coarse grid levels are required for particular computations. How to extract these information in either DMMG or PCMG? I have not found a function for this purpose. I have set up all information myself, should I pass these information to the coarse grid levels to the coarse levels? How and again how to extract these information?
> 
> 3. I have the restriction, interpolation, coarse grid solver ... implemented. How could these be integrated with PETSc functions? It appears that some functions like PCMGGetSmoother/UP/Down, PCMGSetInterpolation .... should be used, but how? The online manual simply repeat the name, and provides no other information.
> 
> Thanks a lot.
> 
> 
> 
>  



More information about the petsc-users mailing list