This commit is contained in:
+120
-6
@@ -494,18 +494,43 @@ contains
|
||||
end subroutine fem_get_contact_cache_stats
|
||||
|
||||
subroutine fem_record_convergence(increment, iteration, residual_norm, &
|
||||
correction_norm, converged)
|
||||
correction_norm, last_dt, accepted_time, &
|
||||
converged, relative_residual_norm, &
|
||||
contact_gap_norm)
|
||||
integer, intent(in) :: increment
|
||||
integer, intent(in) :: iteration
|
||||
real(rk), intent(in) :: residual_norm
|
||||
real(rk), intent(in) :: correction_norm
|
||||
real(rk), intent(in) :: last_dt
|
||||
real(rk), intent(in) :: accepted_time
|
||||
logical, intent(in) :: converged
|
||||
real(rk), intent(in), optional :: relative_residual_norm
|
||||
real(rk), intent(in), optional :: contact_gap_norm
|
||||
|
||||
convergence_increment = increment
|
||||
convergence_iteration = iteration
|
||||
convergence_residual_norm = residual_norm
|
||||
convergence_correction_norm = correction_norm
|
||||
if (present(relative_residual_norm)) then
|
||||
convergence_rel_resid_norm = relative_residual_norm
|
||||
else
|
||||
convergence_rel_resid_norm = residual_norm
|
||||
end if
|
||||
if (present(contact_gap_norm)) then
|
||||
convergence_contact_gap_norm = contact_gap_norm
|
||||
end if
|
||||
convergence_combined_norm = max(convergence_rel_resid_norm, &
|
||||
max(convergence_correction_norm, convergence_contact_gap_norm))
|
||||
convergence_last_dt = last_dt
|
||||
convergence_last_accepted_time = accepted_time
|
||||
convergence_converged = converged
|
||||
if (converged) then
|
||||
convergence_status_code = CONVERGENCE_STATUS_CONVERGED
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
else
|
||||
convergence_status_code = CONVERGENCE_STATUS_FAILED
|
||||
convergence_failure_code = CONV_FAIL_NONCONVERGENCE
|
||||
end if
|
||||
end subroutine fem_record_convergence
|
||||
|
||||
subroutine fem_get_convergence_status(increment, iteration, residual_norm, &
|
||||
@@ -537,6 +562,59 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_convergence_status
|
||||
|
||||
subroutine fem_get_convergence_metrics(relative_residual_norm, &
|
||||
contact_gap_norm, combined_norm, ierr)
|
||||
real(rk), intent(out) :: relative_residual_norm
|
||||
real(rk), intent(out) :: contact_gap_norm
|
||||
real(rk), intent(out) :: combined_norm
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
relative_residual_norm = ZERO
|
||||
contact_gap_norm = ZERO
|
||||
combined_norm = ZERO
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_convergence_metrics called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
relative_residual_norm = convergence_rel_resid_norm
|
||||
contact_gap_norm = convergence_contact_gap_norm
|
||||
combined_norm = convergence_combined_norm
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_convergence_metrics
|
||||
|
||||
subroutine fem_get_convergence_diagnostics(cutback_count, last_dt, &
|
||||
last_accepted_time, status_code, &
|
||||
failure_code, ierr)
|
||||
integer, intent(out) :: cutback_count
|
||||
real(rk), intent(out) :: last_dt
|
||||
real(rk), intent(out) :: last_accepted_time
|
||||
integer, intent(out) :: status_code
|
||||
integer, intent(out) :: failure_code
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
cutback_count = 0
|
||||
last_dt = ZERO
|
||||
last_accepted_time = ZERO
|
||||
status_code = CONVERGENCE_STATUS_IDLE
|
||||
failure_code = CONV_FAIL_NONE
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_convergence_diagnostics called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
cutback_count = convergence_cutback_count
|
||||
last_dt = convergence_last_dt
|
||||
last_accepted_time = convergence_last_accepted_time
|
||||
status_code = convergence_status_code
|
||||
failure_code = convergence_failure_code
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_convergence_diagnostics
|
||||
|
||||
subroutine fem_get_boundary_facet_count(num_facets, max_face_nodes, ierr)
|
||||
integer, intent(out) :: num_facets
|
||||
integer, intent(out) :: max_face_nodes
|
||||
@@ -1277,10 +1355,12 @@ contains
|
||||
return
|
||||
end if
|
||||
|
||||
convergence_cutback_count = 0
|
||||
call implicit_solve_linear_static(current_time, max_iter, tol, iter, res_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, .true.)
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, &
|
||||
ZERO, current_time, .true., res_norm, ZERO)
|
||||
current_step = current_step + 1
|
||||
call log_info('implicit linear solve completed')
|
||||
end subroutine fem_solve_implicit_linear
|
||||
@@ -1302,10 +1382,13 @@ contains
|
||||
solve_time = current_time
|
||||
if (time_end .gt. ZERO) solve_time = time_end
|
||||
|
||||
convergence_cutback_count = 0
|
||||
call implicit_solve_linear_static(solve_time, max_iter, tol, iter, res_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, .true.)
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, &
|
||||
solve_time - current_time, solve_time, &
|
||||
.true., res_norm, ZERO)
|
||||
call element_compute_internal_force(ierr, ZERO)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
@@ -1366,11 +1449,13 @@ contains
|
||||
end if
|
||||
|
||||
analysis_type = ANALYSIS_IMPLICIT_DYNAMIC
|
||||
convergence_cutback_count = 0
|
||||
call implicit_advance_newmark_linear(dt, newmark_beta, newmark_gamma, &
|
||||
max_iter, tol, iter, res_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, .true.)
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, &
|
||||
dt, current_time + dt, .true., res_norm, ZERO)
|
||||
current_step = current_step + 1
|
||||
current_time = current_time + dt
|
||||
call log_info('implicit Newmark step completed')
|
||||
@@ -1404,11 +1489,23 @@ contains
|
||||
end if
|
||||
|
||||
analysis_type = ANALYSIS_IMPLICIT_DYNAMIC
|
||||
convergence_cutback_count = 0
|
||||
call implicit_newmark_nonlinear_step(dt, newmark_beta, newmark_gamma, &
|
||||
max_iter, tol, iter, res_norm, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
if (ierr .ne. FEM_SUCCESS) then
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, &
|
||||
convergence_correction_norm, dt, &
|
||||
current_time, .false., &
|
||||
convergence_rel_resid_norm, &
|
||||
convergence_contact_gap_norm)
|
||||
return
|
||||
end if
|
||||
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, ZERO, .true.)
|
||||
call fem_record_convergence(current_step + 1, iter, res_norm, &
|
||||
convergence_correction_norm, dt, &
|
||||
current_time + dt, .true., &
|
||||
convergence_rel_resid_norm, &
|
||||
convergence_contact_gap_norm)
|
||||
current_step = current_step + 1
|
||||
current_time = current_time + dt
|
||||
call log_info('nonlinear Newmark step completed')
|
||||
@@ -1513,6 +1610,7 @@ contains
|
||||
integer :: run_steps
|
||||
integer :: step_limit
|
||||
integer :: cut_count
|
||||
integer :: total_cutback
|
||||
|
||||
iter_total = 0
|
||||
res_norm = ZERO
|
||||
@@ -1564,6 +1662,10 @@ contains
|
||||
dt_min_eff = dt * 1.0e-8_rk
|
||||
end if
|
||||
dt_min_eff = max(dt_min_eff, time_tol)
|
||||
total_cutback = 0
|
||||
convergence_cutback_count = 0
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
convergence_last_accepted_time = current_time
|
||||
|
||||
do
|
||||
remaining = time_end - current_time
|
||||
@@ -1580,11 +1682,21 @@ contains
|
||||
dt_step * cutback_factor .ge. dt_min_eff) then
|
||||
dt_step = dt_step * cutback_factor
|
||||
cut_count = cut_count + 1
|
||||
total_cutback = total_cutback + 1
|
||||
convergence_cutback_count = total_cutback
|
||||
convergence_last_dt = dt_step
|
||||
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
ierr = FEM_SUCCESS
|
||||
else
|
||||
convergence_cutback_count = total_cutback
|
||||
convergence_status_code = CONVERGENCE_STATUS_FAILED
|
||||
convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT
|
||||
return
|
||||
end if
|
||||
end do
|
||||
convergence_cutback_count = total_cutback
|
||||
convergence_last_accepted_time = current_time
|
||||
iter_total = iter_total + iter
|
||||
run_steps = run_steps + 1
|
||||
|
||||
@@ -1600,6 +1712,8 @@ contains
|
||||
if (time_end - current_time .gt. time_tol) then
|
||||
call error_set(FEM_ERR_SOLVER, &
|
||||
'nonlinear Newmark run stopped before end time', ierr)
|
||||
convergence_status_code = CONVERGENCE_STATUS_FAILED
|
||||
convergence_failure_code = CONV_FAIL_STOPPED
|
||||
return
|
||||
end if
|
||||
|
||||
|
||||
@@ -6,6 +6,15 @@ module fem_control
|
||||
integer, parameter :: ANALYSIS_STATIC_LINEAR = 2
|
||||
integer, parameter :: ANALYSIS_STATIC_NONLINEAR = 3
|
||||
integer, parameter :: ANALYSIS_IMPLICIT_DYNAMIC = 4
|
||||
integer, parameter :: CONVERGENCE_STATUS_IDLE = 0
|
||||
integer, parameter :: CONVERGENCE_STATUS_ITERATING = 1
|
||||
integer, parameter :: CONVERGENCE_STATUS_CONVERGED = 2
|
||||
integer, parameter :: CONVERGENCE_STATUS_CUTBACK = 3
|
||||
integer, parameter :: CONVERGENCE_STATUS_FAILED = -1
|
||||
integer, parameter :: CONV_FAIL_NONE = 0
|
||||
integer, parameter :: CONV_FAIL_NONCONVERGENCE = 1
|
||||
integer, parameter :: CONV_FAIL_CUTBACK_LIMIT = 2
|
||||
integer, parameter :: CONV_FAIL_STOPPED = 3
|
||||
|
||||
real(rk) :: time_start = ZERO
|
||||
real(rk) :: time_end = ZERO
|
||||
@@ -36,8 +45,16 @@ module fem_control
|
||||
integer :: output_interval = 1
|
||||
integer :: convergence_increment = 0
|
||||
integer :: convergence_iteration = 0
|
||||
integer :: convergence_cutback_count = 0
|
||||
integer :: convergence_status_code = CONVERGENCE_STATUS_IDLE
|
||||
integer :: convergence_failure_code = CONV_FAIL_NONE
|
||||
real(rk) :: convergence_residual_norm = ZERO
|
||||
real(rk) :: convergence_rel_resid_norm = ZERO
|
||||
real(rk) :: convergence_correction_norm = ZERO
|
||||
real(rk) :: convergence_contact_gap_norm = ZERO
|
||||
real(rk) :: convergence_combined_norm = ZERO
|
||||
real(rk) :: convergence_last_dt = ZERO
|
||||
real(rk) :: convergence_last_accepted_time = ZERO
|
||||
logical :: convergence_converged = .false.
|
||||
logical :: use_sph_coupling = .false.
|
||||
logical :: use_user_dt = .false.
|
||||
@@ -77,8 +94,16 @@ contains
|
||||
output_interval = 1
|
||||
convergence_increment = 0
|
||||
convergence_iteration = 0
|
||||
convergence_cutback_count = 0
|
||||
convergence_status_code = CONVERGENCE_STATUS_IDLE
|
||||
convergence_failure_code = CONV_FAIL_NONE
|
||||
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 = ZERO
|
||||
convergence_last_accepted_time = ZERO
|
||||
convergence_converged = .false.
|
||||
use_sph_coupling = .false.
|
||||
use_user_dt = .false.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module fem_contact
|
||||
use fem_precision
|
||||
use fem_error
|
||||
use fem_control
|
||||
use fem_database
|
||||
use fem_sparse_csr
|
||||
use fem_coupling
|
||||
@@ -53,6 +54,7 @@ contains
|
||||
return
|
||||
end if
|
||||
call contact_finalize_status()
|
||||
call contact_update_convergence_gap()
|
||||
call cpu_time(time_finish)
|
||||
call contact_record_force_time(time_finish - time_start)
|
||||
|
||||
@@ -372,6 +374,15 @@ contains
|
||||
pair_has_analytic_master = trim(surface_type(surface_id)) .eq. 'ANALYTICAL'
|
||||
end function pair_has_analytic_master
|
||||
|
||||
subroutine contact_update_convergence_gap()
|
||||
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 contact_update_convergence_gap
|
||||
|
||||
subroutine pair_analytic_plane(pair, normal, offset, ierr)
|
||||
integer, intent(in) :: pair
|
||||
real(rk), intent(out) :: normal(NDIM)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#define F_GET_TIME FC_GLOBAL(femlite_f_get_time, FEMLITE_F_GET_TIME)
|
||||
#define F_GET_SIZE FC_GLOBAL(femlite_f_get_size, FEMLITE_F_GET_SIZE)
|
||||
#define F_GET_CONVERGENCE FC_GLOBAL(femlite_f_get_convergence, FEMLITE_F_GET_CONVERGENCE)
|
||||
#define F_GET_CONV_METRICS FC_GLOBAL(femlite_f_get_conv_metrics, FEMLITE_F_GET_CONV_METRICS)
|
||||
#define F_GET_CONV_DIAG FC_GLOBAL(femlite_f_get_conv_diag, FEMLITE_F_GET_CONV_DIAG)
|
||||
#define F_GET_CONTACT_SUMMARY FC_GLOBAL(femlite_f_get_contact_summary, FEMLITE_F_GET_CONTACT_SUMMARY)
|
||||
#define F_GET_CONTACT_DIAG FC_GLOBAL(femlite_f_get_contact_diag, FEMLITE_F_GET_CONTACT_DIAG)
|
||||
#define F_GET_CONTACT_FRICTION FC_GLOBAL(femlite_f_get_contact_friction, FEMLITE_F_GET_CONTACT_FRICTION)
|
||||
@@ -55,6 +57,16 @@ extern void F_GET_CONVERGENCE(int *increment,
|
||||
double *correction_norm,
|
||||
int *converged,
|
||||
int *ierr);
|
||||
extern void F_GET_CONV_METRICS(double *relative_residual_norm,
|
||||
double *contact_gap_norm,
|
||||
double *combined_norm,
|
||||
int *ierr);
|
||||
extern void F_GET_CONV_DIAG(int *cutback_count,
|
||||
double *last_dt,
|
||||
double *last_accepted_time,
|
||||
int *status_code,
|
||||
int *failure_code,
|
||||
int *ierr);
|
||||
extern void F_GET_CONTACT_SUMMARY(int *active_count,
|
||||
double *work_step,
|
||||
double *work_total,
|
||||
@@ -263,6 +275,35 @@ int femlite_get_convergence_status(int *increment,
|
||||
return ierr;
|
||||
}
|
||||
|
||||
int femlite_get_convergence_metrics(double *relative_residual_norm,
|
||||
double *contact_gap_norm,
|
||||
double *combined_norm)
|
||||
{
|
||||
int ierr = 0;
|
||||
if (!relative_residual_norm || !contact_gap_norm || !combined_norm) {
|
||||
return -1;
|
||||
}
|
||||
F_GET_CONV_METRICS(relative_residual_norm, contact_gap_norm,
|
||||
combined_norm, &ierr);
|
||||
return ierr;
|
||||
}
|
||||
|
||||
int femlite_get_convergence_diagnostics(int *cutback_count,
|
||||
double *last_dt,
|
||||
double *last_accepted_time,
|
||||
int *status_code,
|
||||
int *failure_code)
|
||||
{
|
||||
int ierr = 0;
|
||||
if (!cutback_count || !last_dt || !last_accepted_time ||
|
||||
!status_code || !failure_code) {
|
||||
return -1;
|
||||
}
|
||||
F_GET_CONV_DIAG(cutback_count, last_dt, last_accepted_time,
|
||||
status_code, failure_code, &ierr);
|
||||
return ierr;
|
||||
}
|
||||
|
||||
int femlite_get_contact_summary(int *active_count,
|
||||
double *work_step,
|
||||
double *work_total,
|
||||
|
||||
@@ -180,6 +180,38 @@ subroutine femlite_f_get_convergence(increment, iteration, residual_norm, &
|
||||
end if
|
||||
end subroutine femlite_f_get_convergence
|
||||
|
||||
subroutine femlite_f_get_conv_metrics(relative_residual_norm, &
|
||||
contact_gap_norm, combined_norm, ierr)
|
||||
use fem_api
|
||||
use fem_precision
|
||||
implicit none
|
||||
real(rk), intent(out) :: relative_residual_norm
|
||||
real(rk), intent(out) :: contact_gap_norm
|
||||
real(rk), intent(out) :: combined_norm
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call fem_get_convergence_metrics(relative_residual_norm, &
|
||||
contact_gap_norm, combined_norm, ierr)
|
||||
end subroutine femlite_f_get_conv_metrics
|
||||
|
||||
subroutine femlite_f_get_conv_diag(cutback_count, last_dt, &
|
||||
last_accepted_time, status_code, &
|
||||
failure_code, ierr)
|
||||
use fem_api
|
||||
use fem_precision
|
||||
implicit none
|
||||
integer, intent(out) :: cutback_count
|
||||
real(rk), intent(out) :: last_dt
|
||||
real(rk), intent(out) :: last_accepted_time
|
||||
integer, intent(out) :: status_code
|
||||
integer, intent(out) :: failure_code
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
call fem_get_convergence_diagnostics(cutback_count, last_dt, &
|
||||
last_accepted_time, status_code, &
|
||||
failure_code, ierr)
|
||||
end subroutine femlite_f_get_conv_diag
|
||||
|
||||
subroutine femlite_f_clear_sph(ierr)
|
||||
use fem_api
|
||||
implicit none
|
||||
|
||||
@@ -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