The function MatMarkDiagonal_SeqAIJ() takes care of this.<br><br> Matt<br><br><div class="gmail_quote">On Mon, Apr 27, 2009 at 9:34 AM, SUN Chun <span dir="ltr"><<a href="mailto:Chun.SUN@3ds.com">Chun.SUN@3ds.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br>
<br>
I have an update to this problem:<br>
<br>
I found that in MatRelax_SeqAIJ function (mat/impl/aij/seq/aij.c), I have:<br>
<br>
diag = a->diag and:<br>
<br>
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 DSCG.<br>
<br>
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....<br>
<br>
Thanks again!<br>
<font color="#888888">Chun<br>
</font><div><div></div><div class="h5"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a> [mailto:<a href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a>] On Behalf Of SUN Chun<br>
Sent: Monday, April 27, 2009 9:13 AM<br>
To: PETSc users list<br>
Subject: SSOR problem<br>
<br>
Hello,<br>
<br>
I have an *particular* Ax=b which I want to solve with CG preconditioned<br>
by SSOR using PETSc. Then some specific strange things happen. Please<br>
allow me to describe all the symptoms that I found here. Thanks for your<br>
help:<br>
<br>
0) All solves are in serial.<br>
<br>
1) A 20-line academic code and another matlab code converge the solution<br>
with identical residual history and number of iterations (76), they<br>
match well. If I run without SSOR (just diagonal scaled CG): PETSc,<br>
academic code, and matlab all match well with same number (180) of<br>
iterations.<br>
<br>
2) PETSc with SSOR seems to give me -8 indefinite pc. If I play with<br>
omega other than using 1.0 (as in Gauss-Seidel), sometimes (with<br>
omega=1.2) I see stagnation and it won't converge then exceeds the<br>
maximum iteration allowed (500). Residuals even don't go down. If I<br>
don't say -ksp_diagonal_scale, I get -8 too. So, PETSc with SSOR either<br>
gives me -8 or -3.<br>
<br>
3) The above was run with -pc_sor_symmetric. However, if I ran with<br>
-pc_sor_forward, I got a convergence curve identical to what I have<br>
without any preconditioner, with same iterations (180). If I ran with<br>
-pc_sor_backward, it gives me -8 indefinite pc.<br>
<br>
4) If I increase any of the number of -pc_sor_its (or lits) to 2, it<br>
converges (but still don't match the matlab/academic code).<br>
<br>
5) The matrix has good condition number (~8000), maximum diagonal is<br>
about 6, minimum diagonal is about 1.1. There's no zero or negative<br>
diagonal entries in this matrix. It's spd otherwise matlab won't be able<br>
to solve it.<br>
<br>
6) The behavior is independent of rhs. I've tried random rhs and get the<br>
same scenario.<br>
<br>
7) Here is the confusing part: All other matrices that we have except<br>
for this one can be solved by PETSc with same settings very well. And<br>
they match the academic code and matlab code. It's just this matrix that<br>
exhibits the strange behavior. I tend to eliminate the possibility of<br>
interface problem because all other matrices and other preconditioner<br>
settings work well.<br>
<br>
We're running out of ideas here, if you have any insight please say<br>
anything or point any directions.<br>
<br>
Thanks a lot,<br>
Chun<br>
<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>