<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 17, 2016 at 10:15 AM, Pierre Jolivet <span dir="ltr"><<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Dear Hong,<div>Thank you for your answer.</div><div>I understand the error message, but I don’t understand why setting the preconditioner to be of type LU, i.e., factorizing the matrix, does not set the factortype to MAT_FACTOR_LU.</div><div></div></div></blockquote><div><br></div><div>It sounds like you were using the wrong matrix. If the factorization is out-of-place, then A is not the factored matrix.</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="word-wrap:break-word"><div>More puzzling to me is the fact that in the output, one can see:</div><div><br></div><div><div> Factored matrix follows:</div><div> Mat Object: 1 MPI processes</div></div><div><br></div><div>but that the error is then that the matrix is unfactored. Anyway, as you suggested, this works:</div><div><div> Mat F;</div><div> PCFactorGetMatrix(pc, &F);</div><div> MatSolve(F, b, x);</div></div><div><br></div><div>Thank you,</div><div>Pierre</div><div><br></div><div><div><blockquote type="cite"><div>On Aug 17, 2016, at 4:34 PM, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Pierre:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
[0]PETSC ERROR: Object is in wrong state<br>
[0]PETSC ERROR: Unfactored matrix<br></blockquote><div><br></div><div>indicates that your input matrix is an Unfactored matrix.</div><div><br></div><div>If you want to replace KSPSolve() with your own MatMatSolve, you need use following blocks</div><div>to replace KSPSolve() :</div><div><div>Mat F;</div><div> ierr = KSPGetPC(ksp,&pc);</div><div> ierr = PCFactorSetMatSolverPackage(<wbr>pc,MATSOLVERPETSC);</div><div> ierr = PCFactorSetUpMatSolverPackage(<wbr>pc); /* call MatGetFactor() to create F */</div><div> ierr = PCFactorGetMatrix(pc,&F);</div><div> ierr = KSPSetUp(ksp);</div></div><div> ierr = MatSolve(F,b,x);<br></div><div><br></div><div>Hong</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/faq.html</a> for trouble shooting.<br>
[0]PETSC ERROR: Petsc Development GIT revision: v3.7.3-1165-gfeaa1dd GIT Date: 2016-08-16 11:58:28 -0500<br>
<br>
Is this the expected behavior? How should I call MatSolve?<br>
The rationale for calling MatSolve instead of KSPSolve (for which there is obviously no error) is that I need to use MatMatSolve in my application—because there is no KSPSolve(KSP, Mat, Mat), and the behavior is the same for both MatSolve and MatMatSolve.<br>
<br>
Thank you,<br>
Pierre</blockquote></div><br></div></div>
</div></blockquote></div><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">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></div>