2011/1/28 Cristian Tibirna <ctibirna at giref.ulaval.ca> > Hello > > We use PETSc-2.3.3-p15 (long story...) embedded inside a large FE code from > which it would be difficult for me to extract exact PETSc code. Sorry for > this. But we have a rather ugly problem and I would like to know just if it > is > our use or there might be some intrinsic problem. > > What we do, in principle, is > 1) create a KSP, a Mat and some Vec > 2) start a loop (e.g. a home-made nonlinear solver) > inside the loop: > 2.1) reassemble Mat either through one of two variants: > a) sometimes the nonzero structure is constant > only the assembled values are changing > b) sometimes the nonzero structure changes too, > which brings us to create and use a new Mat > 2.2) reassemble the rhs Vec > 2.3) on fait un KSPSetOperators avec > 2.4) solve the system and get the solution (or correction) > > NOTE: As you see, the KSP is created only once then reused. > NOTE: the point b) -- the main issue of this email -- consists most usually > of > a MatPtAP operation, which naturally gives us a new Mat with new non-zero > structure. > > If we do the above with the variant a), all works perfectly. > if we do the variant b), the solution is completely aberant. >
That should work. This is not really enough of a description for us to debug the problem. I suggest using -pc_type lu -ksp_type preonly for an exact solution, and then check the solution for doing a MatMult(). Usually, this problem occurs because you forget to call KSPSetOperators(). Matt > The only workaround we found was to recreate the KSP at each iteration in > the > loop. Then the solution vector is correctly computed. > > What gives? > > -- > Cristian Tibirna (1-418-) 656-2131 / 4340 > Laval University - Quebec, CAN ... http://www.giref.ulaval.ca/~ctibirna > Research professional at GIREF ... ctibirna at giref.ulaval.ca > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110128/36b10b25/attachment.htm>
