[petsc-users] Return value of PCFactorGetMatrix
Shri
abhyshr at mcs.anl.gov
Mon Dec 12 11:44:34 CST 2011
MatGetFactor() only sets up the matrix for factorization but does not do any factorization. You need to call
MatCholeskyFactorSymbolic() http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCholeskyFactorSymbolic.html
and MatCholeskyFactorNumeric() http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCholeskyFactorNumeric.html#MatCholeskyFactorNumeric
after MatGetFactor().
Shri
----- Original Message -----
> 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