Skip to content

Commit 71f3bbc

Browse files
committed
Fix storing the trace
1 parent 5b14b20 commit 71f3bbc

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

src/trace.jl

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function __init_trace_history(::Val{show_trace}, trace_level, ::Val{store_trace}
184184
!store_trace && !show_trace && return nothing
185185
entry = __trace_entry(trace_level, 0, u, fu, J, δu)
186186
show_trace && show(entry)
187-
store_trace && return [entry]
187+
store_trace && return NonlinearSolveTraceEntry[entry]
188188
return nothing
189189
end
190190

@@ -218,29 +218,6 @@ function update_trace!(trace::NonlinearSolveTrace{ShT, StT}, iter, u, fu, J, δu
218218
return trace
219219
end
220220

221-
# Needed for Algorithms which directly use `inv(J)` instead of `J`
222-
function update_trace_with_invJ!(trace::NonlinearSolveTrace{ShT, StT}, iter, u, fu, J, δu,
223-
α = 1; last::Val{L} = Val(false)) where {ShT, StT, L}
224-
!StT && !ShT && return nothing
225-
226-
if L
227-
entry = NonlinearSolveTraceEntry(-1, norm(fu, Inf), NaN32, nothing, nothing,
228-
nothing, nothing, nothing)
229-
show(entry)
230-
return trace
231-
end
232-
233-
show_now = ShT && (mod1(iter, trace.trace_level.print_frequency) == 1)
234-
store_now = StT && (mod1(iter, trace.trace_level.store_frequency) == 1)
235-
if show_now || store_now
236-
J_ = trace.trace_level isa TraceMinimal ? J : inv(J)
237-
entry = __trace_entry(trace.trace_level, iter, u, fu, J_, δu, α)
238-
end
239-
store_now && push!(trace.history, entry)
240-
show_now && show(entry)
241-
return trace
242-
end
243-
244221
function update_trace!(cache::AbstractNonlinearSolveCache, α = true)
245222
trace = __getproperty(cache, Val(:trace))
246223
trace === nothing && return nothing
@@ -252,8 +229,8 @@ function update_trace!(cache::AbstractNonlinearSolveCache, α = true)
252229
update_trace!(trace, cache.stats.nsteps + 1, get_u(cache), get_fu(cache),
253230
nothing, cache.du, α)
254231
else
255-
update_trace_with_invJ!(trace, cache.stats.nsteps + 1, get_u(cache),
256-
get_fu(cache), J_inv, cache.du, α)
232+
update_trace!(trace, cache.stats.nsteps + 1, get_u(cache), get_fu(cache),
233+
ApplyArray(inv, J_inv), cache.du, α)
257234
end
258235
else
259236
update_trace!(trace, cache.stats.nsteps + 1, get_u(cache), get_fu(cache), J,

0 commit comments

Comments
 (0)