The fix is in petsc-dev: http://petsc.cs.iit.edu/petsc/petsc-dev/rev/a19846efa232
I just pushed a test of MatGetDiagonal(F,diag) for petsc Cholesky factorization in ~petsc-dev/src/ksp/ksp/examples/tutorials/ex52.c Do cd ~petsc-dev hg pull hg update or get the latest petsc-dev. Run ex52 with ./ex52 -use_petsc_ch ... Vector Object: 1 MPI processes type: seq 4 3.75 3.73333 3.73214 ... 3.24979 3.30916 Norm of error < 1.e-12 iterations 1 Let us know if you do not get the above result. Hong On Thu, Aug 11, 2011 at 4:46 AM, Clemens Domanig <clemens.domanig at uibk.ac.at> wrote: > I checked out the dev-version today but it doesn't fix my problem. > Is it possible that your fix is not in th dev-version? > Thx. > > [0]PETSC ERROR: --------------------- Error Message > ---------------------------- > -------- > [0]PETSC ERROR: Object is in wrong state! > [0]PETSC ERROR: Not for factored matrix! > [0]PETSC ERROR: > ---------------------------------------------------------------- > -------- > [0]PETSC ERROR: Petsc Development HG revision: > 173a9704a10394abf9048b83aebd58c4c > > > > > Hong Zhang wrote: >> >> Clemens : >> This is a bug in MatGetDiagonal_SeqSBAIJ() for cholesky factored matrix. >> I fixed it and pushed to petsc-dev. >> See http://www.mcs.anl.gov/petsc/petsc-as/developers/index.html >> on how to get petsc-dev. >> >> Thanks for reporting the problem. Contact us if you still get problem. >> >> Hong >> >> >>> Hi, >>> >>> I already talked to some of you about this in combination with some other >>> problem, but somehow I don't get it. >>> I want the diagonal entries of the matrix M. But my vector 'diag' is >>> mainly >>> full of zeros when using MatGetDiagonal(). >>> I can print 'DiagM' (VecView) where I see all the diagonal entries but I >>> cannot access them using MatGetValue (Object is in wrong state. Not for >>> factored matrix!). >>> How can I get access to the diagonal? >>> Thx - Clemens >>> >>> >>> KSPCreate( coml, &kspBA); >>> KSPGetPC( kspBA, &precond); >>> PCSetType( precond, PCCHOLESKY); >>> PCFactorSetMatSolverPackage( precond, MAT_SOLVER_PETSC); >>> KSPSetOptionsPrefix( kspBA, "diag_pc_type cholesky"); >>> KSPSetFromOptions( kspBA); >>> KSPSetOperators( kspBA, Kt, Kt, DIFFERENT_NONZERO_PATTERN); >>> KSPSetUp( kspBA); >>> PCFactorGetMatrix( precond, &DiagM); ? ?//DO NOT DESTROY DiagM !!! >>> MatGetDiagonal( DiagM, diag); >>> > >
