From 6302183501e206c9520dea83ed70557869a207eb Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Tue, 22 Aug 2023 12:45:47 -0400 Subject: [PATCH] Add a test with Left Preconditioner --- test/basictests.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/basictests.jl b/test/basictests.jl index a37b753f3..1ab2fbaee 100644 --- a/test/basictests.jl +++ b/test/basictests.jl @@ -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 @@ -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