@@ -394,20 +394,31 @@ function newton_krylov!(
394394 kwargs = (; M = M (J), kwargs... )
395395 end
396396 if forcing != = nothing
397- # ‖F′(u)d + F(u)‖ <= η * ‖F(u)‖ Inexact Newton termination
398- kwargs = (; rtol = η, kwargs... )
397+ # The termination cirterion of the inner Krylov solver is
398+ # ‖F′(u) d + F(u)‖ <= η ‖F(u)‖
399+ # i.e., we use an inexact Newton method. Since the initial
400+ # guess of the Krylov solver is zero, we set an absolute
401+ # tolerance of `atol = 0` and a relative tolerance of
402+ # `rtol = η`.
403+ # Since the user-provided `kwargs` are appended at the end,
404+ # the user can override these settings.
405+ kwargs = (; atol = zero (η), rtol = η, kwargs... )
399406 end
400407
401- # Solve: Jx = -res
402- # res is modified by J, so we create a copy `-res`
403- # TODO : provide a temporary storage for `-res`
408+ # Solve: J d = res = F(u)
409+ # Typically, the Newton method is formulated as J d = -F(u)
410+ # with update u = u + d.
411+ # To simplify the implementation, we solve J d = F(u)
412+ # and update u = u - d instead.
413+ # `res` is modified by J, so we create a copy `res`
414+ # TODO : provide a temporary storage for `res`
404415 krylov_solve! (workspace, J, copy (res); kwargs... )
405416
406- d = workspace. x # Newton direction
407- s = 1 # Newton step TODO : LineSearch
417+ d = workspace. x # (negative) Newton direction
418+ s = 1 # Scaling of the Newton step TODO : LineSearch
408419
409420 # Update u
410- u .- = s . * d
421+ u .= muladd .( - s, d, u) # u = u - s * d
411422
412423 # Update residual and norm
413424 n_res_prior = n_res
0 commit comments