[petsc-users] Reusing ML preconditioner

John Fettig john.fettig at gmail.com
Wed Jun 29 10:50:58 CDT 2011


I'm trying to reuse a ML preconditioner but it's not working
correctly.  The A matrix is changing (even being destroyed), so here's
what I do:

1) The first time I'm setting up the KSP, I duplicate the A matrix
with MatDuplicate and pass it to the KSP:
   MatDuplicate(Amat,MAT_COPY_VALUES,&Pmat);
   KSPSetOperators( ksp, Amat, Pmat, SAME_PRECONDITIONER );

2) I call KSPSolve, then Amat gets destroyed.  The KSP persists.

3) The next time through, I follow the instructions on the manpage for
KSPSetOperators and do the following, note that Amat is a totally
different matrix:

              Mat tmp_A, tmp_P;
              MatStructure tmp_flag;

              KSPGetOperators(ksp,&tmp_A,&tmp_P,&tmp_flag);
              PetscObjectReference((PetscObject)(tmp_P));
              KSPSetOperators( ksp, new_Amat, tmp_P, SAME_PRECONDITIONER );

However it doesn't work.  The iteration count is too high (I verified
through a slower method that the preconditioner is still good for
new_Amat).  What am I doing wrong?

Thanks,
John


More information about the petsc-users mailing list