[petsc-users] MatGetDiagonal

Hong Zhang hzhang at mcs.anl.gov
Tue Aug 9 09:09:32 CDT 2011


Clemens :
I can repeat your problem, could be a bug in petsc.
I'm investigating it and will get back to you soon.
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);
>


More information about the petsc-users mailing list