You could do -sys2_mg_levels_ksp_max_it 3 and/or -sys2_mg_coarse_pc_type
redundant
Or if you configured PETSc with a parallel direct solver like superlu_dist
you could use -sys2_mg_coarse_pc_type pc
-sys2_mg_coarse_pc_mat_factor_solver_package superlu_dist
Or you could keep the current PC gamg options and switch to -ksp_type bcgs
Barry
> On Nov 21, 2014, at 11:05 PM, Anush Krishnan <[email protected]> wrote:
>
>
>
> On 21 November 2014 18:23, Barry Smith <[email protected]> wrote:
>
> > On Nov 21, 2014, at 5:09 PM, Anush Krishnan <[email protected]> wrote:
> >
> > Hello petsc-users,
> >
> > I've been running some CFD simulations, and I ran into one case where the
> > system (which is a coupled system for pressure and body forces) did not
> > converge and the reason was KSP_DIVERGED_INDEFINITE_PC. The options I'm
> > using are -pc_gamg_agg_nsmooths 1 -pc_type gamg -pc_gamg_type agg with a
> > conjugate gradient solver.
>
> We've heard reports of this happening before. You should increase the
> number of smoothing steps for the multigrid or change to a "stronger"
> smoother.
>
> What do you get with -ksp_view for exact solver you are using?
>
> I've attached a copy of the output with -ksp_view.
>
>
> Are you using PETSc's SNES? TS? Or just KSP?
>
> Just KSP.
>
>
> >
> > I saw in example ksp/pc/examples/tutorials/ex2.c that I should use the flag
> > -pc_factor_shift_positive_definite to avoid this.
>
> This flag is only for factorization based preconditioners not gamg so you
> should not use it.
>
> > I have a few questions regarding this:
> > • What does it mean that the preconditioner is indefinite?
>
> It means that the preconditioner generated by GAMG has both negative and
> positive eigenvalues. CG cannot handle this, CG requires the preconditioner
> have all eigenvalues of the same sign.
>
> > What can cause this to happen? And what does the above flag do?
> > • The error occurs midway through the simulation. Is there any reason
> > why this might be the case? The left-hand side matrix does not change
> > during the simulation.
>
> Huh? If the matrix is not changing then the preconditioner should not be
> changing and hence the preconditioner should not be rebuilt and hence you
> should not see this message "midway through the simulation". Are you sure
> that the matrix is not changing??
>
> Yes, I'm sure that the matrix is not changing. Only the right hand side
> vector changes every time step.
>
> I have heard that CG sometimes converges even if the matrix is not positive
> definite - do you think that might be happening? Also, is there a way to
> check if a given matrix is positive definite using PETSc? And is it possible
> to generate an indefinite preconditioner from a matrix that is symmetric
> positive definite (I remember seeing a thread about this recently)?
>
>
>
> > • Do both -pc_factor_shift_positive_definite and
> > -pc_factor_shift_type POSITIVE_DEFINITE do the same thing?
>
> Yes, they are from different versions of PETSc, but neither are for gamg.
>
> Barry
>
> > Thank you,
> >
> > Anush
> >
>
>
> <ksp_view.txt>