@@ -114,39 +114,41 @@ const error_control_options = (:dt_NaN, :init_NaN, :dense_output_saveat, :max_it
114114const performance_options = (:alg_switch , :stiff_detection , :mismatched_input_output_type , :jacobian_update , :w_factorization , :newton_iterations )
115115const numerical_options = (:rosenbrock_no_differential_states , :shampine_dt , :unlimited_dt , :dt_epsilon , :stability_check , :near_singular )
116116
117- function option_group (option:: Symbol )
118- if option in error_control_options
119- return :error_control
120- elseif option in performance_options
121- return :performance
122- elseif option in numerical_options
123- return :numerical
124- else
125- error (" Unknown verbosity option: $option " )
126- end
127- end
128-
129- # Get all options in a group
130- function group_options (verbosity:: ODEVerbosity , group:: Symbol )
131- if group === :error_control
132- return NamedTuple {error_control_options} (getproperty (verbosity, opt)
133- for opt in error_control_options)
134- elseif group === :performance
135- return NamedTuple {performance_options} (getproperty (verbosity, opt)
136- for opt in performance_options)
137- elseif group === :numerical
138- return NamedTuple {numerical_options} (getproperty (verbosity, opt)
139- for opt in numerical_options)
140- else
141- error (" Unknown group: $group " )
142- end
143- end
144-
145-
146117function ODEVerbosity (;
147118 error_control = nothing , performance = nothing , numerical = nothing ,
148119 linear_verbosity = nothing , nonlinear_verbosity = nothing , kwargs... )
149120 # Validate group arguments
121+
122+ if error_control === nothing && performance === nothing && numerical === nothing &&
123+ linear_verbosity === nothing && nonlinear_verbosity === nothing && isempty (kwargs)
124+ return ODEVerbosity (
125+ linear_verbosity = Minimal (),
126+ nonlinear_verbosity = Minimal (),
127+ dt_NaN = WarnLevel (),
128+ init_NaN = WarnLevel (),
129+ dense_output_saveat = WarnLevel (),
130+ max_iters = WarnLevel (),
131+ dt_min_unstable = WarnLevel (),
132+ instability = WarnLevel (),
133+ newton_convergence = Silent (),
134+ step_rejected = Silent (),
135+ step_accepted = Silent (),
136+ convergence_limit = Silent (),
137+ alg_switch = Silent (),
138+ stiff_detection = Silent (),
139+ mismatched_input_output_type = WarnLevel (),
140+ jacobian_update = Silent (),
141+ w_factorization = Silent (),
142+ newton_iterations = Silent (),
143+ rosenbrock_no_differential_states = WarnLevel (),
144+ shampine_dt = Silent (),
145+ unlimited_dt = WarnLevel (),
146+ dt_epsilon = Silent (),
147+ stability_check = Silent (),
148+ near_singular = Silent ()
149+ )
150+ end
151+
150152 if error_control != = nothing && ! (error_control isa AbstractMessageLevel)
151153 throw (ArgumentError (" error_control must be a SciMLLogging.AbstractMessageLevel, got $(typeof (error_control)) " ))
152154 end
@@ -196,13 +198,37 @@ function ODEVerbosity(;
196198 near_singular = Silent ()
197199 )
198200
199- # Apply group-level settings
201+ # Apply group-level settings - done explicitly for type stability
200202 final_args = if error_control != = nothing || performance != = nothing ||
201203 numerical != = nothing
202- NamedTuple {keys(default_args)} (
203- _resolve_arg_value (
204- key, default_args[key], error_control, performance, numerical)
205- for key in keys (default_args)
204+ (
205+ linear_verbosity = default_args. linear_verbosity,
206+ nonlinear_verbosity = default_args. nonlinear_verbosity,
207+ # Error control group
208+ dt_NaN = error_control != = nothing ? error_control : default_args. dt_NaN,
209+ init_NaN = error_control != = nothing ? error_control : default_args. init_NaN,
210+ dense_output_saveat = error_control != = nothing ? error_control : default_args. dense_output_saveat,
211+ max_iters = error_control != = nothing ? error_control : default_args. max_iters,
212+ dt_min_unstable = error_control != = nothing ? error_control : default_args. dt_min_unstable,
213+ instability = error_control != = nothing ? error_control : default_args. instability,
214+ newton_convergence = error_control != = nothing ? error_control : default_args. newton_convergence,
215+ step_rejected = error_control != = nothing ? error_control : default_args. step_rejected,
216+ step_accepted = error_control != = nothing ? error_control : default_args. step_accepted,
217+ convergence_limit = error_control != = nothing ? error_control : default_args. convergence_limit,
218+ # Performance group
219+ alg_switch = performance != = nothing ? performance : default_args. alg_switch,
220+ stiff_detection = performance != = nothing ? performance : default_args. stiff_detection,
221+ mismatched_input_output_type = performance != = nothing ? performance : default_args. mismatched_input_output_type,
222+ jacobian_update = performance != = nothing ? performance : default_args. jacobian_update,
223+ w_factorization = performance != = nothing ? performance : default_args. w_factorization,
224+ newton_iterations = performance != = nothing ? performance : default_args. newton_iterations,
225+ # Numerical group
226+ rosenbrock_no_differential_states = numerical != = nothing ? numerical : default_args. rosenbrock_no_differential_states,
227+ shampine_dt = numerical != = nothing ? numerical : default_args. shampine_dt,
228+ unlimited_dt = numerical != = nothing ? numerical : default_args. unlimited_dt,
229+ dt_epsilon = numerical != = nothing ? numerical : default_args. dt_epsilon,
230+ stability_check = numerical != = nothing ? numerical : default_args. stability_check,
231+ near_singular = numerical != = nothing ? numerical : default_args. near_singular
206232 )
207233 else
208234 default_args
222248function ODEVerbosity (verbose:: AbstractVerbosityPreset )
223249 if verbose isa Minimal
224250 # Minimal: Only fatal errors and critical warnings
225- ODEVerbosity (
251+ return ODEVerbosity (
226252 linear_verbosity = Minimal (),
227253 nonlinear_verbosity = Minimal (),
228254 dt_NaN = WarnLevel (),
@@ -250,10 +276,10 @@ function ODEVerbosity(verbose::AbstractVerbosityPreset)
250276 )
251277 elseif verbose isa Standard
252278 # Standard: Everything from Minimal + non-fatal warnings
253- ODEVerbosity ()
279+ return ODEVerbosity ()
254280 elseif verbose isa Detailed
255281 # Detailed: Everything from Standard + debugging/solver behavior
256- ODEVerbosity (
282+ return ODEVerbosity (
257283 linear_verbosity = Detailed (),
258284 nonlinear_verbosity = Detailed (),
259285 dt_NaN = WarnLevel (),
@@ -281,7 +307,7 @@ function ODEVerbosity(verbose::AbstractVerbosityPreset)
281307 )
282308 elseif verbose isa All
283309 # All: Maximum verbosity - every possible logging message at InfoLevel
284- ODEVerbosity (
310+ return ODEVerbosity (
285311 linear_verbosity = All (),
286312 nonlinear_verbosity = All (),
287313 dt_NaN = WarnLevel (),
338364 Silent ()
339365 )
340366end
341-
342- # Helper function to resolve argument values based on group membership
343- @inline function _resolve_arg_value (
344- key:: Symbol , default_val, error_control, performance, numerical)
345- if key === :linear_verbosity || key === :nonlinear_verbosity
346- return default_val
347- elseif key in error_control_options && error_control != = nothing
348- return error_control
349- elseif key in performance_options && performance != = nothing
350- return performance
351- elseif key in numerical_options && numerical != = nothing
352- return numerical
353- else
354- return default_val
355- end
356- end
0 commit comments