From 71e9806ab027a3efb16b82628a34d54aef255157 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 31 Oct 2024 15:27:53 -0400 Subject: [PATCH] test: precs need concrete jacobian --- docs/src/tutorials/large_systems.md | 2 +- .../test/rootfind_tests.jl | 42 ++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/docs/src/tutorials/large_systems.md b/docs/src/tutorials/large_systems.md index ae8ed7acd..434acb185 100644 --- a/docs/src/tutorials/large_systems.md +++ b/docs/src/tutorials/large_systems.md @@ -274,7 +274,7 @@ which is more automatic. The setup is very similar to before: using AlgebraicMultigrid function algebraicmultigrid(W, p = nothing) - return aspreconditioner(ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I + return aspreconditioner(ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I end @btime solve(prob_brusselator_2d_sparse, diff --git a/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl b/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl index b352febaf..3aa61b256 100644 --- a/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl +++ b/lib/NonlinearSolveFirstOrder/test/rootfind_tests.jl @@ -38,17 +38,22 @@ end @testset "[IIP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0],) ad isa AutoZygote && continue - @testset for linsolve in ( - nothing, - KrylovJL_GMRES(; precs = nothing), - KrylovJL_GMRES(; - precs = (A, p = nothing) -> ( - Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I + @testset for (concrete_jac, linsolve) in ( + (Val(false), nothing), + (Val(false), KrylovJL_GMRES(; precs = nothing)), + ( + Val(true), + KrylovJL_GMRES(; + precs = (A, p = nothing) -> ( + Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I + ) ) ), - \ + (Val(false), \) ) - solver = NewtonRaphson(; linsolve, linesearch, autodiff = ad) + solver = NewtonRaphson(; + linsolve, linesearch, autodiff = ad, concrete_jac + ) sol = solve_iip(quadratic_f!, u0; solver) @test SciMLBase.successful_retcode(sol) @@ -114,17 +119,22 @@ end @testset "[IIP] u0: $(typeof(u0))" for u0 in ([1.0, 1.0],) ad isa AutoZygote && continue - @testset for linsolve in ( - nothing, - KrylovJL_GMRES(; precs = nothing), - KrylovJL_GMRES(; - precs = (A, p = nothing) -> ( - Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I + @testset for (concrete_jac, linsolve) in ( + (Val(false), nothing), + (Val(false), KrylovJL_GMRES(; precs = nothing)), + ( + Val(true), + KrylovJL_GMRES(; + precs = (A, p = nothing) -> ( + Diagonal(randn!(similar(A, size(A, 1)))), LinearAlgebra.I + ) ) ), - \ + (Val(false), \) ) - solver = PseudoTransient(; alpha_initial = 10.0, linsolve, autodiff = ad) + solver = PseudoTransient(; + alpha_initial = 10.0, linsolve, autodiff = ad, concrete_jac + ) sol = solve_iip(quadratic_f!, u0; solver) @test SciMLBase.successful_retcode(sol) err = maximum(abs, quadratic_f(sol.u, 2.0))