I've check it in Matlab. the matrix A is symmetric and has no negative eigenvalues( only a zero eigen value). I've also checked that the nullspace is correct( norm(A*phi)<1e-11); <br>Thanks. <div><br><div class="gmail_quote">
On Wed, Nov 23, 2011 at 1:26 PM, 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="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Print out the matrix for a small grid then check in Matlab that it is symmetric and has no negative eigenvalues.<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Nov 23, 2011, at 9:50 AM, Shiyuan wrote:<br>
<br>
> Hi,<br>
> I want to solve a singular system with a known nullspace. However, I the KSP solve diverges with KSP_INDEFINTE_PC even if I disable the preconditioning by PCNONE.<br>
> this is how I setup the system. What did I do wrong? Any possible causes? Thanks.<br>
><br>
> ierr=MatNullSpaceCreate(PETSC_COMM_SELF,PETSC_FALSE,1,&phi,&nsp);CHKERRV(ierr);<br>
> ierr=KSPCreate(PETSC_COMM_SELF,&ksp);CHKERRV(ierr);<br>
> ierr=KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRV(ierr);<br>
> ierr=KSPSetNullSpace(ksp,nsp);CHKERRV(ierr);<br>
> ierr=KSPSetType(ksp,KSPCG);CHKERRV(ierr);<br>
> ierr=KSPGetPC(ksp,&prec);CHKERRV(ierr);<br>
> ierr=PCSetType(prec,PCNONE);CHKERRV(ierr);<br>
> ierr=KSPSetTolerances(ksp,1e-5,1e-20,1e5,10000);CHKERRV(ierr);<br>
> ierr=KSPSetFromOptions(ksp);CHKERRV(ierr);<br>
> ierr=KSPSetUp(ksp);CHKERRV(ierr);<br>
><br>
> Shiyuan<br>
<br>
</div></div></blockquote></div><br></div>