[petsc-users] multigrid implementation problem

Nakib Haider Protik nprot048 at uottawa.ca
Sun Jun 10 20:32:37 CDT 2012


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);

    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
[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.

Thanks

> On Sun, Jun 10, 2012 at 8:19 PM, Nakib Haider Protik
> <nprot048 at uottawa.ca>wrote:
>
>> With the suggested changes, the code doesn't run.
>>
>
> You didn't state the error or show the code.
>
>
>> Is there any example
>> code of KSP solvers using multigrid preconditioning? All the examples of
>> multigrid I have come across involve dmmg.
>>
>
> Please upgrade to petsc-3.3. DMMG is gone and most examples support
> multigrid. In most cases, you can just run with -pc_type mg.
>


-- 
Nakib :)


More information about the petsc-users mailing list