about MatSolve() and KSP

Barry Smith bsmith at mcs.anl.gov
Tue Jan 27 11:51:54 CST 2009


On Jan 27, 2009, at 11:43 AM, Yujie wrote:

> Dear PETSc Developers:
>
> I have checked the differerence between 2.3.3 and 3.0.0 in using  
> external package.
>
> Now, we don't need to use Matconvert() to convert the matrix to the  
> type suitable for external package, just to use MatGetFactor().
>
> The following codes are the realization of MatSolveXXX() after  
> calling MatGetFactor().
>
> 53: MatFactorInfoInitialize(&info);
>
> 54: MatGetFactor(C,MAT_SOLVER_PETSC,MAT_FACTOR_LU,&A);
>
>  55: MatLUFactorSymbolic(A,C,row,col,&info);
>  56: MatLUFactorNumeric(A,C,&info);
>  57: MatSolveTranspose(A,b,x);
>
> I have checked the description to MatSolveXXX() or MatMatSolve().
>
> "Notes
> Most users should employ the simplified KSP interface for linear  
> solvers instead of working directly with matrix algebra routines  
> such as this. See, e.g., KSPCreate()."
>
    ^^^^^^^

     MOST users of PETSc, 99% at least, need to solve a single linear  
system at a time. For these we recommend using KSP since it provides a  
COMMON
interface for all linear solvers direct and iterative. By coding  
directly with MatSolve() one losses the flexibility of switching  
between many solvers are are
more appropriate for PDES.

    Because block (multiple right hand side) Krylov methods are  
complicated and delicate (and we are lazy) we have not coded our  
iterative methods
for solving many systems at the same time. Thus KSP does not support  
directly solving many linear systems at the same time. Due to demand  
from a small
number of users we do provide support for multiple solves using direct  
solvers via MatMatSolve(). If we were not so damn lazy and coded KSP  
up for multiple
solves then we would not suggest using MatMatSolve() directly, but  
since we are stupid and lazy when one solves multiple right hand sides  
with
direct solvers we suggest MatMatSolve().

    It is really easy to understand.

    Barry
> You advise to use KSP interface for calling MatSolveXXX(). I am  
> wondering if it is ok to directly call MatSolveXX(), why need KSP  
> interface? thanks a lot.
>
> Regards,
>
> Yujie
>
>
>



More information about the petsc-users mailing list