2011/1/28 Cristian Tibirna <span dir="ltr">&lt;<a href="mailto:ctibirna@giref.ulaval.ca">ctibirna@giref.ulaval.ca</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello<br>
<br>
We use PETSc-2.3.3-p15 (long story...) embedded inside a large FE code from<br>
which it would be difficult for me to extract exact PETSc code. Sorry for<br>
this. But we have a rather ugly problem and I would like to know just if it is<br>
our use or there might be some intrinsic problem.<br>
<br>
What we do, in principle, is<br>
1) create a KSP, a Mat and some Vec<br>
2) start a loop (e.g. a home-made nonlinear solver)<br>
        inside the loop:<br>
        2.1)  reassemble Mat either through one of two variants:<br>
                a) sometimes the nonzero structure is constant<br>
                        only the assembled values are changing<br>
                b) sometimes the nonzero structure changes too,<br>
                        which brings us to create and use a new Mat<br>
        2.2) reassemble the rhs Vec<br>
        2.3) on fait un KSPSetOperators avec<br>
        2.4) solve the system and get the solution (or correction)<br>
<br>
NOTE: As you see, the KSP is created only once then reused.<br>
NOTE: the point b) -- the main issue of this email -- consists most usually of<br>
a MatPtAP operation, which naturally gives us a new Mat with new non-zero<br>
structure.<br>
<br>
If we do the above with the variant a), all works perfectly.<br>
if we do the variant b), the solution is completely aberant.<br></blockquote><div><br></div><div>That should work. This is not really enough of a description for us to debug the problem.</div><div>I suggest using -pc_type lu -ksp_type preonly for an exact solution, and then check the</div>
<div>solution for doing a MatMult(). Usually, this problem occurs because you forget to call</div><div>KSPSetOperators().</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;">

The only workaround we found was to recreate the KSP at each iteration in the<br>
loop. Then the solution vector is correctly computed.<br>
<br>
What gives?<br>
<font color="#888888"><br>
--<br>
Cristian Tibirna                                (1-418-) 656-2131 / 4340<br>
  Laval University - Quebec, CAN ... <a href="http://www.giref.ulaval.ca/~ctibirna" target="_blank">http://www.giref.ulaval.ca/~ctibirna</a><br>
  Research professional at GIREF ... <a href="mailto:ctibirna@giref.ulaval.ca">ctibirna@giref.ulaval.ca</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>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<br>