Skip to content

Commit

Permalink
Add a test with Left Preconditioner
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Aug 22, 2023
1 parent 913231f commit 6302183
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/basictests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ sol = benchmark_scalar(sf, csu0)
# @test (@ballocated benchmark_mutable(ff, cu0)) < 200
# @test (@ballocated benchmark_scalar(sf, csu0)) < 400

function benchmark_inplace(f, u0, linsolve)
function benchmark_inplace(f, u0, linsolve, precs)
probN = NonlinearProblem{true}(f, u0)
solver = init(probN, NewtonRaphson(; linsolve), abstol = 1e-9)
solver = init(probN, NewtonRaphson(; linsolve, precs), abstol = 1e-9)
sol = solve!(solver)
end

Expand All @@ -58,8 +58,13 @@ function ffiip(du, u, p)
end
u0 = [1.0, 1.0]

for linsolve in (nothing, KrylovJL_GMRES())
sol = benchmark_inplace(ffiip, u0, linsolve)
precs = [
NonlinearSolve.DEFAULT_PRECS,
(args...) -> (Diagonal(rand!(similar(u0))), nothing)
]

for prec in precs, linsolve in (nothing, KrylovJL_GMRES())
sol = benchmark_inplace(ffiip, u0, linsolve, prec)
@test sol.retcode === ReturnCode.Success
@test all(abs.(sol.u .* sol.u .- 2) .< 1e-9)
end
Expand Down

0 comments on commit 6302183

Please sign in to comment.