KSPSetNullSpace and CG for singular systems
berry
lua.byhh at gmail.com
Sun Aug 3 22:09:48 CDT 2008
hi, shao-ching
Why not try to change the singular matrix to be non-singular ?
I mean set the last column and row of the matrix to be zero except diagonal
element( which is set to 1).
On Mon, Aug 4, 2008 at 9:23 AM, Shao-Ching Huang <schuang at ats.ucla.edu>wrote:
> Hi Barry:
>
> Thanks you for your suggestions. Now both sequential and parallel
> cases work when I use CG.
>
> Shao-Ching
>
>
> On Fri, Aug 01, 2008 at 08:56:23PM -0500, Barry Smith wrote:
> >
> > It is not the null space that is the problem.
> >
> > You are right to try the shift but
> > 1) first run on one process using -pc_type icc -ksp_type cg -
> > pc_factor_shift_positive_definite
> > this will keep increasing the shift until it produces a positive-
> > definite preconditioner.
> >
> > Run also with -ksp_view to confirm that it is using all the options you
> > provided. (you can run with -help to
> > see the option names)
> >
> > 2) If you have the sequential converging then use -pc_type bjacobi -
> > sub_pc_type icc -pc_factor_shift_positive_definite
> >
> > Barry
> >
> > On Aug 1, 2008, at 7:52 PM, Shao-Ching Huang wrote:
> >
> >> Hi,
> >>
> >> I am trying to use CG to solve a singular systems (i.e. Poisson
> >> equation with periodic conditions on all boundaries).
> >>
> >> The code works when I use GMRES, but it diverges when I switch CG.
> >>
> >> Since the null space is a constant vector, in the code I have:
> >>
> >> KSP ksp;
> >> MatNullSpace nullspace;
> >> ...
> >> MatNullSpaceCreate(MPI_COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL,
> >> &nullspace);
> >> KSPSetNullSpace(ksp, nullspace);
> >> MatNullSpaceRemove(nullspace, f->p_rhs, PETSC_NULL);
> >>
> >> KSPSetFromOptions(ksp);
> >> KSPSetUp(ksp);
> >> KSPSolve(ksp, f->p_rhs, f->phi);
> >>
> >> [f->p_rhs is the RHS vector. f->phi is the solution vector.]
> >>
> >> When I use "-ksp_type gmres", it converges (shown by -ksp_monitor).
> >>
> >> However, when I switch to "-ksp_type cg", it diverges.
> >> In this case (cg), "-ksp_converged_reason" says:
> >>
> >> Linear solve did not converge due to DIVERGED_INDEFINITE_PC
> >> iterations 1
> >>
> >> I also try adding "-sub_pc_factor_shift_nonzero 0.0000000001" but the
> >> CG case still fails.
> >>
> >> Am I missing some step in handling the null space when using CG?
> >>
> >> Thanks,
> >>
> >> Shao-Ching Huang
> >>
> >>
>
>
--
Pang Shengyong
Solidification Simulation Lab,
State Key Lab of Mould & Die Technology,
Huazhong Univ. of Sci. & Tech. China
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080804/96646265/attachment.htm>
More information about the petsc-users
mailing list