<div dir="ltr"><div class="gmail_extra">Pierre:</div><div class="gmail_extra">See petsc/src/ksp/ksp/examples/tests/ex27.c on how to use MatMatSolve().</div><div class="gmail_extra">Hong</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 17, 2016 at 9:34 AM, Hong <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Pierre:</div><div class="gmail_quote"><span class=""><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></span><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><span class=""><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></span></div><br></div></div>
</blockquote></div><br></div></div>