9595 inv_workspace
9696
9797 # Counters
98- nf :: Int
98+ stats :: NLStats
9999 nsteps:: Int
100100 nresets:: Int
101101 max_resets:: Int
@@ -131,7 +131,7 @@ function __reinit_internal!(cache::ApproximateJacobianSolveCache{INV, GB, iip},
131131 end
132132 cache. p = p
133133
134- cache. nf = 1
134+ __reinit_internal! ( cache. stats)
135135 cache. nsteps = 0
136136 cache. nresets = 0
137137 cache. steps_since_last_reset = 0
151151
152152function SciMLBase. __init (
153153 prob:: AbstractNonlinearProblem{uType, iip} , alg:: ApproximateJacobianSolveAlgorithm ,
154- args... ; alias_u0 = false , maxtime = nothing , maxiters = 1000 , abstol = nothing ,
155- reltol = nothing , linsolve_kwargs = (;), termination_condition = nothing ,
154+ args... ; stats = empty_nlstats (), alias_u0 = false , maxtime = nothing ,
155+ maxiters = 1000 , abstol = nothing , reltol = nothing ,
156+ linsolve_kwargs = (;), termination_condition = nothing ,
156157 internalnorm:: F = DEFAULT_NORM, kwargs... ) where {uType, iip, F}
157158 timer = get_timer_output ()
158159 @static_timeit timer " cache construction" begin
@@ -165,7 +166,7 @@ function SciMLBase.__init(
165166
166167 linsolve = get_linear_solver (alg. descent)
167168 initialization_cache = __internal_init (
168- prob, alg. initialization, alg, f, fu, u, p; linsolve, maxiters, internalnorm)
169+ prob, alg. initialization, alg, f, fu, u, p; stats, linsolve, maxiters, internalnorm)
169170
170171 abstol, reltol, termination_cache = init_termination_cache (
171172 prob, abstol, reltol, fu, u, termination_condition)
@@ -174,7 +175,7 @@ function SciMLBase.__init(
174175 J = initialization_cache (nothing )
175176 inv_workspace, J = INV ? __safe_inv_workspace (J) : (nothing , J)
176177 descent_cache = __internal_init (
177- prob, alg. descent, J, fu, u; abstol, reltol, internalnorm,
178+ prob, alg. descent, J, fu, u; stats, abstol, reltol, internalnorm,
178179 linsolve_kwargs, pre_inverted = Val (INV), timer)
179180 du = get_du (descent_cache)
180181
@@ -192,28 +193,28 @@ function SciMLBase.__init(
192193 supports_trust_region (alg. descent) || error (" Trust Region not supported by \
193194 $(alg. descent) ." )
194195 trustregion_cache = __internal_init (
195- prob, alg. trustregion, f, fu, u, p; internalnorm, kwargs... )
196+ prob, alg. trustregion, f, fu, u, p; stats, internalnorm, kwargs... )
196197 GB = :TrustRegion
197198 end
198199
199200 if alg. linesearch != = missing
200201 supports_line_search (alg. descent) || error (" Line Search not supported by \
201202 $(alg. descent) ." )
202203 linesearch_cache = __internal_init (
203- prob, alg. linesearch, f, fu, u, p; internalnorm, kwargs... )
204+ prob, alg. linesearch, f, fu, u, p; stats, internalnorm, kwargs... )
204205 GB = :LineSearch
205206 end
206207
207208 update_rule_cache = __internal_init (
208- prob, alg. update_rule, J, fu, u, du; internalnorm)
209+ prob, alg. update_rule, J, fu, u, du; stats, internalnorm)
209210
210211 trace = init_nonlinearsolve_trace (prob, alg, u, fu, ApplyArray (__zero, J), du;
211212 uses_jacobian_inverse = Val (INV), kwargs... )
212213
213214 return ApproximateJacobianSolveCache {INV, GB, iip, maxtime !== nothing} (
214215 fu, u, u_cache, p, du, J, alg, prob, initialization_cache,
215216 descent_cache, linesearch_cache, trustregion_cache, update_rule_cache,
216- reinit_rule_cache, inv_workspace, 0 , 0 , 0 , alg. max_resets,
217+ reinit_rule_cache, inv_workspace, stats , 0 , 0 , alg. max_resets,
217218 maxiters, maxtime, alg. max_shrink_times, 0 , timer, 0.0 ,
218219 termination_cache, trace, ReturnCode. Default, false , false , kwargs)
219220 end
@@ -223,7 +224,7 @@ function __step!(cache::ApproximateJacobianSolveCache{INV, GB, iip};
223224 recompute_jacobian:: Union{Nothing, Bool} = nothing ) where {INV, GB, iip}
224225 new_jacobian = true
225226 @static_timeit cache. timer " jacobian init/reinit" begin
226- if get_nsteps ( cache) == 0 # First Step is special ignore kwargs
227+ if cache. nsteps == 0 # First Step is special ignore kwargs
227228 J_init = __internal_solve! (
228229 cache. initialization_cache, cache. fu, cache. u, Val (false ))
229230 if INV
0 commit comments