<div dir="ltr"><div>hi, shao-ching</div>
<div> </div>
<div>Why not try to change the singular matrix to be non-singular ? </div>
<div>I mean set the last column and row of the matrix to be zero except diagonal element( which is set to 1).</div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On Mon, Aug 4, 2008 at 9:23 AM, Shao-Ching Huang <span dir="ltr"><<a href="mailto:schuang@ats.ucla.edu">schuang@ats.ucla.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Barry:<br><br>Thanks you for your suggestions. Now both sequential and parallel<br>cases work when I use CG.<br>
<font color="#888888"><br>Shao-Ching<br></font>
<div>
<div></div>
<div class="Wj3C7c"><br><br>On Fri, Aug 01, 2008 at 08:56:23PM -0500, Barry Smith wrote:<br>><br>> It is not the null space that is the problem.<br>><br>> You are right to try the shift but<br>> 1) first run on one process using -pc_type icc -ksp_type cg -<br>
> pc_factor_shift_positive_definite<br>> this will keep increasing the shift until it produces a positive-<br>> definite preconditioner.<br>><br>> Run also with -ksp_view to confirm that it is using all the options you<br>
> provided. (you can run with -help to<br>> see the option names)<br>><br>> 2) If you have the sequential converging then use -pc_type bjacobi -<br>> sub_pc_type icc -pc_factor_shift_positive_definite<br>><br>
> Barry<br>><br>> On Aug 1, 2008, at 7:52 PM, Shao-Ching Huang wrote:<br>><br>>> Hi,<br>>><br>>> I am trying to use CG to solve a singular systems (i.e. Poisson<br>>> equation with periodic conditions on all boundaries).<br>
>><br>>> The code works when I use GMRES, but it diverges when I switch CG.<br>>><br>>> Since the null space is a constant vector, in the code I have:<br>>><br>>> KSP ksp;<br>>> MatNullSpace nullspace;<br>
>> ...<br>>> MatNullSpaceCreate(MPI_COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL,<br>>> &nullspace);<br>>> KSPSetNullSpace(ksp, nullspace);<br>>> MatNullSpaceRemove(nullspace, f->p_rhs, PETSC_NULL);<br>
>><br>>> KSPSetFromOptions(ksp);<br>>> KSPSetUp(ksp);<br>>> KSPSolve(ksp, f->p_rhs, f->phi);<br>>><br>>> [f->p_rhs is the RHS vector. f->phi is the solution vector.]<br>
>><br>>> When I use "-ksp_type gmres", it converges (shown by -ksp_monitor).<br>>><br>>> However, when I switch to "-ksp_type cg", it diverges.<br>>> In this case (cg), "-ksp_converged_reason" says:<br>
>><br>>> Linear solve did not converge due to DIVERGED_INDEFINITE_PC<br>>> iterations 1<br>>><br>>> I also try adding "-sub_pc_factor_shift_nonzero 0.0000000001" but the<br>>> CG case still fails.<br>
>><br>>> Am I missing some step in handling the null space when using CG?<br>>><br>>> Thanks,<br>>><br>>> Shao-Ching Huang<br>>><br>>><br><br></div></div></blockquote></div>
<br><br clear="all"><br>-- <br>Pang Shengyong<br>Solidification Simulation Lab, <br>State Key Lab of Mould & Die Technology,<br>Huazhong Univ. of Sci. & Tech. China<br></div>