haampie / IncompleteLU.jl

Crout ILU for Julia
MIT License
32 stars 13 forks source link

Inplace update? #21

Open JianghuiDu opened 3 years ago

JianghuiDu commented 3 years ago

Is there a function to update the ILU preconditioner inplace?

haampie commented 3 years ago

How do you mean exactly?

JianghuiDu commented 3 years ago

If the preconditioner changes during iteration then you would want to preallocate the preconditioner and then do in place update later. The Preconditioners.jl package does this for AMG using UpdatePreconditioner!(p, A) where p is the preallocated preconditioner and A is the preconditioner matrix that will be updated during iteration. Same thing in package ILUZero where you update the preconditioner using ilu0!(LU, A) where preconditioner LU is preallocated.

Is the sparsity pattern of ILU constant with fixed drop tolerance? If yes then maybe it is possible to do in place update?

haampie commented 3 years ago

Ah no, the sparsity pattern depends on the matrix entries, so preallocation is not applicable.

Although maybe it is possible to update using the same sparsity pattern later and just disregard the drop tolerance criterion then. But then the updated preconditioner is not the same one you would get from rerunning ilu on the new matrix. I don't think this functionality should be part of this package though, basically it would be doing an approximate LU within the fixed sparsity pattern generated ahead of time by this package.

haampie commented 3 years ago

By the way, just noticed you are at ETH too, feel free to ping me on Slack (https://julialang.org/slack/) either in the #linear-algebra channel or direct message if you want to discuss your use case further

JianghuiDu commented 3 years ago

Cool thank! I think the usage is rather common. When we solve nonlinear equations the Jacobian changes over iterations and the preconditioner should change with it. If we can't pre-allocate the preconditioner then it would take many memory allocations. Maybe that's the advantage of ILU(k) where you know the sparsity pattern.