LinearSolve.jl icon indicating copy to clipboard operation
LinearSolve.jl copied to clipboard

Unified handling of preconditoners and factorizations ?

Open j-fu opened this issue 1 year ago • 2 comments

Hi,

I see that 2.0 is underway, so this may be an occasion to have some discussion about the API. The current API handles preconditioners and direct solvers very differently. IMHO they both are (possibly incomplete) factorizations and could be handeled in a similar way.

OTOH, the current API puts UMFPACKFactorization() and the like and iterative solvers into one basket which seems to be not very logical to me either.

So my view is the following:

  • A complete factorization provides a solver: Pardiso, Umfpack, KLU, Cholesky etc.

  • whereas an approximate factorization provides a preconditioner: ILU0, Jacobi, AlgebraicMultigrid etc.

Iterative algorithms are CG, GMRES etc. Direct solution essentially corresponds to a "OneStep" algorithm which works together with a complete factorization aka solver.

In that sense, a solve API could look as follows:

solve(P::LinearProblem, F::Factorization, I::Iteration)

and one could have something like

solve(P::LinearProblem, F::Factorization)= solve(P,F,OneStep())

(with a possible warning that an incomplete factorization doesn't solve)

As factorization one would provide a preconditioner constructor instead of a the preconditioner itself. So we could have

solve(p, KLUFactorization())
solve(p, ILU0Factorization(), CG())

Repeated solve after updating the matrix could update the preconditioner in a similar way as a factorization.

May be this proposal comes too late or doesn't fit for some other reasons, I can live either way (and already coded around this...).

j-fu avatar May 31 '23 12:05 j-fu