run_newton Subroutine

private subroutine run_newton(st, ub_n_loc, ub_nm1_loc, c_resid, hist_c1, hist_c2, scheme_label, n_dof_loc, kl_loc, ku_loc, ldab_loc, diag_row_loc, ab_loc, rhs_loc, dq_loc, resid_base_loc, resid_pert_loc)

Shared Newton + banded-solve inner loop for the implicit steppers.

Solves A·ΔQ = c_resid·dt·R(Q^k) - ((Q^k - c1·Q_n) + c2·Q_{n-1}), A = I - c_resid·dt·J, iterating Q^{k+1}=Q^k+ΔQ up to n_newton times with a column-wise FD Jacobian. The history coefficients select the scheme: * backward Euler : c_resid=1, c1=1, c2=0 (Q_{n-1} unused) * BDF2 : c_resid=2/3, c1=4/3, c2=1/3 The fixed assembly order (Q^k - c1·Q_n) + c2·Q_{n-1} reproduces both callers' previous arithmetic bit-for-bit (·1.0 and +0.0 are exact in IEEE). Operates entirely on st%ub / st%resid; the caller owns the band geometry and the ab/rhs/dq/resid scratch. Does NOT call compute_resid_glob.

Arguments

Type IntentOptional Attributes Name
type(solver_state_t), intent(inout) :: st
real(kind=wp), intent(in) :: ub_n_loc(neq,st%n_pt)
real(kind=wp), intent(in) :: ub_nm1_loc(neq,st%n_pt)
real(kind=wp), intent(in) :: c_resid
real(kind=wp), intent(in) :: hist_c1
real(kind=wp), intent(in) :: hist_c2
character(len=*), intent(in) :: scheme_label
integer, intent(in) :: n_dof_loc
integer, intent(in) :: kl_loc
integer, intent(in) :: ku_loc
integer, intent(in) :: ldab_loc
integer, intent(in) :: diag_row_loc
real(kind=wp), intent(inout) :: ab_loc(ldab_loc,n_dof_loc)
real(kind=wp), intent(inout) :: rhs_loc(n_dof_loc)
real(kind=wp), intent(inout) :: dq_loc(n_dof_loc)
real(kind=wp), intent(inout) :: resid_base_loc(n_dof_loc)
real(kind=wp), intent(inout) :: resid_pert_loc(n_dof_loc)