SSOR problem

Matthew Knepley knepley at
Mon Apr 27 10:32:30 CDT 2009

The function MatMarkDiagonal_SeqAIJ() takes care of this.


On Mon, Apr 27, 2009 at 9:34 AM, SUN Chun <Chun.SUN at> wrote:

> Hello,
> I have an update to this problem:
> I found that in MatRelax_SeqAIJ function (mat/impl/aij/seq/aij.c), I have:
> diag = a->diag and:
> diag[i] is has exactly the same value of a->i[i] for each row i. This gives
> me n=0 when doing forward pass of zero initial guess. That explains why
> setting -pc_sor_forward will give me identical results as if I run pure
> I assume that this a->diag[] stores the sparse column index of diagonal
> entries of a matrix. Now it seems to be improperly set. I will pursue this
> further in debugger. Do you know which function it should be set during the
> assembly process? That would point a short-cut for me....
> Thanks again!
> Chun
> -----Original Message-----
> From: petsc-users-bounces at [mailto:
> petsc-users-bounces at] On Behalf Of SUN Chun
> Sent: Monday, April 27, 2009 9:13 AM
> To: PETSc users list
> Subject: SSOR problem
> Hello,
> I have an *particular* Ax=b which I want to solve with CG preconditioned
> by SSOR using PETSc. Then some specific strange things happen. Please
> allow me to describe all the symptoms that I found here. Thanks for your
> help:
> 0) All solves are in serial.
> 1) A 20-line academic code and another matlab code converge the solution
> with identical residual history and number of iterations (76), they
> match well. If I run without SSOR (just diagonal scaled CG): PETSc,
> academic code, and matlab all match well with same number (180) of
> iterations.
> 2) PETSc with SSOR seems to give me -8 indefinite pc. If I play with
> omega other than using 1.0 (as in Gauss-Seidel), sometimes (with
> omega=1.2) I see stagnation and it won't converge then exceeds the
> maximum iteration allowed (500). Residuals even don't go down. If I
> don't say -ksp_diagonal_scale, I get -8 too. So, PETSc with SSOR either
> gives me -8 or -3.
> 3) The above was run with -pc_sor_symmetric. However, if I ran with
> -pc_sor_forward, I got a convergence curve identical to what I have
> without any preconditioner, with same iterations (180). If I ran with
> -pc_sor_backward, it gives me -8 indefinite pc.
> 4) If I increase any of the number of -pc_sor_its (or lits) to 2, it
> converges (but still don't match the matlab/academic code).
> 5) The matrix has good condition number (~8000), maximum diagonal is
> about 6, minimum diagonal is about 1.1. There's no zero or negative
> diagonal entries in this matrix. It's spd otherwise matlab won't be able
> to solve it.
> 6) The behavior is independent of rhs. I've tried random rhs and get the
> same scenario.
> 7) Here is the confusing part: All other matrices that we have except
> for this one can be solved by PETSc with same settings very well. And
> they match the academic code and matlab code. It's just this matrix that
> exhibits the strange behavior. I tend to eliminate the possibility of
> interface problem because all other matrices and other preconditioner
> settings work well.
> We're running out of ideas here, if you have any insight please say
> anything or point any directions.
> Thanks a lot,
> Chun

What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the petsc-users mailing list