[petsc-dev] factortype and -pc_type lu

Pierre Jolivet pierre.jolivet at enseeiht.fr
Wed Aug 17 10:15:05 CDT 2016


Dear Hong,
Thank you for your answer.
I understand the error message, but I don’t understand why setting the preconditioner to be of type LU, i.e., factorizing the matrix, does not set the factortype to MAT_FACTOR_LU.
More puzzling to me is the fact that in the output, one can see:

      Factored matrix follows:
        Mat Object: 1 MPI processes

but that the error is then that the matrix is unfactored. Anyway, as you suggested, this works:
  Mat F;
  PCFactorGetMatrix(pc, &F);
  MatSolve(F, b, x);

Thank you,
Pierre

> On Aug 17, 2016, at 4:34 PM, Hong <hzhang at mcs.anl.gov> wrote:
> 
> Pierre:
> 
> [0]PETSC ERROR: Object is in wrong state
> [0]PETSC ERROR: Unfactored matrix
> 
> indicates that your input matrix is an  Unfactored matrix.
> 
> If you want to replace KSPSolve() with your own MatMatSolve, you need use following blocks
> to replace KSPSolve() :
> Mat F;
>   ierr = KSPGetPC(ksp,&pc);
>   ierr = PCFactorSetMatSolverPackage(pc,MATSOLVERPETSC);
>   ierr = PCFactorSetUpMatSolverPackage(pc); /* call MatGetFactor() to create F */
>   ierr = PCFactorGetMatrix(pc,&F);
>   ierr = KSPSetUp(ksp);
>   ierr = MatSolve(F,b,x);
> 
> Hong
> 
>  
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html <http://www.mcs.anl.gov/petsc/documentation/faq.html> for trouble shooting.
> [0]PETSC ERROR: Petsc Development GIT revision: v3.7.3-1165-gfeaa1dd  GIT Date: 2016-08-16 11:58:28 -0500
> 
> Is this the expected behavior? How should I call MatSolve?
> The rationale for calling MatSolve instead of KSPSolve (for which there is obviously no error) is that I need to use MatMatSolve in my application—because there is no KSPSolve(KSP, Mat, Mat), and the behavior is the same for both MatSolve and MatMatSolve.
> 
> Thank you,
> Pierre
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160817/8415804e/attachment.html>


More information about the petsc-dev mailing list