On Wed, Jun 29, 2011 at 10:38 PM, Barry Smith <bsmith at mcs.anl.gov> wrote: > ? What do you mean a slower method? How can you verify that it is still a > good preconditioner without actually running the old preconditioner on the > new matrix.
I have two equivalent ways of building the matrix: 1) MatSetValues, (standard route) 2) MatCreate*WithArrays. Both routines produce identical matrices and identical solutions. However, if I run with version 1), the preconditioner is pretty good for many solves. If I run with version 2), the preconditioner only works well for a couple of solves. > ? ?BTW: You don't need that complicated stuff above. Just do > > ? ?KSPSetOperators( ksp, Amat, Amat, SAME_PRECONDITIONER ); > ? ?KSPSolve(). > ? ?change Amat, or destroy it and make a new one > ? ?KSPSetOperators( ksp, Amat, Amat, SAME_PRECONDITIONER ); > ? ?KSPSolve(). > > ? ?It will solve the new linear system using the old preconditioner built > during the first KSPSolve(). There is no reason to pass in the old version of > Amat you copied to Pmat I tried this and it works ok for a couple of solves (a couple of nonlinear iterations), but on the next timestep it takes a lot more iterations than what I referenced above as version 1). The total KSPSolve time in version 1) strongly indicates to me that it is indeed using the old preconditioner. Thanks, John
