Skip to content

Commit

Permalink
Deal with ILU
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Apr 26, 2024
1 parent 2d1a718 commit e0959a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "0.1.0"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down
1 change: 1 addition & 0 deletions src/DiffKrylov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module DiffKrylov
using Krylov
using SparseArrays
using LinearAlgebra
using IncompleteLU
include("ForwardDiff/forwarddiff.jl")
include("EnzymeRules/enzymerules.jl")
end
11 changes: 10 additions & 1 deletion src/EnzymeRules/enzymerules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,16 @@ for AMT in (:Matrix, :SparseMatrixCSC)
if verbose > 0
@info "($psolver, $pamt) reverse"
end
_b.dval .= Krylov.$solver(transpose(A), bx[]; M=M, N=N, verbose=verbose, options...)[1]
N = M
M = N
if isa(M, IncompleteLU.ILUFactorization)
U = copy(M.U)
L = copy(M.L)
transpose!(U, M.L)
transpose!(L, M.U)
N = IncompleteLU.ILUFactorization(L, U)
end
_b.dval .= Krylov.$solver(adjoint(A), bx[]; M=M, N=N, verbose=verbose, options...)[1]
_A.dval .= -x .* _b.dval'
return (nothing, nothing)
end
Expand Down

0 comments on commit e0959a1

Please sign in to comment.