<div dir="ltr">Thanks... <br><br>Shao-Ching, have you solved this problem? <br><br><br><div class="gmail_quote">On Mon, Aug 4, 2008 at 11:49 AM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</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;"><br>
One reason not to use this approach is that it can result in a very ill-conditioned linear<br>
system that may be difficult for an iterative solver.<br><font color="#888888">
<br>
Barry</font><div><div></div><div class="Wj3C7c"><br>
<br>
On Aug 3, 2008, at 10:09 PM, berry wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hi, shao-ching<br>
<br>
Why not try to change the singular matrix to be non-singular ?<br>
I mean set the last column and row of the matrix to be zero except diagonal element( which is set to 1).<br>
<br>
<br>
<br>
On Mon, Aug 4, 2008 at 9:23 AM, Shao-Ching Huang <<a href="mailto:schuang@ats.ucla.edu" target="_blank">schuang@ats.ucla.edu</a>> wrote:<br>
Hi Barry:<br>
<br>
Thanks you for your suggestions. Now both sequential and parallel<br>
cases work when I use CG.<br>
<br>
Shao-Ching<br>
<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>
<br>
<br>
<br>
-- <br>
Pang Shengyong<br>
Solidification Simulation Lab,<br>
State Key Lab of Mould & Die Technology,<br>
Huazhong Univ. of Sci. & Tech. China<br>
</blockquote>
<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>