Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/NonlinearSolveBase/src/termination_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ function SciMLBase.reinit!(
length(saved_value_prototype) != 0 && (cache.saved_values = saved_value_prototype)

mode = cache.mode
if u isa Number || !ArrayInterface.can_setindex(u)
cache.u = u
else
cache.u .= u
if cache.u !== nothing
if u isa Number || !ArrayInterface.can_setindex(u)
cache.u = u
else
cache.u .= u
end
end
cache.retcode = ReturnCode.Default

Expand Down
16 changes: 16 additions & 0 deletions lib/NonlinearSolveBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,20 @@ using InteractiveUtils, Test

@test NonlinearSolveBase.Utils.faster_vcat(b, d) == vcat(sparse(b), d)
end

@testset "Termination Conditions" begin
using NonlinearSolveBase, SciMLBase
@testset "reinit! with AbsTerminationMode" begin
mode = NonlinearSolveBase.AbsTerminationMode()
u_unaliased = nothing
T = Float64
cache = NonlinearSolveBase.NonlinearTerminationModeCache(
u_unaliased, SciMLBase.ReturnCode.Default, 1e-8, 1e-8, Inf, mode,
nothing, nothing, 0, nothing, nothing, nothing, nothing, nothing, false
)
du = [1.0, 1.0]
u = [1.1, 1.1]
@test_nowarn SciMLBase.reinit!(cache, du, u)
end
end
end
Loading