<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi Matt,<br>I found my error! It's due to the output part in my code. How stupid I am! When I "Script" the matrix_viewer, I found the none-zero values. I'm ready to check my output code. Please forgive my stupid. Thank you for your patient reply! Hope you have a nice day!<br>Thank you very much!<br>daye<br></div><br><br><br><br><div style="position:relative;zoom:1"></div><div id="divNeteaseMailCard"></div><br>At 2018-03-24 19:58:57, "Matthew Knepley" <knepley@gmail.com> wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Mar 24, 2018 at 8:56 AM, ĪŅ <span dir="ltr"><<a href="mailto:dayedut123@163.com" target="_blank">dayedut123@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi Matt,<br>I have tested my code with a really small matrix(10*10) just now and the preconditioned matrix is obtained. But for my case, the output is still equal to zero. I'm thinking if it is because this coefficient matrix is too ill. In my case, due to the Dirichlet boundary condition, I multiply a really huge number(e.g. 1e+10) at the matrix's given position. So this matrix is combined with some really huge numbers. I don't know if it will influence the preconditioned matrix output.<br></div></div></blockquote><div><br></div><div>Try changing the PC to Jacobi and see what you get. I think its not the huge numbers.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>The viewer is PETSC_VIEWER_STDOUT_WORLD.<br>Thanks again!<br>daye<br></div><br><br><br><br><div style="zoom:1"></div><div id="m_7065186979939973756divNeteaseMailCard"></div><br>At 2018-03-24 19:26:34, "Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br> <blockquote id="m_7065186979939973756isReplyContent" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Mar 24, 2018 at 8:15 AM, ĪŅ <span dir="ltr"><<a href="mailto:dayedut123@163.com" target="_blank">dayedut123@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi Matt,<br>Sorry to distribute you again. I still have trouble with KSPComputeExplicitOperator. I reduced the matrix size to around 1000*1000. The time-cost of this function is acceptable, but when I output the preconditioned matrix, all the values are equal to zero! Here is part of my codes, do I operate error with this function?<br><br>PC pc;<br>KSP ksp;<br>Mat A,PA;<br>Vec b,x;<br>ierr=KSPCreate(PETSC_COMM_WORL<wbr></wbr>D,&ksp);CHKERRQ(ierr);<br>ierr=KSPSetOperators(ksp,A,A);<wbr></wbr>CHKERRQ(ierr);<br>ierr=KSPGetPC(ksp,&pc);CHKERRQ<wbr></wbr>(ierr);<br>ierr=PCSetType(pc,PCHYPRE);CHK<wbr></wbr>ERRQ(ierr);<br>ierr=KSPSetType(ksp,KSPGMRES);<wbr></wbr>CHKERRQ(ierr);<br>ierr=KSPSetFromOptions(ksp);CH<wbr></wbr>KERRQ(ierr);<br>ierr=KSPSolve(ksp,b,x);CHKERRQ<wbr></wbr>(ierr);<br>ierr=KSPComputeExplicitOperato<wbr></wbr>r(ksp,&PA);<br></div></div></blockquote><div><br></div><div>There is no need to assemble the output matrix.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>ierr=MatAssemblyBegin(PA,MAT_F<wbr></wbr>INAL_ASSEMBLY);CHKERRQ(ierr);<br>ierr=MatAssemblyEnd(PA,MAT_FIN<wbr></wbr>AL_ASSEMBLY);CHKERRQ(ierr);<br></div></div></blockquote><div><br></div><div>What kind of viewer are you using? The code above should work. I would step through</div><div>in the debugger to see why one column is all zeros, or try it in an example like</div><div>SNES ex5 to make sure its not a problem in your code.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>ierr=MatView(PA,viewer);CHKERR<wbr></wbr>Q(ierr);<br><br>Thank you very much!<br>Daye<br><br></div><br><br><br><br><div style="zoom:1"></div><div id="m_7065186979939973756m_-7017123387310291066divNeteaseMailCard"></div><br>At 2018-03-23 07:41:26, "Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br> <blockquote id="m_7065186979939973756m_-7017123387310291066isReplyContent" style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 22, 2018 at 8:29 PM, ĪŅ <span dir="ltr"><<a href="mailto:dayedut123@163.com" target="_blank">dayedut123@163.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi all,<br>I want to analyze the preconditioned matrix. But the KSPComputeExplicitOperator costs too much time to obtain the matrix. My origin matrix is about 3000*3000 sparse one. I noticed this function is applicable for the relative small system. What's the matrix-size limitation for this function? And for my case, any suggestions to solve it with less time?<br></div></div></blockquote><div><br></div><div>This is just a really expensive operation. There is no way around it.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Thank you very much!<br>daye <a name="m_7065186979939973756_m_-7017123387310291066_m_6587389865708374460_KSPComputeExplicitOperator"><h1><br></h1></a></div></div><br><br><span title="neteasefooter"><p> </p></span></blockquote></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><span class="m_7065186979939973756HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_7065186979939973756m_-7017123387310291066gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~k<wbr></wbr>nepley/</a><br></div></div></div></div></div>
</font></span></font></span></div></div><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br><span title="neteasefooter"><p> </p></span></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_7065186979939973756gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~<wbr></wbr>knepley/</a><br></div></div></div></div></div>
</font></span></div></div>
</blockquote></div><br><br><span title="neteasefooter"><p> </p></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>
</blockquote></div><br><br><span title="neteasefooter"><p> </p></span>