@@ -226,11 +226,11 @@ Abstract Type for all NonlinearSolveBase Caches.
226226### Interface Functions
227227
228228 - `get_fu(cache)`: get the residual.
229+
229230 - `get_u(cache)`: get the current state.
230231 - `set_fu!(cache, fu)`: set the residual.
231232 - `has_time_limit(cache)`: whether or not the solver has a maximum time limit.
232233 - `not_terminated(cache)`: whether or not the solver has terminated.
233-
234234 - `SciMLBase.set_u!(cache, u)`: set the current state.
235235 - `SciMLBase.reinit!(cache, u0; kwargs...)`: reinitialize the cache with the initial state
236236 `u0` and any additional keyword arguments.
@@ -339,3 +339,170 @@ Abstract Type for all Jacobian Caches used in NonlinearSolveBase. Subtypes of th
339339meant to be constructured via [`construct_jacobian_cache`](@ref).
340340"""
341341abstract type AbstractJacobianCache <: AbstractNonlinearSolveBaseAPI end
342+
343+ """
344+ AbstractApproximateJacobianStructure
345+
346+ Abstract Type for all Approximate Jacobian Structures used in NonlinearSolve.jl.
347+
348+ ### Interface Functions
349+
350+ - `stores_full_jacobian(alg)`: whether or not the algorithm stores the full Jacobian.
351+ Defaults to `false`.
352+ - `get_full_jacobian(cache, alg, J)`: get the full Jacobian. Defaults to throwing an
353+ error if `stores_full_jacobian(alg)` is `false`.
354+ """
355+ abstract type AbstractApproximateJacobianStructure <: AbstractNonlinearSolveBaseAPI end
356+
357+ stores_full_jacobian (:: AbstractApproximateJacobianStructure ) = false
358+ function get_full_jacobian (cache, alg:: AbstractApproximateJacobianStructure , J)
359+ stores_full_jacobian (alg) && return J
360+ error (" This algorithm does not store the full Jacobian. Define `get_full_jacobian` for \
361+ this algorithm." )
362+ end
363+
364+ """
365+ AbstractJacobianInitialization
366+
367+ Abstract Type for all Jacobian Initialization Algorithms used in NonlinearSolveBase.
368+
369+ ### Interface Functions
370+
371+ - `jacobian_initialized_preinverted(alg)`: whether or not the Jacobian is initialized
372+ preinverted. Defaults to `false`.
373+
374+ ### `InternalAPI.init` specification
375+
376+ ```julia
377+ InternalAPI.init(
378+ prob::AbstractNonlinearProblem, alg::AbstractJacobianInitialization, solver,
379+ f, fu, u, p;
380+ linsolve = missing, internalnorm::IN = L2_NORM, kwargs...
381+ )::AbstractJacobianCache
382+ ```
383+
384+ All subtypes need to define
385+ `(cache::AbstractJacobianCache)(alg::NewSubType, fu, u)` which reinitializes the Jacobian in
386+ `cache.J`.
387+ """
388+ abstract type AbstractJacobianInitialization <: AbstractNonlinearSolveBaseAPI end
389+
390+ jacobian_initialized_preinverted (:: AbstractJacobianInitialization ) = false
391+
392+ """
393+ AbstractApproximateJacobianUpdateRule
394+
395+ Abstract Type for all Approximate Jacobian Update Rules used in NonlinearSolveBase.
396+
397+ ### Interface Functions
398+
399+ - `store_inverse_jacobian(alg)`: Return `alg.store_inverse_jacobian`
400+
401+ ### `InternalAPI.init` specification
402+
403+ ```julia
404+ InternalAPI.init(
405+ prob::AbstractNonlinearProblem, alg::AbstractApproximateJacobianUpdateRule, J, fu, u,
406+ du, args...; internalnorm = L2_NORM, kwargs...
407+ )::AbstractApproximateJacobianUpdateRuleCache
408+ ```
409+ """
410+ abstract type AbstractApproximateJacobianUpdateRule <: AbstractNonlinearSolveBaseAPI end
411+
412+ function store_inverse_jacobian (rule:: AbstractApproximateJacobianUpdateRule )
413+ return rule. store_inverse_jacobian
414+ end
415+
416+ """
417+ AbstractApproximateJacobianUpdateRuleCache
418+
419+ Abstract Type for all Approximate Jacobian Update Rule Caches used in NonlinearSolveBase.
420+
421+ ### Interface Functions
422+
423+ - `store_inverse_jacobian(cache)`: Return `store_inverse_jacobian(cache.rule)`
424+
425+ ### `InternalAPI.solve!` specification
426+
427+ ```julia
428+ InternalAPI.solve!(
429+ cache::AbstractApproximateJacobianUpdateRuleCache, J, fu, u, du; kwargs...
430+ ) --> J / J⁻¹
431+ ```
432+ """
433+ abstract type AbstractApproximateJacobianUpdateRuleCache <: AbstractNonlinearSolveBaseAPI end
434+
435+ function store_inverse_jacobian (cache:: AbstractApproximateJacobianUpdateRuleCache )
436+ return store_inverse_jacobian (cache. rule)
437+ end
438+
439+ """
440+ AbstractResetCondition
441+
442+ Condition for resetting the Jacobian in Quasi-Newton's methods.
443+
444+ ### `InternalAPI.init` specification
445+
446+ ```julia
447+ InternalAPI.init(
448+ alg::AbstractResetCondition, J, fu, u, du, args...; kwargs...
449+ )::AbstractResetConditionCache
450+ ```
451+ """
452+ abstract type AbstractResetCondition <: AbstractNonlinearSolveBaseAPI end
453+
454+ """
455+ AbstractResetConditionCache
456+
457+ Abstract Type for all Reset Condition Caches used in NonlinearSolveBase.
458+
459+ ### `InternalAPI.solve!` specification
460+
461+ ```julia
462+ InternalAPI.solve!(
463+ cache::AbstractResetConditionCache, J, fu, u, du; kwargs...
464+ )::Bool
465+ ```
466+ """
467+ abstract type AbstractResetConditionCache <: AbstractNonlinearSolveBaseAPI end
468+
469+ """
470+ AbstractTrustRegionMethod
471+
472+ Abstract Type for all Trust Region Methods used in NonlinearSolveBase.
473+
474+ ### `InternalAPI.init` specification
475+
476+ ```julia
477+ InternalAPI.init(
478+ prob::AbstractNonlinearProblem, alg::AbstractTrustRegionMethod, f, fu, u, p, args...;
479+ internalnorm = L2_NORM, kwargs...
480+ )::AbstractTrustRegionMethodCache
481+ ```
482+ """
483+ abstract type AbstractTrustRegionMethod <: AbstractNonlinearSolveBaseAPI end
484+
485+ """
486+ AbstractTrustRegionMethodCache
487+
488+ Abstract Type for all Trust Region Method Caches used in NonlinearSolveBase.
489+
490+ ### Interface Functions
491+
492+ - `last_step_accepted(cache)`: whether or not the last step was accepted. Defaults to
493+ `cache.last_step_accepted`. Should if overloaded if the field is not present.
494+
495+ ### `InternalAPI.solve!` specification
496+
497+ ```julia
498+ InternalAPI.solve!(
499+ cache::AbstractTrustRegionMethodCache, J, fu, u, δu, descent_stats; kwargs...
500+ )
501+ ```
502+
503+ Returns `last_step_accepted`, updated `u_cache` and `fu_cache`. If the last step was
504+ accepted then these values should be copied into the toplevel cache.
505+ """
506+ abstract type AbstractTrustRegionMethodCache <: AbstractNonlinearSolveBaseAPI end
507+
508+ last_step_accepted (cache:: AbstractTrustRegionMethodCache ) = cache. last_step_accepted
0 commit comments