[petsc-users] petsc KLU

Barry Smith bsmith at mcs.anl.gov
Fri Aug 14 10:30:58 CDT 2015


   You should call 

    MatGetFactor(mat,MATSOLVERKLU,MAT_FACTOR_LU,&fact); 

  then call 

> MatLUFactorNumeric(Mat fact,Mat mat,const MatFactorInfo *info)
> MatLUFactorSymbolic(Mat fact,Mat mat,IS row,IS col,const MatFactorInfo *info)
> MatLUFactor(Mat mat,IS row,IS col,const MatFactorInfo *info)

   This routines correctly internally call the appropriate MatLUFactorNumeric_KLU() etc for you because you passed MATSOLVERKLU above.
   There is no reason to (and it won't work) to call 

> MatLUFactorNumeric_KLU(Mat F,Mat A,const MatFactorInfo *info)
> MatLUFactorSymbolic_KLU(Mat F,Mat A,IS r,IS c,const MatFactorInfo *info)
> MatGetFactor_seqaij_klu(Mat A,MatFactorType ftype,Mat *F)

directly.

  Barry

> On Aug 14, 2015, at 10:07 AM, Romain Thomas <R.Thomas at tudelft.nl> wrote:
> 
> Hi,
> Thank you for your answer.
> My problem is a bit more complex. During the simulation (“real time”), I need to upgrade at each time step the matrix A and the MatassemblyBegin and MatassemblyEnd take time and so, in order to avoid these functions, I don’t use ksp or pc. I prefer to use the functions MatLUFactorNumeric, MatLUFactorSymbolic and MatLUFactor. And so, I want to know if there is similar functions for KLU. (I tried for Cholesky and, iLU and it works well).
> Best regards,
> Romain
>  
>  
> From: Matthew Knepley [mailto:knepley at gmail.com] 
> Sent: vrijdag 14 augustus 2015 16:41
> To: Romain Thomas
> Cc: petsc-users at mcs.anl.gov
> Subject: Re: [petsc-users] petsc KLU
>  
> On Fri, Aug 14, 2015 at 9:23 AM, Romain Thomas <R.Thomas at tudelft.nl> wrote:
> Dear PETSc users,
> 
> I would like to know if I can replace the following functions
> 
> MatLUFactorNumeric(Mat fact,Mat mat,const MatFactorInfo *info)
> MatLUFactorSymbolic(Mat fact,Mat mat,IS row,IS col,const MatFactorInfo *info)
> MatLUFactor(Mat mat,IS row,IS col,const MatFactorInfo *info)
> 
> by
> 
> MatLUFactorNumeric_KLU(Mat F,Mat A,const MatFactorInfo *info)
> MatLUFactorSymbolic_KLU(Mat F,Mat A,IS r,IS c,const MatFactorInfo *info)
> MatGetFactor_seqaij_klu(Mat A,MatFactorType ftype,Mat *F)
> 
> in my code for the simulation of electrical power systems? (I installed the package SuiteSparse)
>  
> Why would you do that? It already works with the former code. In fact, you should really just use
>  
>   KSPCreate(comm, &ksp)
>   KSPSetOperator(ksp, A, A);
>   KSPSetFromOptions(ksp);
>   KSPSolve(ksp, b, x);
>  
> and then give the options
>  
>   -ksp_type preonly -pc_type lu -pc_mat_factor_package suitesparse
>  
> This is no advantage to using the Factor language since subsequent calls to
> KSPSolve() will not refactor.
>  
>    Matt
>  
> Thank you,
> Best regards,
> Romain
> 
> 
>  
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener



More information about the petsc-users mailing list