[petsc-users] multigrid implementation problem

Nakib Haider Protik nprot048 at uottawa.ca
Sun Jun 10 17:08:11 CDT 2012


Thanks a million for the clarification.

> On Sun, Jun 10, 2012 at 4:54 PM, Nakib Haider Protik
> <nprot048 at uottawa.ca>wrote:
>
>> Sorry, I meant to refer to this:
>> http://lists.mcs.anl.gov/pipermail/petsc-users/2011-May/008793.html
>
>
> As I've said in every message, this rampantly overwrites local variables.
>
>> >   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);
>
> This overwrites ksp with the coarse solver.
>
>> >
>> >   PCMGGetSmoother(pcmg, 0, &ksp);
>
> This overwrites it again with the level 0 "smoother" (same as the coarse
> solver).
>
>> >   PCMGGetSmoother(pcmg, 1, &ksp);
>
> This overwrites it again with the level 1 smoother.
>
>> >   PCMGSetInterpolation(pcmg, 1, M);
>> >   PCMGSetRestriction(pcmg, 1, M);
>> >
>> >   PCMGSetResidual(pcmg, 0, PCMGDefaultResidual, M);
>> >   PCMGSetResidual(pcmg, 1, PCMGDefaultResidual, M);
>
> So if you get down here and use "ksp" for something (as your code did),
> your are actually working with the level 1 smoother. I also said this in
> my
> first email, explaining why the problem was solved this way (the smoother
> was as good as a direct solve). The original KSP has been lost forever and
> has leaked its memory.
>


-- 
Nakib :)


More information about the petsc-users mailing list