<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 17, 2016, at 5:21 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 17, 2016 at 10:15 AM, Pierre Jolivet<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank" class="">pierre.jolivet@enseeiht.fr</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" 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=""></div></div></blockquote><div class=""><br class=""></div><div class="">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></div></div></div></blockquote><div><br class=""></div><div>Ah, I didn’t think about in-place/out-of-place factorization. That makes perfect sense, thank you!</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">   Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><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="">     <span class="Apple-converted-space"> </span>Factored matrix follows:</div><div class="">       <span class="Apple-converted-space"> </span>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=""> <span class="Apple-converted-space"> </span>Mat F;</div><div class=""> <span class="Apple-converted-space"> </span>PCFactorGetMatrix(pc, &F);</div><div class=""> <span class="Apple-converted-space"> </span>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 class=""><blockquote type="cite" class=""><div class="">On Aug 17, 2016, at 4:34 PM, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank" class="">hzhang@mcs.anl.gov</a>> wrote:</div><br class=""><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-width: 1px; border-left-style: solid; border-left-color: 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=""> <span class="Apple-converted-space"> </span>ierr = KSPGetPC(ksp,&pc);</div><div class=""> <span class="Apple-converted-space"> </span>ierr = PCFactorSetMatSolverPackage(<wbr class="">pc,MATSOLVERPETSC);</div><div class=""> <span class="Apple-converted-space"> </span>ierr = PCFactorSetUpMatSolverPackage(<wbr class="">pc); /* call MatGetFactor() to create F */</div><div class=""> <span class="Apple-converted-space"> </span>ierr = PCFactorGetMatrix(pc,&F);</div><div class=""> <span class="Apple-converted-space"> </span>ierr = KSPSetUp(ksp);</div></div><div class=""> <span class="Apple-converted-space"> </span>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-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">[0]PETSC ERROR: See<span class="Apple-converted-space"> </span><a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank" class="">http://www.mcs.anl.gov/petsc/d<wbr class="">ocumentation/faq.html</a><span class="Apple-converted-space"> </span>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></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><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 class="">-- Norbert Wiener</div></div></div></div></blockquote></div><br class=""></body></html>