[petsc-users] interpolation function in multigrid

Barry Smith bsmith at mcs.anl.gov
Tue Sep 11 18:43:50 CDT 2012


On Sep 11, 2012, at 5:11 PM, coco at dmi.unict.it wrote:

> Dear all,
> 
> I am using the multigrid as preconditioner, and I got in a trouble with the interpolation function. In practice, I defined a user interpolation function:
> 
> PetscErrorCode UserMultAddInterpolation(Mat mat,Vec x,Vec v2, Vec y);
> 
> and I noticed that the vectors v2 and y are zero in input, while I am expected that they are the solution computed in the smooth down process at the same level. In detail, given the following source code of the petsc file mg.c :
> 
> ierr = KSPSolve(mglevels->smoothd,mglevels->b,mglevels->x);CHKERRQ(ierr);  /* pre-smooth */
> [...]
>    while (cycles--) {
>      ierr = PCMGMCycle_Private(pc,mglevelsin-1,reason);CHKERRQ(ierr);
>    }
> [...]
>    ierr = MatInterpolateAdd(mglevels->interpolate,mgc->x,mglevels->x,mglevels->x);CHKERRQ(ierr);
> 
> I observed that mglevels->x is a vector which contains the correct values after the KSPSolve calling for the pre-smooth step, but it is a zero vector when given in input to the MatInterpolateAdd routine.
> I would like to debug the mg.c code, for instance accessing the single values of the vector mglevels->x and figuring out where they are zeroed out between the KSPSolve and MatInterpolateAdd callings. Would you have some suggestion for this debugging?

   You can call VecView(mglevels->x,0) directly in the debugger (for a small problem) I would start by simply calling it right after the KSPSolve() then right before the MatInterpolateAdd() if the second is zero but the first ok then run with two levels and break in the inner PCMGMCycle_Private() and print the same thing there (remember the value of mglevels changes.

   Good luck,

   Barry

> 
> Thank you for the collaboration.
> Best regards,
> Armando
> 



More information about the petsc-users mailing list