This commit is contained in:
@@ -143,6 +143,11 @@ contains
|
||||
|
||||
iter_total = 0
|
||||
res_norm = ZERO
|
||||
convergence_cutback_count = 0
|
||||
convergence_last_dt = ZERO
|
||||
convergence_last_accepted_time = current_time
|
||||
convergence_status_code = CONVERGENCE_STATUS_ITERATING
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
|
||||
if (ndof .le. 0) then
|
||||
call error_set(FEM_ERR_SOLVER, 'nonlinear static solve requires positive ndof', ierr)
|
||||
@@ -209,6 +214,8 @@ contains
|
||||
if (ierr .eq. FEM_SUCCESS) then
|
||||
iter_total = iter_total + iter_inc
|
||||
current_time = sub_target_time
|
||||
convergence_last_accepted_time = current_time
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
current_step = current_step + 1
|
||||
dt_try = target_time - current_time
|
||||
cut_count = 0
|
||||
@@ -216,8 +223,14 @@ contains
|
||||
abs(dt_try * cutback_factor) .ge. dt_min_eff) then
|
||||
dt_try = dt_try * cutback_factor
|
||||
cut_count = cut_count + 1
|
||||
convergence_cutback_count = convergence_cutback_count + 1
|
||||
convergence_last_dt = dt_try
|
||||
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
ierr = FEM_SUCCESS
|
||||
else
|
||||
convergence_status_code = CONVERGENCE_STATUS_FAILED
|
||||
convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT
|
||||
return
|
||||
end if
|
||||
end do
|
||||
@@ -447,6 +460,7 @@ contains
|
||||
|
||||
iter_used = 0
|
||||
res_norm = ZERO
|
||||
call begin_newmark_convergence(dt)
|
||||
ref_norm = ONE
|
||||
trial_res_norm = ZERO
|
||||
trial_ref_norm = ONE
|
||||
@@ -490,8 +504,11 @@ contains
|
||||
kdamp, res_norm, ref_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
iter_used = iter
|
||||
call record_convergence_iteration(iter, res_norm, ref_norm, &
|
||||
convergence_correction_norm)
|
||||
if (res_norm .le. tol .or. res_norm / ref_norm .le. tol) then
|
||||
converged = .true.
|
||||
call mark_convergence_success()
|
||||
if (allocated(freaction)) then
|
||||
freaction = fint + mass_diag * a + damping_force - external
|
||||
end if
|
||||
@@ -503,24 +520,19 @@ contains
|
||||
call newmark_nl_solve_corr(kmat, target_time, a0, a1, residual, &
|
||||
rhs_corr, du, max_iter, tol, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
call record_convergence_correction(sqrt(sum(du * du)), res_norm, &
|
||||
ref_norm)
|
||||
|
||||
u_base = u
|
||||
if (use_line_search) then
|
||||
call nonlinear_newmark_line_search(target_time, dt, a0, a1, &
|
||||
u_pred, v_pred, u_base, du, &
|
||||
res_norm, residual, external, &
|
||||
damping_force, kdamp, &
|
||||
trial_res_norm, trial_ref_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
else
|
||||
u = u + du
|
||||
call boundary_apply_dirichlet(target_time, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
end if
|
||||
call nonlinear_newmark_apply_update(target_time, dt, a0, a1, u_pred, &
|
||||
v_pred, u_base, du, res_norm, ref_norm, residual, external, &
|
||||
damping_force, kdamp, trial_res_norm, trial_ref_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
end do
|
||||
|
||||
if (.not. converged) then
|
||||
call error_set(FEM_ERR_SOLVER, 'nonlinear Newmark Newton iteration did not converge', ierr)
|
||||
call mark_convergence_failure(CONV_FAIL_NONCONVERGENCE)
|
||||
go to 900
|
||||
end if
|
||||
|
||||
@@ -745,6 +757,46 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine nonlinear_newmark_line_search
|
||||
|
||||
subroutine nonlinear_newmark_apply_update(target_time, dt, a0, a1, &
|
||||
u_pred, v_pred, u_base, du, &
|
||||
res_norm, ref_norm, residual, &
|
||||
external, damping_force, kdamp, &
|
||||
trial_res_norm, trial_ref_norm, &
|
||||
ierr)
|
||||
real(rk), intent(in) :: target_time
|
||||
real(rk), intent(in) :: dt
|
||||
real(rk), intent(in) :: a0
|
||||
real(rk), intent(in) :: a1
|
||||
real(rk), intent(in) :: u_pred(ndof)
|
||||
real(rk), intent(in) :: v_pred(ndof)
|
||||
real(rk), intent(in) :: u_base(ndof)
|
||||
real(rk), intent(in) :: du(ndof)
|
||||
real(rk), intent(inout) :: res_norm
|
||||
real(rk), intent(inout) :: ref_norm
|
||||
real(rk), intent(inout) :: residual(ndof)
|
||||
real(rk), intent(inout) :: external(ndof)
|
||||
real(rk), intent(inout) :: damping_force(ndof)
|
||||
real(rk), intent(inout) :: kdamp(ndof)
|
||||
real(rk), intent(out) :: trial_res_norm
|
||||
real(rk), intent(out) :: trial_ref_norm
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
if (use_line_search) then
|
||||
call nonlinear_newmark_line_search(target_time, dt, a0, a1, &
|
||||
u_pred, v_pred, u_base, du, res_norm, residual, external, &
|
||||
damping_force, kdamp, trial_res_norm, trial_ref_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
call record_line_search_metrics(res_norm, ref_norm, trial_res_norm, &
|
||||
trial_ref_norm)
|
||||
else
|
||||
u = u + du
|
||||
call boundary_apply_dirichlet(target_time, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
end if
|
||||
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine nonlinear_newmark_apply_update
|
||||
|
||||
subroutine evaluate_newmark_trial_residual(target_time, dt, a0, a1, &
|
||||
u_pred, v_pred, residual, external, &
|
||||
damping_force, kdamp, res_norm, &
|
||||
@@ -852,11 +904,7 @@ contains
|
||||
trial_ref_norm = ONE
|
||||
correction_norm = ZERO
|
||||
converged = .false.
|
||||
convergence_increment = increment_id
|
||||
convergence_iteration = 0
|
||||
convergence_residual_norm = ZERO
|
||||
convergence_correction_norm = ZERO
|
||||
convergence_converged = .false.
|
||||
call begin_static_convergence(increment_id, dt_inc)
|
||||
allocate(residual(ndof), external(ndof), rhs_corr(ndof), du(ndof), &
|
||||
u_start(ndof), u_base(ndof), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
@@ -880,13 +928,11 @@ contains
|
||||
res_norm, ref_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
iter_used = iter
|
||||
convergence_iteration = iter
|
||||
convergence_residual_norm = res_norm
|
||||
convergence_correction_norm = correction_norm
|
||||
convergence_converged = .false.
|
||||
call record_convergence_iteration(iter, res_norm, ref_norm, &
|
||||
correction_norm)
|
||||
if (res_norm .le. tol .or. res_norm / ref_norm .le. tol) then
|
||||
converged = .true.
|
||||
convergence_converged = .true.
|
||||
call mark_convergence_success()
|
||||
if (allocated(freaction)) freaction = fint - external
|
||||
exit
|
||||
end if
|
||||
@@ -896,7 +942,7 @@ contains
|
||||
max_iter, tol, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
correction_norm = sqrt(sum(du * du))
|
||||
convergence_correction_norm = correction_norm
|
||||
call record_convergence_correction(correction_norm, res_norm, ref_norm)
|
||||
|
||||
u_base = u
|
||||
if (use_line_search) then
|
||||
@@ -909,6 +955,10 @@ contains
|
||||
call boundary_apply_dirichlet(target_time, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
end if
|
||||
if (use_line_search) then
|
||||
call record_line_search_metrics(res_norm, ref_norm, trial_res_norm, &
|
||||
trial_ref_norm)
|
||||
end if
|
||||
end do
|
||||
|
||||
if (.not. converged) then
|
||||
@@ -924,6 +974,7 @@ contains
|
||||
900 continue
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
if (allocated(u_start)) u = u_start
|
||||
call mark_convergence_failure(CONV_FAIL_NONCONVERGENCE)
|
||||
call element_state_abort_trial(state_ierr)
|
||||
end if
|
||||
if (allocated(residual)) deallocate(residual)
|
||||
@@ -956,9 +1007,110 @@ contains
|
||||
|
||||
res_norm = sqrt(sum(residual * residual))
|
||||
ref_norm = max(ONE, sqrt(sum(external * external)))
|
||||
call update_convergence_metrics(res_norm, ref_norm)
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine static_eval_residual
|
||||
|
||||
subroutine begin_newmark_convergence(dt)
|
||||
real(rk), intent(in) :: dt
|
||||
|
||||
convergence_increment = current_step + 1
|
||||
convergence_iteration = 0
|
||||
convergence_residual_norm = ZERO
|
||||
convergence_rel_resid_norm = ZERO
|
||||
convergence_correction_norm = ZERO
|
||||
convergence_contact_gap_norm = ZERO
|
||||
convergence_combined_norm = ZERO
|
||||
convergence_last_dt = dt
|
||||
convergence_converged = .false.
|
||||
convergence_status_code = CONVERGENCE_STATUS_ITERATING
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
end subroutine begin_newmark_convergence
|
||||
|
||||
subroutine begin_static_convergence(increment_id, dt_inc)
|
||||
integer, intent(in) :: increment_id
|
||||
real(rk), intent(in) :: dt_inc
|
||||
|
||||
convergence_increment = increment_id
|
||||
convergence_iteration = 0
|
||||
convergence_residual_norm = ZERO
|
||||
convergence_rel_resid_norm = ZERO
|
||||
convergence_correction_norm = ZERO
|
||||
convergence_contact_gap_norm = ZERO
|
||||
convergence_combined_norm = ZERO
|
||||
convergence_last_dt = dt_inc
|
||||
convergence_converged = .false.
|
||||
convergence_status_code = CONVERGENCE_STATUS_ITERATING
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
end subroutine begin_static_convergence
|
||||
|
||||
subroutine record_convergence_iteration(iter, res_norm, ref_norm, &
|
||||
correction_norm)
|
||||
integer, intent(in) :: iter
|
||||
real(rk), intent(in) :: res_norm
|
||||
real(rk), intent(in) :: ref_norm
|
||||
real(rk), intent(in) :: correction_norm
|
||||
|
||||
convergence_iteration = iter
|
||||
convergence_residual_norm = res_norm
|
||||
convergence_correction_norm = correction_norm
|
||||
call update_convergence_metrics(res_norm, ref_norm)
|
||||
convergence_converged = .false.
|
||||
end subroutine record_convergence_iteration
|
||||
|
||||
subroutine record_convergence_correction(correction_norm, res_norm, ref_norm)
|
||||
real(rk), intent(in) :: correction_norm
|
||||
real(rk), intent(in) :: res_norm
|
||||
real(rk), intent(in) :: ref_norm
|
||||
|
||||
convergence_correction_norm = correction_norm
|
||||
call update_convergence_metrics(res_norm, ref_norm)
|
||||
end subroutine record_convergence_correction
|
||||
|
||||
subroutine record_line_search_metrics(res_norm, ref_norm, trial_res_norm, &
|
||||
trial_ref_norm)
|
||||
real(rk), intent(inout) :: res_norm
|
||||
real(rk), intent(inout) :: ref_norm
|
||||
real(rk), intent(in) :: trial_res_norm
|
||||
real(rk), intent(in) :: trial_ref_norm
|
||||
|
||||
res_norm = trial_res_norm
|
||||
ref_norm = trial_ref_norm
|
||||
convergence_residual_norm = res_norm
|
||||
call update_convergence_metrics(res_norm, ref_norm)
|
||||
end subroutine record_line_search_metrics
|
||||
|
||||
subroutine mark_convergence_success()
|
||||
convergence_converged = .true.
|
||||
convergence_status_code = CONVERGENCE_STATUS_CONVERGED
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
end subroutine mark_convergence_success
|
||||
|
||||
subroutine mark_convergence_failure(failure_code)
|
||||
integer, intent(in) :: failure_code
|
||||
|
||||
convergence_converged = .false.
|
||||
convergence_status_code = CONVERGENCE_STATUS_FAILED
|
||||
convergence_failure_code = failure_code
|
||||
end subroutine mark_convergence_failure
|
||||
|
||||
subroutine update_convergence_metrics(res_norm, ref_norm)
|
||||
real(rk), intent(in) :: res_norm
|
||||
real(rk), intent(in) :: ref_norm
|
||||
|
||||
if (ref_norm .gt. tiny(ONE)) then
|
||||
convergence_rel_resid_norm = res_norm / ref_norm
|
||||
else
|
||||
convergence_rel_resid_norm = res_norm
|
||||
end if
|
||||
convergence_contact_gap_norm = ZERO
|
||||
if (allocated(contact_pair_gap_residual)) then
|
||||
convergence_contact_gap_norm = maxval(contact_pair_gap_residual)
|
||||
end if
|
||||
convergence_combined_norm = max(convergence_rel_resid_norm, &
|
||||
max(convergence_correction_norm, convergence_contact_gap_norm))
|
||||
end subroutine update_convergence_metrics
|
||||
|
||||
subroutine static_solve_correction(target_time, residual, rhs_corr, du, &
|
||||
max_iter, tol, ierr)
|
||||
real(rk), intent(in) :: target_time
|
||||
|
||||
Reference in New Issue
Block a user