[petsc-users] Return value of PCFactorGetMatrix
Uwe Schlifkowitz
uwe.schlifkowitz at uibk.ac.at
Mon Dec 12 11:35:46 CST 2011
Dear list,
following advice from this list and petsc documentation (especially http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex52.c.html ), i have the following code:
//---------
ierr = KSPCreate( coml,&kspBA);CHKERRQ(ierr);
ierr = KSPSetOperators( kspBA, Kt, Kt, DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
ierr = KSPSetType(kspBA,KSPPREONLY);CHKERRQ(ierr);
ierr = KSPGetPC(kspBA, &pcba);
ierr = PCSetType(pcba, PCCHOLESKY);CHKERRQ(ierr);
ierr = PCFactorSetMatSolverPackage(pcba, MATSOLVERPETSC);CHKERRQ(ierr);
ierr = PCFactorSetUpMatSolverPackage(pcba);CHKERRQ(ierr);
ierr = MatGetFactor(Kt,"petsc",MAT_FACTOR_CHOLESKY,&DiagM);CHKERRQ(ierr);
ierr = PCFactorGetMatrix(pcba, &DiagM);CHKERRQ(ierr);
ierr = KSPSetUp(kspBA);CHKERRQ(ierr);
//ierr = MatView(DiagM,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
//ierr = MatView(DiagM,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = VecDuplicate(fin,&diag);CHKERRQ(ierr);
ierr = MatGetDiagonal(DiagM,diag);CHKERRQ(ierr);
//-----------
where Kt is a stiffness matrix. I was hoping that PCFactorGetMatrix() makes DiagM become D from a LDL^T factorization, but to me it seems as if this is not true.
Can anyone clarify?
Regards,
Uwe
More information about the petsc-users
mailing list