This commit is contained in:
@@ -493,6 +493,50 @@ contains
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_contact_cache_stats
|
||||
|
||||
subroutine fem_record_convergence(increment, iteration, residual_norm, &
|
||||
correction_norm, converged)
|
||||
integer, intent(in) :: increment
|
||||
integer, intent(in) :: iteration
|
||||
real(rk), intent(in) :: residual_norm
|
||||
real(rk), intent(in) :: correction_norm
|
||||
logical, intent(in) :: converged
|
||||
|
||||
convergence_increment = increment
|
||||
convergence_iteration = iteration
|
||||
convergence_residual_norm = residual_norm
|
||||
convergence_correction_norm = correction_norm
|
||||
convergence_converged = converged
|
||||
end subroutine fem_record_convergence
|
||||
|
||||
subroutine fem_get_convergence_status(increment, iteration, residual_norm, &
|
||||
correction_norm, converged, ierr)
|
||||
integer, intent(out) :: increment
|
||||
integer, intent(out) :: iteration
|
||||
real(rk), intent(out) :: residual_norm
|
||||
real(rk), intent(out) :: correction_norm
|
||||
logical, intent(out) :: converged
|
||||
integer, intent(out) :: ierr
|
||||
|
||||
increment = 0
|
||||
iteration = 0
|
||||
residual_norm = ZERO
|
||||
correction_norm = ZERO
|
||||
converged = .false.
|
||||
|
||||
if (.not. api_initialized) then
|
||||
call error_set(FEM_ERR_INTERNAL, &
|
||||
'fem_get_convergence_status called before fem_initialize', ierr)
|
||||
return
|
||||
end if
|
||||
|
||||
increment = convergence_increment
|
||||
iteration = convergence_iteration
|
||||
residual_norm = convergence_residual_norm
|
||||
correction_norm = convergence_correction_norm
|
||||
converged = convergence_converged
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine fem_get_convergence_status
|
||||
|
||||
subroutine fem_get_boundary_facet_count(num_facets, max_face_nodes, ierr)
|
||||
integer, intent(out) :: num_facets
|
||||
integer, intent(out) :: max_face_nodes
|
||||
@@ -1236,6 +1280,7 @@ contains
|
||||
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.)
|
||||
current_step = current_step + 1
|
||||
call log_info('implicit linear solve completed')
|
||||
end subroutine fem_solve_implicit_linear
|
||||
@@ -1260,6 +1305,7 @@ contains
|
||||
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 element_compute_internal_force(ierr, ZERO)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
@@ -1324,6 +1370,7 @@ contains
|
||||
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.)
|
||||
current_step = current_step + 1
|
||||
current_time = current_time + dt
|
||||
call log_info('implicit Newmark step completed')
|
||||
@@ -1361,6 +1408,7 @@ contains
|
||||
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.)
|
||||
current_step = current_step + 1
|
||||
current_time = current_time + dt
|
||||
call log_info('nonlinear Newmark step completed')
|
||||
|
||||
@@ -34,6 +34,11 @@ module fem_control
|
||||
integer :: max_newton_iter = 25
|
||||
integer :: max_cutback = 8
|
||||
integer :: output_interval = 1
|
||||
integer :: convergence_increment = 0
|
||||
integer :: convergence_iteration = 0
|
||||
real(rk) :: convergence_residual_norm = ZERO
|
||||
real(rk) :: convergence_correction_norm = ZERO
|
||||
logical :: convergence_converged = .false.
|
||||
logical :: use_sph_coupling = .false.
|
||||
logical :: use_user_dt = .false.
|
||||
logical :: large_deformation = .true.
|
||||
@@ -70,6 +75,11 @@ contains
|
||||
max_newton_iter = 25
|
||||
max_cutback = 8
|
||||
output_interval = 1
|
||||
convergence_increment = 0
|
||||
convergence_iteration = 0
|
||||
convergence_residual_norm = ZERO
|
||||
convergence_correction_norm = ZERO
|
||||
convergence_converged = .false.
|
||||
use_sph_coupling = .false.
|
||||
use_user_dt = .false.
|
||||
large_deformation = .true.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define F_ADVANCE_EXPLICIT FC_GLOBAL(femlite_f_advance_explicit, FEMLITE_F_ADVANCE_EXPLICIT)
|
||||
#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_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)
|
||||
@@ -48,6 +49,12 @@ extern void F_ESTIMATE_DT(double *dtcrit, int *ierr);
|
||||
extern void F_ADVANCE_EXPLICIT(double *dt, int *ierr);
|
||||
extern void F_GET_TIME(double *time, int *step, int *ierr);
|
||||
extern void F_GET_SIZE(int *num_nodes, int *num_elems, int *num_dof, int *ierr);
|
||||
extern void F_GET_CONVERGENCE(int *increment,
|
||||
int *iteration,
|
||||
double *residual_norm,
|
||||
double *correction_norm,
|
||||
int *converged,
|
||||
int *ierr);
|
||||
extern void F_GET_CONTACT_SUMMARY(int *active_count,
|
||||
double *work_step,
|
||||
double *work_total,
|
||||
@@ -240,6 +247,22 @@ int femlite_get_model_size(int *num_nodes, int *num_elems, int *num_dof)
|
||||
return ierr;
|
||||
}
|
||||
|
||||
int femlite_get_convergence_status(int *increment,
|
||||
int *iteration,
|
||||
double *residual_norm,
|
||||
double *correction_norm,
|
||||
int *converged)
|
||||
{
|
||||
int ierr = 0;
|
||||
if (!increment || !iteration || !residual_norm ||
|
||||
!correction_norm || !converged) {
|
||||
return -1;
|
||||
}
|
||||
F_GET_CONVERGENCE(increment, iteration, residual_norm,
|
||||
correction_norm, converged, &ierr);
|
||||
return ierr;
|
||||
}
|
||||
|
||||
int femlite_get_contact_summary(int *active_count,
|
||||
double *work_step,
|
||||
double *work_total,
|
||||
|
||||
@@ -158,6 +158,28 @@ subroutine femlite_f_get_size(num_nodes, num_elems, num_dof, ierr)
|
||||
call fem_get_model_size(num_nodes, num_elems, num_dof, ierr)
|
||||
end subroutine femlite_f_get_size
|
||||
|
||||
subroutine femlite_f_get_convergence(increment, iteration, residual_norm, &
|
||||
correction_norm, converged_flag, ierr)
|
||||
use fem_api
|
||||
use fem_precision
|
||||
implicit none
|
||||
integer, intent(out) :: increment
|
||||
integer, intent(out) :: iteration
|
||||
real(rk), intent(out) :: residual_norm
|
||||
real(rk), intent(out) :: correction_norm
|
||||
integer, intent(out) :: converged_flag
|
||||
integer, intent(out) :: ierr
|
||||
logical :: converged
|
||||
|
||||
call fem_get_convergence_status(increment, iteration, residual_norm, &
|
||||
correction_norm, converged, ierr)
|
||||
if (converged) then
|
||||
converged_flag = 1
|
||||
else
|
||||
converged_flag = 0
|
||||
end if
|
||||
end subroutine femlite_f_get_convergence
|
||||
|
||||
subroutine femlite_f_clear_sph(ierr)
|
||||
use fem_api
|
||||
implicit none
|
||||
|
||||
@@ -203,8 +203,9 @@ contains
|
||||
dt_try = sub_target_time - current_time
|
||||
end if
|
||||
|
||||
call nonlinear_static_increment(sub_target_time, dt_try, max_iter, tol, &
|
||||
iter_inc, res_norm, ierr)
|
||||
call nonlinear_static_increment(current_step + 1, sub_target_time, &
|
||||
dt_try, max_iter, tol, iter_inc, &
|
||||
res_norm, ierr)
|
||||
if (ierr .eq. FEM_SUCCESS) then
|
||||
iter_total = iter_total + iter_inc
|
||||
current_time = sub_target_time
|
||||
@@ -818,8 +819,10 @@ contains
|
||||
if (allocated(kcopy)) deallocate(kcopy)
|
||||
end subroutine evaluate_newmark_trial_residual
|
||||
|
||||
subroutine nonlinear_static_increment(target_time, dt_inc, max_iter, tol, &
|
||||
iter_used, res_norm, ierr)
|
||||
subroutine nonlinear_static_increment(increment_id, target_time, dt_inc, &
|
||||
max_iter, tol, iter_used, res_norm, &
|
||||
ierr)
|
||||
integer, intent(in) :: increment_id
|
||||
real(rk), intent(in) :: target_time
|
||||
real(rk), intent(in) :: dt_inc
|
||||
integer, intent(in) :: max_iter
|
||||
@@ -836,6 +839,7 @@ contains
|
||||
real(rk) :: ref_norm
|
||||
real(rk) :: trial_res_norm
|
||||
real(rk) :: trial_ref_norm
|
||||
real(rk) :: correction_norm
|
||||
integer :: iter
|
||||
integer :: stat
|
||||
integer :: state_ierr
|
||||
@@ -846,7 +850,13 @@ contains
|
||||
ref_norm = ONE
|
||||
trial_res_norm = ZERO
|
||||
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.
|
||||
allocate(residual(ndof), external(ndof), rhs_corr(ndof), du(ndof), &
|
||||
u_start(ndof), u_base(ndof), stat=stat)
|
||||
if (stat .ne. 0) then
|
||||
@@ -870,8 +880,13 @@ 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.
|
||||
if (res_norm .le. tol .or. res_norm / ref_norm .le. tol) then
|
||||
converged = .true.
|
||||
convergence_converged = .true.
|
||||
if (allocated(freaction)) freaction = fint - external
|
||||
exit
|
||||
end if
|
||||
@@ -880,6 +895,8 @@ contains
|
||||
call static_solve_correction(target_time, residual, rhs_corr, du, &
|
||||
max_iter, tol, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) go to 900
|
||||
correction_norm = sqrt(sum(du * du))
|
||||
convergence_correction_norm = correction_norm
|
||||
|
||||
u_base = u
|
||||
if (use_line_search) then
|
||||
|
||||
Reference in New Issue
Block a user