[petsc-users] CG or GMRES

Jed Brown jedbrown at mcs.anl.gov
Wed May 8 19:25:25 CDT 2013


"Zhenglun (Alan) Wei" <zhenglun.wei at gmail.com> writes:

> Dear folks,
> I hope you're having a nice day.
> For the Poisson solver in /src/ksp/ksp/example/tutorial/ex45.c, I used
> the ksp_type = CG to solve it before; it converges very fast with
> pc_type = gamg. However, I was trying to check if the matrix generated
> by the 'ComputeMatrix' is symmetric by using "ierr = MatIsSymmetric(B,
> tol, &flg);". It shows that this matrix is not exact a symmetric one by
> setting tol = 0.0. Yet, the matrix is 'symmetric' if the tol > 0.01.

The matrix does not enforce boundary conditions symmetrically.

> Does this mean that, even if the matrix is not exact symmetric, the CG
> could still be used. 

You happen to be iterating in a "benign" space in which the operator is SPD.

> This brings me a question. Can the CG be used to solve an actual
> unsymmetric matrix as long as 'MatIsSymmetric' returns a 'PETSC_TRUE'
> value with certain tolerance. 

No.

> Is there any rule of thumb for this tolerence?  Also, as a
> preconditioner, does 'gamg' only work for symmetric positive-definite
> matrix? or it works for any matrix or even with GMRES?

It works for many moderately non-symmetric, certainly for something that only
has non-symmetric boundary conditions.


More information about the petsc-users mailing list