<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Hong,<div class="">Thank you for your answer.</div><div class="">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 class="">More puzzling to me is the fact that in the output, one can see:</div><div class=""><br class=""></div><div class=""><div class="">      Factored matrix follows:</div><div class="">        Mat Object: 1 MPI processes</div></div><div class=""><br class=""></div><div class="">but that the error is then that the matrix is unfactored. Anyway, as you suggested, this works:</div><div class=""><div class="">  Mat F;</div><div class="">  PCFactorGetMatrix(pc, &F);</div><div class="">  MatSolve(F, b, x);</div></div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Pierre</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Aug 17, 2016, at 4:34 PM, Hong <<a href="mailto:hzhang@mcs.anl.gov" class="">hzhang@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><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 class="">
[0]PETSC ERROR: Object is in wrong state<br class="">
[0]PETSC ERROR: Unfactored matrix<br class=""></blockquote><div class=""><br class=""></div><div class="">indicates that your input matrix is an  Unfactored matrix.</div><div class=""><br class=""></div><div class="">If you want to replace KSPSolve() with your own MatMatSolve, you need use following blocks</div><div class="">to replace KSPSolve() :</div><div class=""><div class="">Mat F;</div><div class="">  ierr = KSPGetPC(ksp,&pc);</div><div class="">  ierr = PCFactorSetMatSolverPackage(pc,MATSOLVERPETSC);</div><div class="">  ierr = PCFactorSetUpMatSolverPackage(pc); /* call MatGetFactor() to create F */</div><div class="">  ierr = PCFactorGetMatrix(pc,&F);</div><div class="">  ierr = KSPSetUp(ksp);</div></div><div class="">  ierr = MatSolve(F,b,x);<br class=""></div><div class=""><br class=""></div><div class="">Hong</div><div class=""><br class=""></div><div class=""> </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" class="">http://www.mcs.anl.gov/petsc/<wbr class="">documentation/faq.html</a> for trouble shooting.<br class="">
[0]PETSC ERROR: Petsc Development GIT revision: v3.7.3-1165-gfeaa1dd  GIT Date: 2016-08-16 11:58:28 -0500<br class="">
<br class="">
Is this the expected behavior? How should I call MatSolve?<br class="">
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 class="">
<br class="">
Thank you,<br class="">
Pierre</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>