On Sun, Jun 10, 2012 at 3:49 PM, Nakib Haider Protik <nprot048 at uottawa.ca>wrote:
> Thank you very much for the reply. Here's a change that works for the 2D > case: > > ////////////////////MG Solver Stuff//////////////////// > KSPCreate(PETSC_COMM_WORLD, &ksp); > KSPSetType(ksp, KSPGMRES); > > KSPCreate(PETSC_COMM_WORLD, &kspu); > KSPSetType(kspu, KSPGMRES); > Why do you have two KSPs here? > > KSPGetPC(ksp, &pc); > KSPGetPC(kspu, &pc); > Why? > > PCSetType(pc, PCMG); > PCMGSetLevels(pc, 2, PETSC_NULL); > PCMGSetType(pc, PC_MG_MULTIPLICATIVE); > PCMGSetCycleType(pc, PC_MG_CYCLE_V); > MatDuplicate(A, MAT_COPY_VALUES, &P); > PCMGSetCyclesOnLevel(pc, 0, 1); > PCMGSetCyclesOnLevel(pc, 1, 1); > PCMGGetCoarseSolve(pc, &ksp); > PCMGGetSmootherDown(pc, 0, &ksp); > PCMGGetSmootherUp(pc, 1, &kspu);//(*)// > Okay, clearly you need to learn how variables work in C. Here is a free resource. http://c.learncodethehardway.org/book/ (Any other resource will also do.) When you are comfortable with the language, we can revisit your code. > PCMGSetInterpolation(pc, 1, P); > PCMGSetRestriction(pc, 1, P); > PCMGSetResidual(pc, 0, PCMGDefaultResidual, P); > PCMGSetResidual(pc, 1, PCMGDefaultResidual, P); > KSPSetOperators(ksp, A, P, SAME_NONZERO_PATTERN); > KSPSetFromOptions(ksp); > KSPSolve(ksp, breal, xreal_harm); > KSPSolve(ksp, bimag, ximag_harm); > ////////////////////////////////////////////////////////// > > Do you think this is working again because of some accident? Without the > step marked with a //(*)//, the code works too. > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120610/be76e859/attachment.html>
