<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(pc,MATSOLVERPETSC);</div><div>  ierr = PCFactorSetUpMatSolverPackage(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/<wbr>documentation/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>