On Sun, Jun 10, 2012 at 8:32 PM, Nakib Haider Protik <nprot048 at uottawa.ca>wrote:
> Here's the code with the changes you suggested followed by the terminal > output: > > KSPCreate(PETSC_COMM_WORLD, &ksp); > //KSPCreate(PETSC_COMM_WORLD, &cksp); > //KSPCreate(PETSC_COMM_WORLD, &uksp); > //KSPCreate(PETSC_COMM_WORLD, &dksp); > > //KSPSetType(ksp, KSPGMRES); > //KSPSetType(cksp, KSPGMRES); > //KSPSetType(uksp, KSPGMRES); > //KSPSetType(dksp, KSPGMRES); > > KSPGetPC(ksp, &pc); > //KSPGetPC(cksp, &pc); > //KSPGetPC(uksp, &pc); > //KSPGetPC(dksp, &pc); > > KSPSetFromOptions(ksp); > > 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, &cksp); > //PCMGGetSmootherDown(pc, 0, &dksp); > //PCMGGetSmootherUp(pc, 1, &uksp); > > PCMGSetInterpolation(pc, 1, P); > PCMGSetRestriction(pc, 1, P); > PCMGSetResidual(pc, 0, PCMGDefaultResidual, P); > PCMGSetResidual(pc, 1, PCMGDefaultResidual, P); > ^^ I already explained that these lines are semantically incorrect. You are using the matrix P in different places that do not make sense. You have not set an operator for the smoother and you haven't set a vector. You have to do at least one of those if you want to use the "advanced" PCMG interface. Before trying anything else, install petsc-3.3 and read through this example. http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex45.c.html Compile it and run it with ./ex45 -da_refine 3 -ksp_monitor -pc_type mg -ksp_view Read through the output and understand what algorithm it is using. Run with -help and look at the options starting with "-pc_mg" and "-mg_levels". Change the algorithm using command line parameters. Then, and only then, consider using the low-level PCMG interface directly. > > KSPSetOperators(ksp, A, P, SAME_NONZERO_PATTERN); > KSPSolve(ksp, breal, xreal_harm); > KSPSolve(ksp, bimag, ximag_harm); > > [0]PETSC ERROR: --------------------- Error Message > ------------------------------------ > [0]PETSC ERROR: Null argument, when expecting valid pointer! > [0]PETSC ERROR: Null Object: Parameter # 1! > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: Petsc Release Version 3.0.0, Patch 12, Tue Mar 16 23:20:08 > CDT 2010 > I have asked you several times to upgrade to petsc-3.3. Please do that now, before you write back to this list. > [0]PETSC ERROR: See docs/changes/index.html for recent updates. > [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting. > [0]PETSC ERROR: See docs/index.html for manual pages. > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: ./3dPoissonSolver-cyl-test on a linux-gnu named nakib-F82Q > by nakib Sun Jun 10 21:30:04 2012 > [0]PETSC ERROR: Libraries linked from > /home/nakib/petsc-3.0.0-p12/linux-gnu-c-debug/lib > [0]PETSC ERROR: Configure run at Wed May 9 13:44:03 2012 > [0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran > --download-f-blas-lapack=1 --download-mpich=1 --with-shared=0 > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: MatGetVecs() line 7098 in src/mat/interface/matrix.c > [0]PETSC ERROR: KSPGetVecs() line 820 in src/ksp/ksp/interface/iterativ.c > [0]PETSC ERROR: PCSetUp_MG() line 465 in src/ksp/pc/impls/mg/mg.c > [0]PETSC ERROR: PCSetUp() line 794 in src/ksp/pc/interface/precon.c > [0]PETSC ERROR: KSPSetUp() line 237 in src/ksp/ksp/interface/itfunc.c > [0]PETSC ERROR: KSPSolve() line 353 in src/ksp/ksp/interface/itfunc.c > [0]PETSC ERROR: --------------------- Error Message > ------------------------------------ > [0]PETSC ERROR: Null argument, when expecting valid pointer! > [0]PETSC ERROR: Null Object: Parameter # 1! > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: Petsc Release Version 3.0.0, Patch 12, Tue Mar 16 23:20:08 > CDT 2010 > [0]PETSC ERROR: See docs/changes/index.html for recent updates. > [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting. > [0]PETSC ERROR: See docs/index.html for manual pages. > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: ./3dPoissonSolver-cyl-test on a linux-gnu named nakib-F82Q > by nakib Sun Jun 10 21:30:04 2012 > [0]PETSC ERROR: Libraries linked from > /home/nakib/petsc-3.0.0-p12/linux-gnu-c-debug/lib > [0]PETSC ERROR: Configure run at Wed May 9 13:44:03 2012 > [0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran > --download-f-blas-lapack=1 --download-mpich=1 --with-shared=0 > [0]PETSC ERROR: > ------------------------------------------------------------------------ > [0]PETSC ERROR: MatGetVecs() line 7098 in src/mat/interface/matrix.c > [0]PETSC ERROR: KSPGetVecs() line 820 in src/ksp/ksp/interface/iterativ.c > [0]PETSC ERROR: PCSetUp_MG() line 465 in src/ksp/pc/impls/mg/mg.c > [0]PETSC ERROR: PCSetUp() line 794 in src/ksp/pc/interface/precon.c > [0]PETSC ERROR: KSPSetUp() line 237 in src/ksp/ksp/interface/itfunc.c > [0]PETSC ERROR: KSPSolve() line 353 in src/ksp/ksp/interface/itfunc.c > > The code converges to the wrong solution too. > The error above is fatal, the solver is not configured correctly. You are supposed to catch the error (you can use the CHKERRQ macro). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120610/64211ac5/attachment.html>
