-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with BlockArrays #605
Comments
HI @lijas!
But in that case, Krylov.jl should just use basic vectors (same problem in #573) and we just need to define
For the preconditioner, it's a good idea to use a block diagonal preconditioner like you suggest with an incomplete LU of
We can also define something like this to still use
Input and output vectors |
If you are able to compute a complete factorization of |
Hi! I also needed to remove type annotation of Doing these two changes, I was able to get a small BlockArray system to pass the solver and converge (I have no idea if it is the correct answer though 😄 ). So with a bit of work it would be quite easy (I think) to have compatibility with BlockArrays. However, a bigger question is if it is worth It? It seems like iterative solvers + block arrays is a pretty uncommon thing to do... I cant really find that much information about it when searching for it. I mainly wanted it in order to to design the preconditioner in a better way, but perhaps there are better ways of doing that? Another big issue is that matrix-vector multiplication in BlockArrays is extremely slow for some reason. I have know idea why, but that would need to fixed in BlockArrays as a first step. Regarding the TriMR solver. I dont quite understand the use of it..The main point of using iterative solvers is when factorization of the |
The issue with I will find a way to support For |
Ahh, it makes sense to not use |
1364: Refactor SchurComplementW for ClimaTimesteppers r=charleskawczynski a=charleskawczynski This PR is a peel off from #1358. This PR adds `temp1` and `temp2` to `SchurComplementW`, and defines ```julia linsolve!(::Type{Val{:init}}, f, u0; kwargs...) = _linsolve! _linsolve!(x, A, b, update_matrix = false; kwargs...) = LinearAlgebra.ldiv!(x, A, b) # Function required by Krylov.jl (x and b can be AbstractVectors) # See JuliaSmoothOptimizers/Krylov.jl#605 for a # related issue that requires the same workaround. function LinearAlgebra.ldiv!(x, A::SchurComplementW, b) A.temp1 .= b LinearAlgebra.ldiv!(A.temp2, A, A.temp1) x .= A.temp2 end ``` and the original `_linsolve` contents are in ```julia function LinearAlgebra.ldiv!( x::Fields.FieldVector, A::SchurComplementW, b::Fields.FieldVector, ) ``` (the pattern used in ClimaAtmos). It also renames `_linsolve!` to `test_linsolve!` to avoid a name collision in the test suite. It's a much smaller PR than it appears, due to indenting. Co-authored-by: Charles Kawczynski <[email protected]>
1364: Refactor SchurComplementW for ClimaTimesteppers r=charleskawczynski a=charleskawczynski This PR is a peel off from #1358. This PR adds `temp1` and `temp2` to `SchurComplementW`, and defines ```julia linsolve!(::Type{Val{:init}}, f, u0; kwargs...) = _linsolve! _linsolve!(x, A, b, update_matrix = false; kwargs...) = LinearAlgebra.ldiv!(x, A, b) # Function required by Krylov.jl (x and b can be AbstractVectors) # See JuliaSmoothOptimizers/Krylov.jl#605 for a # related issue that requires the same workaround. function LinearAlgebra.ldiv!(x, A::SchurComplementW, b) A.temp1 .= b LinearAlgebra.ldiv!(A.temp2, A, A.temp1) x .= A.temp2 end ``` and the original `_linsolve` contents are in ```julia function LinearAlgebra.ldiv!( x::Fields.FieldVector, A::SchurComplementW, b::Fields.FieldVector, ) ``` (the pattern used in ClimaAtmos). It also renames `_linsolve!` to `test_linsolve!` to avoid a name collision in the test suite. It's a much smaller PR than it appears, due to indenting. Co-authored-by: Charles Kawczynski <[email protected]>
I have a linear system in the form: A = [K C'; C, 0], (C is relatively small) which requires a large amount of iterations with minres/gmres in order to converge. There is no "out of the box" preconditioner that helps with lowering the amount of iterations.
I dont know if this is the best way, but a few tutorials suggests creating a custom preconditioner, P^-1 = [ilu(K) 0; 0 C'*inv(diag(K))*C] or something similar (perhaps there is a better preconditioner for this case), for which you preferable want to use BlockArrays and overload
ldiv!
in for your costum preconditier:This is the error you get if you try to use BlockArrays+Krylov:
I dont know if this is an issue that should be solved in BlockArrays or in this package.
The text was updated successfully, but these errors were encountered: