Release FemLite 0.5.3
FemLite CI / build-test (push) Has been cancelled

This commit is contained in:
shenw
2026-07-01 18:39:18 +08:00
parent 75d4e735b1
commit 2b7962eb96
51 changed files with 3084 additions and 2175 deletions
+8
View File
@@ -643,6 +643,7 @@ contains
total_cutback = 0
convergence_cutback_count = 0
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
convergence_last_accepted_time = current_time
do
@@ -665,11 +666,17 @@ contains
convergence_last_dt = dt_step
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
ierr = FEM_SUCCESS
else
convergence_cutback_count = total_cutback
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT
if (linear_solver_last_status .eq. LS_STATUS_FAILED) then
convergence_failure_reason_id = NFAIL_LINEAR_SOLVE
else
convergence_failure_reason_id = NFAIL_MIN_STEP
end if
return
end if
end do
@@ -692,6 +699,7 @@ contains
'nonlinear Newmark run stopped before end time', ierr)
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_STOPPED
convergence_failure_reason_id = NFAIL_STOPPED
return
end if
+78 -1
View File
@@ -4,7 +4,7 @@ module fem_api_diagnostics
use fem_control
use fem_linear_solver_cg, only: linear_solver_configure, &
linear_solver_get_settings, linear_solver_get_stats, &
linear_solver_get_diagnostics
linear_solver_get_diagnostics, linear_solver_get_fail_info
use fem_api_state, only: api_initialized
implicit none
private
@@ -12,12 +12,15 @@ module fem_api_diagnostics
public :: fem_get_convergence_status
public :: fem_get_convergence_metrics
public :: fem_get_convergence_diagnostics
public :: fem_get_convergence_reason
public :: fem_get_residual_breakdown
public :: fem_get_continuation_path_count
public :: fem_get_continuation_path_row
public :: fem_set_linear_solver
public :: fem_get_linear_solver_settings
public :: fem_get_linear_solver_stats
public :: fem_get_linsol_diagnostics
public :: fem_get_linsol_failure_info
public :: fem_set_shell_stabilization
public :: fem_get_shell_stabilization
public :: fem_get_shell_stability_stats
@@ -48,6 +51,11 @@ contains
if (present(contact_gap_norm)) then
convergence_contact_gap_norm = contact_gap_norm
end if
convergence_total_resid_norm = residual_norm
convergence_force_resid_norm = residual_norm
convergence_contact_resid_norm = convergence_contact_gap_norm
convergence_cons_resid_norm = ZERO
convergence_arc_resid_norm = ZERO
convergence_combined_norm = max(convergence_rel_resid_norm, &
max(convergence_correction_norm, convergence_contact_gap_norm))
convergence_last_dt = last_dt
@@ -56,9 +64,11 @@ contains
if (converged) then
convergence_status_code = CONVERGENCE_STATUS_CONVERGED
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
else
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_NONCONVERGENCE
convergence_failure_reason_id = NFAIL_NONCONVERGENCE
end if
end subroutine fem_record_convergence
@@ -144,6 +154,59 @@ contains
ierr = FEM_SUCCESS
end subroutine fem_get_convergence_diagnostics
subroutine fem_get_convergence_reason(reason_id, reason_name, ierr)
integer, intent(out) :: reason_id
character(len=*), intent(out) :: reason_name
integer, intent(out) :: ierr
reason_id = NFAIL_NONE
reason_name = 'none'
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_convergence_reason called before fem_initialize', ierr)
return
end if
reason_id = convergence_failure_reason_id
call convergence_failure_reason_name(reason_id, reason_name)
ierr = FEM_SUCCESS
end subroutine fem_get_convergence_reason
subroutine fem_get_residual_breakdown(total_residual, force_residual, &
contact_residual, constraint_residual, &
arc_residual, material_fail_count, &
ierr)
real(rk), intent(out) :: total_residual
real(rk), intent(out) :: force_residual
real(rk), intent(out) :: contact_residual
real(rk), intent(out) :: constraint_residual
real(rk), intent(out) :: arc_residual
integer, intent(out) :: material_fail_count
integer, intent(out) :: ierr
total_residual = ZERO
force_residual = ZERO
contact_residual = ZERO
constraint_residual = ZERO
arc_residual = ZERO
material_fail_count = 0
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_residual_breakdown called before fem_initialize', ierr)
return
end if
total_residual = convergence_total_resid_norm
force_residual = convergence_force_resid_norm
contact_residual = convergence_contact_resid_norm
constraint_residual = convergence_cons_resid_norm
arc_residual = convergence_arc_resid_norm
material_fail_count = convergence_material_fail_count
ierr = FEM_SUCCESS
end subroutine fem_get_residual_breakdown
subroutine fem_get_continuation_path_count(count, ierr)
integer, intent(out) :: count
integer, intent(out) :: ierr
@@ -312,6 +375,20 @@ contains
call linear_solver_get_diagnostics(matrix_class, initial_residual, &
final_residual, relative_residual, status_code, ierr)
end subroutine fem_get_linsol_diagnostics
subroutine fem_get_linsol_failure_info(failure_class, reason, ierr)
integer, intent(out) :: failure_class
character(len=*), intent(out) :: reason
integer, intent(out) :: ierr
failure_class = LS_FAIL_NONE
reason = 'none'
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_linsol_failure_diagnostics called before fem_initialize', &
ierr)
return
end if
call linear_solver_get_fail_info(failure_class, reason, ierr)
end subroutine fem_get_linsol_failure_info
subroutine fem_set_shell_stabilization(drilling_factor, s3_shear_factor, &
s3_shear_min_scale, ierr)
real(rk), intent(in) :: drilling_factor
+141 -2
View File
@@ -17,6 +17,22 @@ module fem_control
integer, parameter :: CONV_FAIL_NONCONVERGENCE = 1
integer, parameter :: CONV_FAIL_CUTBACK_LIMIT = 2
integer, parameter :: CONV_FAIL_STOPPED = 3
integer, parameter :: NFAIL_NONE = 0
integer, parameter :: NFAIL_LINEAR_SOLVE = 10
integer, parameter :: NFAIL_RESIDUAL_STAGNATION = 20
integer, parameter :: NFAIL_CORRECTION_LIMIT = 30
integer, parameter :: NFAIL_LINE_SEARCH = 40
integer, parameter :: NFAIL_TRUST_REJECTION = 50
integer, parameter :: NFAIL_CONTACT_ACTIVE_SET = 60
integer, parameter :: NFAIL_CONTACT_PROJECTION = 61
integer, parameter :: NFAIL_CONTACT_PENETRATION = 62
integer, parameter :: NFAIL_FRICTION_SWITCH = 70
integer, parameter :: NFAIL_MATERIAL_RETURN = 80
integer, parameter :: NFAIL_ARC_CONSTRAINT = 90
integer, parameter :: NFAIL_CONSTRAINT_RESIDUAL = 100
integer, parameter :: NFAIL_MIN_STEP = 110
integer, parameter :: NFAIL_NONCONVERGENCE = 120
integer, parameter :: NFAIL_STOPPED = 130
integer, parameter :: LSOLVER_CG = 1
integer, parameter :: LSOLVER_BICGSTAB = 2
integer, parameter :: LSOLVER_GMRES = 3
@@ -28,6 +44,12 @@ module fem_control
integer, parameter :: LS_STATUS_IDLE = 0
integer, parameter :: LS_STATUS_CONVERGED = 1
integer, parameter :: LS_STATUS_FAILED = -1
integer, parameter :: LS_FAIL_NONE = 0
integer, parameter :: LS_FAIL_NONCONVERGENCE = 1
integer, parameter :: LS_FAIL_INVALID_MATRIX = 2
integer, parameter :: LS_FAIL_DENSE_FALLBACK = 3
integer, parameter :: LS_FAIL_CONFIGURATION = 4
integer, parameter :: LS_FAIL_DIAGNOSTIC = 5
integer, parameter :: NLC_TWO_STAGE = 1
integer, parameter :: NLC_ADAPT_NEWTON = 2
integer, parameter :: NLC_TRUST_DAMPED = 3
@@ -64,7 +86,12 @@ module fem_control
integer, parameter :: NLC_PATH_R_NEXT_TRUST_RADIUS = 22
integer, parameter :: NLC_PATH_R_TRUST_DAMPING = 23
integer, parameter :: NLC_PATH_R_TRUST_MERIT_RATIO = 24
integer, parameter :: NLC_PATH_REAL_COUNT = 24
integer, parameter :: NLC_PATH_R_TOTAL_RESIDUAL = 25
integer, parameter :: NLC_PATH_R_FORCE_RESIDUAL = 26
integer, parameter :: NLC_PATH_R_CONTACT_RESIDUAL = 27
integer, parameter :: NLC_PATH_R_CONS_RESIDUAL = 28
integer, parameter :: NLC_PATH_R_ARC_RESIDUAL = 29
integer, parameter :: NLC_PATH_REAL_COUNT = 29
integer, parameter :: NLC_PATH_I_STEP = 1
integer, parameter :: NLC_PATH_I_CONTROL_DOF_COUNT = 2
integer, parameter :: NLC_PATH_I_ITERATION = 3
@@ -78,7 +105,9 @@ module fem_control
integer, parameter :: NLC_PATH_I_CUTBACK_COUNT = 11
integer, parameter :: NLC_PATH_I_TRUST_ADJUST = 12
integer, parameter :: NLC_PATH_I_TRUST_REJECTIONS = 13
integer, parameter :: NLC_PATH_INT_COUNT = 13
integer, parameter :: NLC_PATH_I_REASON_ID = 14
integer, parameter :: NLC_PATH_I_MATERIAL_FAIL_COUNT = 15
integer, parameter :: NLC_PATH_INT_COUNT = 15
integer, parameter :: BUCKLING_MAX_GEOM_LINE = 64
integer, parameter :: BUCK_GEOM_EXPLICIT = 1
integer, parameter :: BUCK_GEOM_PRELOAD = 2
@@ -146,6 +175,7 @@ module fem_control
integer :: linear_solver_last_iter = 0
integer :: linear_solver_last_status = LS_STATUS_IDLE
integer :: linear_solver_last_matrix_class = 1
integer :: linsol_last_fail_class = LS_FAIL_NONE
integer :: nonlinear_linear_iter_limit = 0
integer :: nonlinear_continuation_method = NLC_DEFAULT
integer :: buckling_num_modes = 1
@@ -177,11 +207,18 @@ module fem_control
integer :: convergence_cutback_count = 0
integer :: convergence_status_code = CONVERGENCE_STATUS_IDLE
integer :: convergence_failure_code = CONV_FAIL_NONE
integer :: convergence_failure_reason_id = NFAIL_NONE
integer :: convergence_material_fail_count = 0
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_total_resid_norm = ZERO
real(rk) :: convergence_force_resid_norm = ZERO
real(rk) :: convergence_contact_resid_norm = ZERO
real(rk) :: convergence_cons_resid_norm = ZERO
real(rk) :: convergence_arc_resid_norm = ZERO
real(rk) :: linear_solver_initial_resid = ZERO
real(rk) :: linear_solver_last_resid = ZERO
real(rk) :: linear_solver_relative_resid = ZERO
@@ -199,6 +236,7 @@ module fem_control
real(rk), allocatable :: nlc_path_real(:,:)
integer, allocatable :: nlc_path_int(:,:)
character(len=256) :: nonlinear_trace_file = ' '
character(len=64) :: linear_solver_last_reason = 'idle'
logical :: convergence_converged = .false.
logical :: use_sph_coupling = .false.
logical :: use_user_dt = .false.
@@ -288,6 +326,8 @@ contains
linear_solver_last_iter = 0
linear_solver_last_status = LS_STATUS_IDLE
linear_solver_last_matrix_class = 1
linsol_last_fail_class = LS_FAIL_NONE
linear_solver_last_reason = 'idle'
nonlinear_linear_iter_limit = 0
nonlinear_continuation_method = NLC_DEFAULT
buckling_num_modes = 1
@@ -327,11 +367,18 @@ contains
convergence_cutback_count = 0
convergence_status_code = CONVERGENCE_STATUS_IDLE
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
convergence_material_fail_count = 0
convergence_residual_norm = ZERO
convergence_rel_resid_norm = ZERO
convergence_correction_norm = ZERO
convergence_contact_gap_norm = ZERO
convergence_combined_norm = ZERO
convergence_total_resid_norm = ZERO
convergence_force_resid_norm = ZERO
convergence_contact_resid_norm = ZERO
convergence_cons_resid_norm = ZERO
convergence_arc_resid_norm = ZERO
linear_solver_initial_resid = ZERO
linear_solver_last_resid = ZERO
linear_solver_relative_resid = ZERO
@@ -445,6 +492,16 @@ contains
nlc_path_real(NLC_PATH_R_TRUST_DAMPING, row) = nlc_last_damping
nlc_path_real(NLC_PATH_R_TRUST_MERIT_RATIO, row) = &
nlc_last_merit_ratio
nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, row) = &
convergence_total_resid_norm
nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, row) = &
convergence_force_resid_norm
nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, row) = &
convergence_contact_resid_norm
nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, row) = &
convergence_cons_resid_norm
nlc_path_real(NLC_PATH_R_ARC_RESIDUAL, row) = &
convergence_arc_resid_norm
nlc_path_int(NLC_PATH_I_STEP, row) = step
nlc_path_int(NLC_PATH_I_CONTROL_DOF_COUNT, row) = control_dof_count
@@ -459,11 +516,93 @@ contains
nlc_path_int(NLC_PATH_I_CUTBACK_COUNT, row) = convergence_cutback_count
nlc_path_int(NLC_PATH_I_TRUST_ADJUST, row) = nlc_last_trust_adjust
nlc_path_int(NLC_PATH_I_TRUST_REJECTIONS, row) = nlc_last_rejections
nlc_path_int(NLC_PATH_I_REASON_ID, row) = convergence_failure_reason_id
nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, row) = &
convergence_material_fail_count
nlc_path_count = row
ierr = FEM_SUCCESS
end subroutine nlc_path_append
integer function convergence_reason_from_failure(failure_code) result(reason_id)
integer, intent(in) :: failure_code
select case (failure_code)
case (CONV_FAIL_NONE)
reason_id = NFAIL_NONE
case (CONV_FAIL_NONCONVERGENCE)
reason_id = NFAIL_NONCONVERGENCE
case (CONV_FAIL_CUTBACK_LIMIT)
reason_id = NFAIL_MIN_STEP
case (CONV_FAIL_STOPPED)
reason_id = NFAIL_STOPPED
case default
reason_id = NFAIL_NONCONVERGENCE
end select
end function convergence_reason_from_failure
subroutine convergence_failure_reason_name(reason_id, reason_name)
integer, intent(in) :: reason_id
character(len=*), intent(out) :: reason_name
reason_name = 'unknown'
select case (reason_id)
case (NFAIL_NONE)
reason_name = 'none'
case (NFAIL_LINEAR_SOLVE)
reason_name = 'linear-solve-failure'
case (NFAIL_RESIDUAL_STAGNATION)
reason_name = 'residual-stagnation'
case (NFAIL_CORRECTION_LIMIT)
reason_name = 'correction-norm-limit'
case (NFAIL_LINE_SEARCH)
reason_name = 'line-search-failure'
case (NFAIL_TRUST_REJECTION)
reason_name = 'trust-rejection'
case (NFAIL_CONTACT_ACTIVE_SET)
reason_name = 'contact-active-set-oscillation'
case (NFAIL_CONTACT_PROJECTION)
reason_name = 'contact-projection-failure'
case (NFAIL_CONTACT_PENETRATION)
reason_name = 'contact-excessive-penetration'
case (NFAIL_FRICTION_SWITCH)
reason_name = 'friction-stick-slip-switching'
case (NFAIL_MATERIAL_RETURN)
reason_name = 'material-return-failure'
case (NFAIL_ARC_CONSTRAINT)
reason_name = 'arc-constraint-failure'
case (NFAIL_CONSTRAINT_RESIDUAL)
reason_name = 'constraint-residual-failure'
case (NFAIL_MIN_STEP)
reason_name = 'minimum-step-exhausted'
case (NFAIL_NONCONVERGENCE)
reason_name = 'nonlinear-nonconvergence'
case (NFAIL_STOPPED)
reason_name = 'run-stopped'
end select
end subroutine convergence_failure_reason_name
subroutine linsol_fail_class_name(failure_class, class_name)
integer, intent(in) :: failure_class
character(len=*), intent(out) :: class_name
class_name = 'unknown'
select case (failure_class)
case (LS_FAIL_NONE)
class_name = 'none'
case (LS_FAIL_NONCONVERGENCE)
class_name = 'linear-nonconvergence'
case (LS_FAIL_INVALID_MATRIX)
class_name = 'invalid-matrix-class'
case (LS_FAIL_DENSE_FALLBACK)
class_name = 'dense-fallback-failure'
case (LS_FAIL_CONFIGURATION)
class_name = 'linear-configuration-failure'
case (LS_FAIL_DIAGNOSTIC)
class_name = 'linear-diagnostic-failure'
end select
end subroutine linsol_fail_class_name
subroutine nlc_path_ensure_capacity(required, ierr)
integer, intent(in) :: required
integer, intent(out) :: ierr
+1 -1
View File
@@ -16,7 +16,7 @@ module fem_precision
integer, parameter :: FEMLITE_VERSION_MAJOR = 0
integer, parameter :: FEMLITE_VERSION_MINOR = 5
integer, parameter :: FEMLITE_VERSION_PATCH = 2
integer, parameter :: FEMLITE_VERSION_PATCH = 3
real(rk), parameter :: ZERO = 0.0_rk
real(rk), parameter :: ONE = 1.0_rk
+45
View File
@@ -11,12 +11,19 @@ module fem_contact_history
public :: contact_history_reset
public :: contact_history_stats
public :: contact_history_state_stats
public :: contact_history_stable_counts
public :: contact_history_write
public :: contact_history_read
integer, parameter, public :: CONTACT_HIST_OPEN = 0
integer, parameter, public :: CONTACT_HIST_STICK = 1
integer, parameter, public :: CONTACT_HIST_SLIP = 2
integer, parameter, public :: CONTACT_STATE_OPEN = 0
integer, parameter, public :: CONTACT_STATE_CLOSED_STICK = 1
integer, parameter, public :: CONTACT_STATE_CLOSED_SLIP = 2
integer, parameter, public :: CONTACT_STATE_CLOSED_RESTICK = 3
integer, parameter, public :: CONTACT_STATE_SEPARATING = 4
integer, parameter, public :: CONTACT_STATE_FAILED_PROJ = 5
integer, allocatable :: hist_pair(:)
integer, allocatable :: hist_slave_elem(:)
@@ -84,6 +91,44 @@ contains
end do
end subroutine contact_history_state_stats
subroutine contact_history_stable_counts(slot_count, open_count, &
closed_stick_count, &
closed_slip_count, &
closed_restick_count, &
separating_count, &
failed_projection_count)
integer, intent(out) :: slot_count
integer, intent(out) :: open_count
integer, intent(out) :: closed_stick_count
integer, intent(out) :: closed_slip_count
integer, intent(out) :: closed_restick_count
integer, intent(out) :: separating_count
integer, intent(out) :: failed_projection_count
integer :: slot
slot_count = hist_count
open_count = 0
closed_stick_count = 0
closed_slip_count = 0
closed_restick_count = 0
separating_count = 0
failed_projection_count = 0
if (hist_count .le. 0 .or. .not. allocated(hist_status)) return
do slot = 1, hist_count
select case (hist_status(slot))
case (CONTACT_HIST_OPEN)
open_count = open_count + 1
case (CONTACT_HIST_STICK)
closed_stick_count = closed_stick_count + 1
case (CONTACT_HIST_SLIP)
closed_slip_count = closed_slip_count + 1
case default
failed_projection_count = failed_projection_count + 1
end select
end do
end subroutine contact_history_stable_counts
subroutine contact_history_write(unit_id, ios)
integer, intent(in) :: unit_id
integer, intent(out) :: ios
@@ -47,6 +47,12 @@ module fem_contact_mortar_tangent
real(rk) :: col_sum_norm = ZERO
real(rk) :: max_asym = ZERO
real(rk) :: max_translation_residual = ZERO
real(rk) :: normal_rigid_residual = ZERO
real(rk) :: normal_relative_fd_error = ZERO
real(rk) :: stick_relative_fd_error = ZERO
real(rk) :: slip_relative_fd_error = ZERO
real(rk) :: friction_rigid_residual = ZERO
real(rk) :: friction_energy_residual = ZERO
real(rk) :: energy_probe = ZERO
logical :: balance_ok = .false.
logical :: translation_ok = .false.
@@ -64,6 +70,7 @@ module fem_contact_mortar_tangent
public :: mortar_tan_block_values
public :: mortar_tan_row_balance
public :: mortar_tan_audit_matrix
public :: mortar_tan_audit_friction
contains
@@ -319,6 +326,7 @@ contains
real(rk) :: probe(MORTAR_TAN_MAX_DOF)
real(rk) :: force(MORTAR_TAN_MAX_DOF)
real(rk) :: matrix_norm
integer :: idir
integer :: inode
integer :: i
@@ -360,8 +368,15 @@ contains
end do
audit%max_translation_residual = max(audit%max_translation_residual, &
maxval(abs(force(1:ndof))))
if (idir .eq. NDIM) audit%normal_rigid_residual = &
maxval(abs(force(1:ndof)))
end do
matrix_norm = maxval(abs(k_local(1:ndof,1:ndof)))
if (matrix_norm .gt. tiny(ONE)) then
audit%normal_relative_fd_error = audit%normal_rigid_residual / matrix_norm
end if
probe = ZERO
force = ZERO
do i = 1, ndof
@@ -383,6 +398,38 @@ contains
call error_clear(ierr)
end subroutine mortar_tan_audit_matrix
subroutine mortar_tan_audit_friction(ndof, k_local, mode, balance_tol, &
audit, ierr)
integer, intent(in) :: ndof
real(rk), intent(in) :: k_local(:,:)
integer, intent(in) :: mode
real(rk), intent(in) :: balance_tol
type(mortar_tangent_audit), intent(out) :: audit
integer, intent(out) :: ierr
real(rk) :: matrix_norm
real(rk) :: rel_error
if (mode .ne. MORTAR_TAN_STICK .and. mode .ne. MORTAR_TAN_SLIP) then
call error_set(FEM_ERR_INPUT, 'unknown mortar friction audit mode', ierr)
return
end if
call mortar_tan_audit_matrix(ndof, k_local, balance_tol, audit, ierr)
if (ierr .ne. FEM_SUCCESS) return
matrix_norm = maxval(abs(k_local(1:ndof,1:ndof)))
rel_error = ZERO
if (matrix_norm .gt. tiny(ONE)) rel_error = audit%max_asym / matrix_norm
if (mode .eq. MORTAR_TAN_STICK) then
audit%stick_relative_fd_error = rel_error
else
audit%slip_relative_fd_error = rel_error
end if
audit%friction_rigid_residual = audit%max_translation_residual
audit%friction_energy_residual = abs(min(ZERO, audit%energy_probe))
call error_clear(ierr)
end subroutine mortar_tan_audit_friction
subroutine build_tangent(cons, params, mode, ndof, k_local, diag, ierr)
type(mortar_constraint), intent(in) :: cons
type(mortar_tangent_params), intent(in) :: params
@@ -575,6 +622,12 @@ contains
audit%col_sum_norm = ZERO
audit%max_asym = ZERO
audit%max_translation_residual = ZERO
audit%normal_rigid_residual = ZERO
audit%normal_relative_fd_error = ZERO
audit%stick_relative_fd_error = ZERO
audit%slip_relative_fd_error = ZERO
audit%friction_rigid_residual = ZERO
audit%friction_energy_residual = ZERO
audit%energy_probe = ZERO
audit%balance_ok = .false.
audit%translation_ok = .false.
+100
View File
@@ -1,6 +1,10 @@
module fem_contact_multiplier
use fem_precision
use fem_error
use fem_contact_history, only: CONTACT_STATE_OPEN, &
CONTACT_STATE_CLOSED_STICK, CONTACT_STATE_CLOSED_SLIP, &
CONTACT_STATE_CLOSED_RESTICK, CONTACT_STATE_SEPARATING, &
CONTACT_STATE_FAILED_PROJ
implicit none
private
@@ -17,6 +21,8 @@ module fem_contact_multiplier
public :: contact_multiplier_old
public :: contact_multiplier_stats
public :: contact_multiplier_full_stats
public :: contact_multiplier_state_counts
public :: contact_multiplier_resid_stats
public :: contact_multiplier_entry
public :: contact_multiplier_status_name
public :: contact_multiplier_compact
@@ -185,6 +191,100 @@ contains
call error_clear(ierr)
end subroutine contact_multiplier_full_stats
subroutine contact_multiplier_state_counts(slot_count, open_count, &
closed_stick_count, &
closed_slip_count, &
closed_restick_count, &
separating_count, &
failed_projection_count, ierr)
integer, intent(out) :: slot_count
integer, intent(out) :: open_count
integer, intent(out) :: closed_stick_count
integer, intent(out) :: closed_slip_count
integer, intent(out) :: closed_restick_count
integer, intent(out) :: separating_count
integer, intent(out) :: failed_projection_count
integer, intent(out) :: ierr
integer :: slot
integer :: state_id
slot_count = mult_count
open_count = 0
closed_stick_count = 0
closed_slip_count = 0
closed_restick_count = 0
separating_count = 0
failed_projection_count = 0
if (mult_count .le. 0) then
call error_clear(ierr)
return
end if
if (.not. allocated(mult_status)) then
failed_projection_count = mult_count
call error_set(FEM_ERR_INTERNAL, &
'contact multiplier state count found missing status array', ierr)
return
end if
do slot = 1, mult_count
if (.not. valid_multiplier_status(mult_status(slot))) then
state_id = CONTACT_STATE_FAILED_PROJ
else if (mult_status(slot) .eq. CONTACT_MULT_ACTIVE) then
state_id = CONTACT_STATE_CLOSED_STICK
else if (mult_status(slot) .eq. CONTACT_MULT_RELEASED) then
state_id = CONTACT_STATE_SEPARATING
else
state_id = CONTACT_STATE_OPEN
end if
select case (state_id)
case (CONTACT_STATE_OPEN)
open_count = open_count + 1
case (CONTACT_STATE_CLOSED_STICK)
closed_stick_count = closed_stick_count + 1
case (CONTACT_STATE_CLOSED_SLIP)
closed_slip_count = closed_slip_count + 1
case (CONTACT_STATE_CLOSED_RESTICK)
closed_restick_count = closed_restick_count + 1
case (CONTACT_STATE_SEPARATING)
separating_count = separating_count + 1
case default
failed_projection_count = failed_projection_count + 1
end select
end do
call error_clear(ierr)
end subroutine contact_multiplier_state_counts
subroutine contact_multiplier_resid_stats(normal_residual, update_count, &
ierr)
real(rk), intent(out) :: normal_residual
integer, intent(out) :: update_count
integer, intent(out) :: ierr
integer :: slot
real(rk) :: diff
normal_residual = ZERO
update_count = 0
if (mult_count .le. 0) then
call error_clear(ierr)
return
end if
if (.not. allocated(mult_lambda) .or. &
.not. allocated(mult_trial_lambda)) then
call error_set(FEM_ERR_INTERNAL, &
'contact multiplier residual stats found missing arrays', ierr)
return
end if
do slot = 1, mult_count
diff = abs(mult_trial_lambda(slot) - mult_lambda(slot))
normal_residual = max(normal_residual, diff)
if (diff .gt. tiny(ONE)) update_count = update_count + 1
end do
call error_clear(ierr)
end subroutine contact_multiplier_resid_stats
subroutine contact_multiplier_audit(slot_count, active_count, &
released_count, open_count, &
duplicate_count, invalid_count, &
+27 -4
View File
@@ -67,14 +67,23 @@ contains
integer :: active
integer :: released
integer :: open_count
integer :: state_slots
integer :: state_open
integer :: state_stick
integer :: state_slip
integer :: state_restick
integer :: state_separating
integer :: state_failed_proj
integer :: duplicate_count
integer :: invalid_count
real(rk) :: max_lambda
real(rk) :: max_trial
real(rk) :: max_gap
real(rk) :: max_commit_error
real(rk) :: normal_residual
integer :: al_update_count
if (len(line) .lt. 256) then
if (len(line) .lt. 512) then
call error_set(FEM_ERR_OUTPUT, 'contact multiplier summary too small', &
ierr)
return
@@ -86,12 +95,26 @@ contains
duplicate_count, invalid_count, max_lambda, max_gap, max_commit_error, &
ierr)
if (ierr .ne. FEM_SUCCESS) return
call contact_multiplier_state_counts(state_slots, state_open, &
state_stick, state_slip, state_restick, state_separating, &
state_failed_proj, ierr)
if (ierr .ne. FEM_SUCCESS) return
call contact_multiplier_resid_stats(normal_residual, al_update_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
write(line, '(A,I0,A,I0,A,I0,A,I0,A,ES16.8,A,ES16.8,A,ES16.8,' // &
'A,I0,A,I0,A,ES16.8)') &
'A,I0,A,I0,A,ES16.8,A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,' // &
'A,ES16.8,A,I0)') &
'slots=', slots, ',active=', active, ',released=', released, &
',open=', open_count, ',max_lambda=', max_lambda, ',max_trial=', &
max_trial, ',max_gap=', max_gap, ',duplicates=', duplicate_count, &
',invalid=', invalid_count, ',max_commit_error=', max_commit_error
',invalid=', invalid_count, ',max_commit_error=', max_commit_error, &
',state_slots=', state_slots, ',state_open=', state_open, &
',state_closed_stick=', state_stick, ',state_closed_slip=', state_slip, &
',state_closed_restick=', state_restick, &
',state_separating=', state_separating, &
',state_failed_projection=', state_failed_proj, &
',normal_multiplier_residual=', normal_residual, &
',al_update_count=', al_update_count
call error_clear(ierr)
end subroutine contact_mult_report_summary
@@ -99,7 +122,7 @@ contains
character(len=*), intent(in) :: filename
integer, intent(out) :: ierr
character(len=256) :: line
character(len=512) :: line
integer :: unit
integer :: ios
integer :: slot
+8
View File
@@ -37,6 +37,7 @@ contains
if (present(dt)) dt_local = dt
fint = ZERO
convergence_material_fail_count = 0
do elem = 1, nelem
if (elem_status(elem) .ne. 0) cycle
@@ -139,6 +140,7 @@ contains
stress(:,gp) = sig
statev(:,gp) = state_new
if (state_new(4) .ge. HALF) then
convergence_material_fail_count = convergence_material_fail_count + 1
elem_status(elem) = 1
stress(:,gp) = ZERO
return
@@ -271,6 +273,9 @@ contains
gp = gp + 1
end do
convergence_material_fail_count = convergence_material_fail_count + &
failed_count
if (failed_count .ge. 4) then
elem_status(elem) = 1
if (gp_start .gt. 0) stress(:,gp_start:gp_start+7) = ZERO
@@ -372,6 +377,9 @@ contains
gp = gp + 1
end do
convergence_material_fail_count = convergence_material_fail_count + &
failed_count
if (should_delete_solid(elem_type(elem), failed_count, npoint)) then
elem_status(elem) = 1
if (gp_start .gt. 0) stress(:,gp_start:gp_start+npoint-1) = ZERO
+141 -8
View File
@@ -345,6 +345,7 @@ contains
integer :: unit_id
integer :: ios
integer :: row
character(len=64) :: reason_name
if (nlc_path_count .le. 0) then
ierr = FEM_SUCCESS
@@ -372,7 +373,10 @@ contains
'adapt_adjust,cutback_count,trust_adjust,trust_rejections,'// &
'status_code,failure_code,linear_method,linear_precond,'// &
'linear_iterations,linear_status,linear_initial_residual,'// &
'linear_final_residual,linear_relative_residual'
'linear_final_residual,linear_relative_residual,'// &
'residual_total,residual_force,residual_contact,'// &
'residual_constraint,residual_arc,material_failure_count,'// &
'reason_id,reason_name'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, &
@@ -381,8 +385,11 @@ contains
end if
do row = 1, nlc_path_count
call convergence_failure_reason_name( &
nlc_path_int(NLC_PATH_I_REASON_ID, row), reason_name)
write(unit_id,'(I12,2(A,ES24.16),A,I12,9(A,ES24.16),'// &
'A,I12,10(A,ES24.16),10(A,I12),3(A,ES24.16))',iostat=ios) &
'A,I12,10(A,ES24.16),10(A,I12),3(A,ES24.16))', &
iostat=ios, advance='no') &
nlc_path_int(NLC_PATH_I_STEP, row), &
',', nlc_path_real(NLC_PATH_R_TIME, row), &
',', nlc_path_real(NLC_PATH_R_PARAMETER, row), &
@@ -420,6 +427,20 @@ contains
',', nlc_path_real(NLC_PATH_R_LIN_INIT_RESID, row), &
',', nlc_path_real(NLC_PATH_R_LIN_FINAL_RESID, row), &
',', nlc_path_real(NLC_PATH_R_LIN_REL_RESID, row)
if (ios .eq. 0) then
write(unit_id,'(5(A,ES24.16),A,I12)',iostat=ios, advance='no') &
',', nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, row), &
',', nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, row), &
',', nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, row), &
',', nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, row), &
',', nlc_path_real(NLC_PATH_R_ARC_RESIDUAL, row), &
',', nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, row)
end if
if (ios .eq. 0) then
write(unit_id,'(A,I12,A,A)',iostat=ios) &
',', nlc_path_int(NLC_PATH_I_REASON_ID, row), &
',', trim(reason_name)
end if
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, &
@@ -541,8 +562,11 @@ contains
write(unit_id,'(A)',iostat=ios) &
'kind,pair_id,active_count,max_penetration,force_norm,work_estimate,'// &
'cumulative_work,stick_count,slip_count,accumulated_slip,'// &
'slip_increment_norm,slip_residual,friction_residual,'// &
'friction_work,friction_work_total,friction_regularization,ftx,fty,ftz,'// &
'status,activation_count,release_count,gap_residual,aug_factor,aug_lambda,'// &
'status,activation_count,release_count,gap_residual,gap_mean,'// &
'gap_l2,failed_projection_count,active_set_flip_count,'// &
'aug_factor,aug_lambda,'// &
'search_facets,search_masters,search_candidates,search_active,'// &
'search_bvh_nodes,search_cache_used,search_cache_overflow,'// &
'search_cpu_time,contact_force_cpu_time,'// &
@@ -560,6 +584,9 @@ contains
integer :: search_facets, search_masters, search_broad, search_active
integer :: search_bvh_nodes, cache_used, cache_overflow
real(rk) :: search_time, force_time, tangent_time
real(rk) :: gap_residual, gap_mean, gap_l2
real(rk) :: slip_inc, slip_residual, friction_residual
integer :: failed_projection, active_set_flip
integer :: ios
call contact_get_search_stats(search_facets, search_masters, &
@@ -567,16 +594,24 @@ contains
search_bvh_nodes)
call contact_get_perf_stats(search_time, force_time, tangent_time)
call contact_get_cache_stats(cache_used, cache_overflow)
call output_csv_contact_gap_stats(0, gap_residual, gap_mean, gap_l2, &
failed_projection, active_set_flip)
call output_csv_contact_slip_stats(0, slip_inc, slip_residual, &
friction_residual)
write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16),2(A,I12),'// &
'7(A,ES24.16),3(A,I12),3(A,ES24.16),7(A,I12),'// &
'10(A,ES24.16),3(A,I12),3(A,ES24.16),2(A,I12),'// &
'2(A,ES24.16),7(A,I12),'// &
'3(A,ES24.16))',iostat=ios) &
'SUMMARY', ',', 0, ',', contact_active_count, &
',', contact_max_penetration, ',', contact_force_norm, &
',', contact_work_step, ',', contact_work_total, ',', 0, ',', 0, &
',', ZERO, ',', contact_friction_work_step, &
',', ZERO, ',', slip_inc, ',', slip_residual, ',', friction_residual, &
',', contact_friction_work_step, &
',', contact_friction_work_total, ',', ZERO, &
',', ZERO, ',', ZERO, ',', ZERO, &
',', 0, ',', 0, ',', 0, ',', ZERO, ',', ZERO, ',', ZERO, &
',', 0, ',', 0, ',', 0, ',', gap_residual, ',', gap_mean, &
',', gap_l2, ',', failed_projection, ',', active_set_flip, &
',', ZERO, ',', ZERO, &
',', search_facets, ',', search_masters, ',', search_broad, &
',', search_active, ',', search_bvh_nodes, ',', cache_used, &
',', cache_overflow, ',', search_time, ',', force_time, ',', tangent_time
@@ -595,7 +630,10 @@ contains
integer :: search_facets, search_masters, search_broad, search_active
integer :: search_bvh_nodes, cache_used, cache_overflow
real(rk) :: max_pen, force_sum, work_sum
real(rk) :: gap_residual, gap_mean, gap_l2
real(rk) :: slip_inc, slip_residual, friction_residual
real(rk) :: search_time, force_time, tangent_time
integer :: failed_projection, active_set_flip
integer :: ios
active = 0
@@ -611,14 +649,20 @@ contains
call contact_get_pair_stats(pair, search_facets, search_masters, &
search_broad, search_active, search_bvh_nodes, cache_used, &
cache_overflow, search_time, force_time, tangent_time)
call output_csv_contact_gap_stats(pair, gap_residual, gap_mean, gap_l2, &
failed_projection, active_set_flip)
call output_csv_contact_slip_stats(pair, slip_inc, slip_residual, &
friction_residual)
write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16),2(A,I12),'// &
'7(A,ES24.16),3(A,I12),3(A,ES24.16),7(A,I12),'// &
'10(A,ES24.16),3(A,I12),3(A,ES24.16),2(A,I12),'// &
'2(A,ES24.16),7(A,I12),'// &
'3(A,ES24.16))',iostat=ios) &
'PAIR', ',', pair, ',', active, ',', max_pen, ',', force_sum, &
',', work_sum, ',', ZERO, &
',', contact_pair_stick_value(pair), ',', contact_pair_slip_value(pair), &
',', contact_pair_accumulated_slip(pair), &
',', slip_inc, ',', slip_residual, ',', friction_residual, &
',', contact_pair_fric_work_value(pair), &
',', contact_pair_fric_total_value(pair), &
',', contact_pair_fric_reg_value(pair), &
@@ -628,7 +672,8 @@ contains
',', contact_pair_status_value(pair), &
',', contact_pair_activation_value(pair), &
',', contact_pair_release_value(pair), &
',', contact_pair_gap_value(pair), &
',', gap_residual, ',', gap_mean, ',', gap_l2, &
',', failed_projection, ',', active_set_flip, &
',', contact_pair_aug_factor_value(pair), &
',', contact_pair_aug_lambda_value(pair), &
',', search_facets, ',', search_masters, ',', search_broad, &
@@ -642,6 +687,94 @@ contains
end subroutine output_csv_contact_pair
subroutine output_csv_contact_gap_stats(pair, gap_residual, gap_mean, &
gap_l2, failed_projection, &
active_set_flip)
integer, intent(in) :: pair
real(rk), intent(out) :: gap_residual
real(rk), intent(out) :: gap_mean
real(rk), intent(out) :: gap_l2
integer, intent(out) :: failed_projection
integer, intent(out) :: active_set_flip
integer :: idx
integer :: count
real(rk) :: gap
real(rk) :: gap_sum
real(rk) :: gap_sq
gap_residual = ZERO
gap_mean = ZERO
gap_l2 = ZERO
failed_projection = 0
active_set_flip = 0
if (pair .gt. 0) then
gap_residual = contact_pair_gap_value(pair)
gap_mean = gap_residual
gap_l2 = gap_residual
active_set_flip = contact_pair_activation_value(pair) + &
contact_pair_release_value(pair)
return
end if
if (ncontact_pair .le. 0) return
count = 0
gap_sum = ZERO
gap_sq = ZERO
do idx = 1, ncontact_pair
gap = contact_pair_gap_value(idx)
gap_residual = max(gap_residual, gap)
gap_sum = gap_sum + gap
gap_sq = gap_sq + gap * gap
active_set_flip = active_set_flip + &
contact_pair_activation_value(idx) + contact_pair_release_value(idx)
count = count + 1
end do
if (count .gt. 0) then
gap_mean = gap_sum / real(count, rk)
gap_l2 = sqrt(gap_sq)
end if
end subroutine output_csv_contact_gap_stats
subroutine output_csv_contact_slip_stats(pair, slip_increment, &
slip_residual, friction_residual)
integer, intent(in) :: pair
real(rk), intent(out) :: slip_increment
real(rk), intent(out) :: slip_residual
real(rk), intent(out) :: friction_residual
integer :: idx
real(rk) :: tangent_norm
slip_increment = ZERO
slip_residual = ZERO
friction_residual = ZERO
if (pair .gt. 0) then
slip_increment = contact_pair_accumulated_slip(pair)
if (contact_pair_slip_value(pair) .gt. 0) slip_residual = slip_increment
friction_residual = sqrt( &
contact_pair_tangent_component(pair, 1) ** 2 + &
contact_pair_tangent_component(pair, 2) ** 2 + &
contact_pair_tangent_component(pair, 3) ** 2)
return
end if
if (ncontact_pair .le. 0) return
do idx = 1, ncontact_pair
slip_increment = max(slip_increment, &
contact_pair_accumulated_slip(idx))
if (contact_pair_slip_value(idx) .gt. 0) then
slip_residual = max(slip_residual, &
contact_pair_accumulated_slip(idx))
end if
tangent_norm = sqrt( &
contact_pair_tangent_component(idx, 1) ** 2 + &
contact_pair_tangent_component(idx, 2) ** 2 + &
contact_pair_tangent_component(idx, 3) ** 2)
friction_residual = max(friction_residual, tangent_norm)
end do
end subroutine output_csv_contact_slip_stats
+236 -6
View File
@@ -56,6 +56,8 @@ contains
if (ios .ne. 0) go to 900
call contact_multiplier_write(unit_id, ios)
if (ios .ne. 0) go to 900
call write_contact_pair_diag(unit_id, ios)
if (ios .ne. 0) go to 900
write(unit_id,'(A)',iostat=ios) 'END'
if (ios .ne. 0) go to 900
@@ -102,7 +104,7 @@ contains
read(unit_id,*,iostat=ios) tag, version
if (ios .ne. 0 .or. trim(tag) .ne. 'FEMLITE_RESTART') go to 910
if (version .lt. 1 .or. version .gt. 3) then
if (version .lt. 1 .or. version .gt. 4) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'unsupported restart version', ierr)
return
@@ -168,7 +170,7 @@ contains
integer, intent(in) :: unit_id
integer, intent(out) :: ios
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 3
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 4
if (ios .ne. 0) return
write(unit_id,'(A,4(1X,I12))',iostat=ios) 'COUNTS', nnode, nelem, &
ndof, ngauss_total
@@ -218,8 +220,8 @@ contains
end if
call contact_multiplier_read(unit_id, mult_slots, ierr)
if (ierr .ne. FEM_SUCCESS) return
read(unit_id,*,iostat=ios) tag
if (ios .ne. 0 .or. trim(tag) .ne. 'END') go to 920
call read_diag_or_end(unit_id, ierr)
if (ierr .ne. FEM_SUCCESS) return
else if (trim(tag) .eq. 'END') then
call contact_multiplier_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
@@ -236,8 +238,8 @@ contains
end if
call contact_multiplier_read(unit_id, mult_slots, ierr)
if (ierr .ne. FEM_SUCCESS) return
read(unit_id,*,iostat=ios) tag
if (ios .ne. 0 .or. trim(tag) .ne. 'END') go to 920
call read_diag_or_end(unit_id, ierr)
if (ierr .ne. FEM_SUCCESS) return
else if (trim(tag) .eq. 'END') then
call contact_history_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
@@ -255,6 +257,234 @@ contains
call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr)
end subroutine read_restart_tail
subroutine write_contact_pair_diag(unit_id, ios)
integer, intent(in) :: unit_id
integer, intent(out) :: ios
integer :: pair
integer :: active_value
integer :: prev_active_value
integer :: status_value
integer :: activation_value
integer :: release_value
integer :: stick_value
integer :: slip_value
real(rk) :: work_value
real(rk) :: max_pen_value
real(rk) :: force_value
real(rk) :: gap_value
real(rk) :: tangent_value(NDIM)
real(rk) :: slip_accum_value
real(rk) :: fric_work_value
real(rk) :: fric_total_value
real(rk) :: aug_lambda_value
write(unit_id,'(A,1X,I12,1X,I12,6(1X,ES24.16))',iostat=ios) &
'CONTACT_PAIR_DIAGNOSTICS', ncontact_pair, contact_active_count, &
contact_work_step, contact_work_total, contact_max_penetration, &
contact_force_norm, contact_friction_work_step, &
contact_friction_work_total
if (ios .ne. 0) return
do pair = 1, ncontact_pair
active_value = 0
prev_active_value = 0
status_value = 0
activation_value = 0
release_value = 0
stick_value = 0
slip_value = 0
work_value = ZERO
max_pen_value = ZERO
force_value = ZERO
gap_value = ZERO
tangent_value = ZERO
slip_accum_value = ZERO
fric_work_value = ZERO
fric_total_value = ZERO
aug_lambda_value = ZERO
if (allocated(contact_pair_active)) active_value = contact_pair_active(pair)
if (allocated(contact_pair_prev_active)) then
prev_active_value = contact_pair_prev_active(pair)
end if
if (allocated(contact_pair_status)) status_value = contact_pair_status(pair)
if (allocated(contact_pair_activation_count)) then
activation_value = contact_pair_activation_count(pair)
end if
if (allocated(contact_pair_release_count)) then
release_value = contact_pair_release_count(pair)
end if
if (allocated(contact_pair_stick_count)) then
stick_value = contact_pair_stick_count(pair)
end if
if (allocated(contact_pair_slip_count)) slip_value = contact_pair_slip_count(pair)
if (allocated(contact_pair_work)) work_value = contact_pair_work(pair)
if (allocated(contact_pair_max_penetration)) then
max_pen_value = contact_pair_max_penetration(pair)
end if
if (allocated(contact_pair_force_norm)) force_value = contact_pair_force_norm(pair)
if (allocated(contact_pair_gap_residual)) gap_value = contact_pair_gap_residual(pair)
if (allocated(contact_pair_tangent_force)) then
tangent_value = contact_pair_tangent_force(:,pair)
end if
if (allocated(contact_pair_slip)) slip_accum_value = contact_pair_slip(pair)
if (allocated(contact_pair_friction_work)) then
fric_work_value = contact_pair_friction_work(pair)
end if
if (allocated(contact_pair_fric_work_total)) then
fric_total_value = contact_pair_fric_work_total(pair)
end if
if (allocated(contact_pair_aug_lambda)) then
aug_lambda_value = contact_pair_aug_lambda(pair)
end if
write(unit_id,'(8(I12,1X),11(ES24.16,1X))',iostat=ios) &
pair, active_value, prev_active_value, status_value, &
activation_value, release_value, stick_value, slip_value, &
work_value, max_pen_value, force_value, gap_value, &
tangent_value(1), tangent_value(2), tangent_value(3), &
slip_accum_value, fric_work_value, fric_total_value, &
aug_lambda_value
if (ios .ne. 0) return
end do
end subroutine write_contact_pair_diag
subroutine read_diag_or_end(unit_id, ierr)
integer, intent(in) :: unit_id
integer, intent(out) :: ierr
character(len=256) :: line
character(len=32) :: tag
integer :: ios
integer :: pair_count
integer :: active_saved
real(rk) :: work_step_saved
real(rk) :: work_total_saved
real(rk) :: max_pen_saved
real(rk) :: force_norm_saved
real(rk) :: fric_step_saved
real(rk) :: fric_total_saved
read(unit_id,'(A)',iostat=ios) line
if (ios .ne. 0) then
call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr)
return
end if
read(line,*,iostat=ios) tag
if (ios .ne. 0) then
call error_set(FEM_ERR_OUTPUT, 'invalid restart tail marker', ierr)
return
end if
if (trim(tag) .eq. 'END') then
ierr = FEM_SUCCESS
return
end if
if (trim(tag) .ne. 'CONTACT_PAIR_DIAGNOSTICS') then
call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr)
return
end if
read(line,*,iostat=ios) tag, pair_count, active_saved, &
work_step_saved, work_total_saved, max_pen_saved, force_norm_saved, &
fric_step_saved, fric_total_saved
if (ios .ne. 0) then
call error_set(FEM_ERR_OUTPUT, 'invalid restart contact diagnostics', ierr)
return
end if
contact_active_count = active_saved
contact_work_step = work_step_saved
contact_work_total = work_total_saved
contact_max_penetration = max_pen_saved
contact_force_norm = force_norm_saved
contact_friction_work_step = fric_step_saved
contact_friction_work_total = fric_total_saved
call read_contact_pair_diag_rows(unit_id, pair_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
read(unit_id,*,iostat=ios) tag
if (ios .ne. 0 .or. trim(tag) .ne. 'END') then
call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr)
return
end if
ierr = FEM_SUCCESS
end subroutine read_diag_or_end
subroutine read_contact_pair_diag_rows(unit_id, pair_count, ierr)
integer, intent(in) :: unit_id
integer, intent(in) :: pair_count
integer, intent(out) :: ierr
integer :: row
integer :: pair
integer :: active_value
integer :: prev_active_value
integer :: status_value
integer :: activation_value
integer :: release_value
integer :: stick_value
integer :: slip_value
integer :: ios
real(rk) :: work_value
real(rk) :: max_pen_value
real(rk) :: force_value
real(rk) :: gap_value
real(rk) :: tangent_value(NDIM)
real(rk) :: slip_accum_value
real(rk) :: fric_work_value
real(rk) :: fric_total_value
real(rk) :: aug_lambda_value
if (pair_count .ne. ncontact_pair) then
call error_set(FEM_ERR_OUTPUT, &
'restart contact diagnostic pair count does not match', ierr)
return
end if
do row = 1, pair_count
read(unit_id,*,iostat=ios) pair, active_value, prev_active_value, &
status_value, activation_value, release_value, stick_value, &
slip_value, work_value, max_pen_value, force_value, gap_value, &
tangent_value(1), tangent_value(2), tangent_value(3), &
slip_accum_value, fric_work_value, fric_total_value, &
aug_lambda_value
if (ios .ne. 0 .or. pair .lt. 1 .or. pair .gt. ncontact_pair) then
call error_set(FEM_ERR_OUTPUT, 'invalid restart contact diagnostics', &
ierr)
return
end if
if (allocated(contact_pair_active)) contact_pair_active(pair) = active_value
if (allocated(contact_pair_prev_active)) then
contact_pair_prev_active(pair) = prev_active_value
end if
if (allocated(contact_pair_status)) contact_pair_status(pair) = status_value
if (allocated(contact_pair_activation_count)) then
contact_pair_activation_count(pair) = activation_value
end if
if (allocated(contact_pair_release_count)) then
contact_pair_release_count(pair) = release_value
end if
if (allocated(contact_pair_stick_count)) contact_pair_stick_count(pair) = stick_value
if (allocated(contact_pair_slip_count)) contact_pair_slip_count(pair) = slip_value
if (allocated(contact_pair_work)) contact_pair_work(pair) = work_value
if (allocated(contact_pair_max_penetration)) then
contact_pair_max_penetration(pair) = max_pen_value
end if
if (allocated(contact_pair_force_norm)) contact_pair_force_norm(pair) = force_value
if (allocated(contact_pair_gap_residual)) contact_pair_gap_residual(pair) = gap_value
if (allocated(contact_pair_tangent_force)) then
contact_pair_tangent_force(:,pair) = tangent_value
end if
if (allocated(contact_pair_slip)) contact_pair_slip(pair) = slip_accum_value
if (allocated(contact_pair_friction_work)) then
contact_pair_friction_work(pair) = fric_work_value
end if
if (allocated(contact_pair_fric_work_total)) then
contact_pair_fric_work_total(pair) = fric_total_value
end if
if (allocated(contact_pair_aug_lambda)) then
contact_pair_aug_lambda(pair) = aug_lambda_value
end if
end do
ierr = FEM_SUCCESS
end subroutine read_contact_pair_diag_rows
subroutine write_restart_dofs(unit_id, ios)
integer, intent(in) :: unit_id
integer, intent(out) :: ios
+3 -1
View File
@@ -1,7 +1,8 @@
module fem_linear_solver_cg
use fem_linear_solver_dispatch, only: linear_solver_solve, &
linear_solver_configure, linear_solver_get_settings, &
linear_solver_get_stats, linear_solver_get_diagnostics
linear_solver_get_stats, linear_solver_get_diagnostics, &
linear_solver_get_fail_info
use fem_linear_solver_iterative, only: linear_cg_solve, &
linear_bicgstab_solve, linear_gmres_solve
implicit none
@@ -11,6 +12,7 @@ module fem_linear_solver_cg
public :: linear_solver_get_settings
public :: linear_solver_get_stats
public :: linear_solver_get_diagnostics
public :: linear_solver_get_fail_info
public :: linear_cg_solve
public :: linear_bicgstab_solve
public :: linear_gmres_solve
+87 -6
View File
@@ -4,7 +4,7 @@ module fem_linear_solver_dispatch
use fem_control
use fem_sparse_csr
use fem_sparse_csr_diagnostics, only: csr_profile, csr_analyze, &
csr_residual_norm
csr_residual_norm, CSR_CLASS_SPD_CAND
use fem_linear_solver_iterative
use fem_linear_solver_dense
implicit none
@@ -16,6 +16,7 @@ module fem_linear_solver_dispatch
public :: linear_solver_get_settings
public :: linear_solver_get_stats
public :: linear_solver_get_diagnostics
public :: linear_solver_get_fail_info
contains
@@ -37,12 +38,16 @@ contains
real(rk) :: final_resid
real(rk) :: final_rel_resid
integer :: matrix_class
integer :: failure_class
integer :: audit_ierr
character(len=64) :: reason_text
method = linear_solver_method
preconditioner = linear_precond_method
status = LS_STATUS_FAILED
matrix_class = 1
failure_class = LS_FAIL_NONE
reason_text = 'selected'
initial_resid = ZERO
initial_rel_resid = ZERO
final_resid = ZERO
@@ -52,9 +57,11 @@ contains
if (ierr .ne. FEM_SUCCESS) then
iter = 0
res_norm = ZERO
failure_class = LS_FAIL_DIAGNOSTIC
reason_text = 'csr-analysis-failure'
call linear_solver_record(method, preconditioner, iter, res_norm, &
status, matrix_class, initial_resid, &
final_rel_resid)
final_rel_resid, failure_class, reason_text)
return
end if
matrix_class = profile%class_id
@@ -63,9 +70,11 @@ contains
if (ierr .ne. FEM_SUCCESS) then
iter = 0
res_norm = ZERO
failure_class = LS_FAIL_DIAGNOSTIC
reason_text = 'initial-residual-audit-failure'
call linear_solver_record(method, preconditioner, iter, res_norm, &
status, matrix_class, initial_resid, &
final_rel_resid)
final_rel_resid, failure_class, reason_text)
return
end if
@@ -84,26 +93,34 @@ contains
case default
iter = 0
res_norm = ZERO
failure_class = LS_FAIL_CONFIGURATION
reason_text = 'unknown-linear-solver-method'
call error_set(FEM_ERR_SOLVER, 'unknown linear solver method', ierr)
end select
if (ierr .ne. FEM_SUCCESS) then
if (failure_class .eq. LS_FAIL_NONE) then
failure_class = linear_solver_classify_failure(method, matrix_class)
call linear_solver_reason_text(method, failure_class, reason_text)
end if
call csr_residual_norm(a, b, x, final_resid, final_rel_resid, &
audit_ierr)
if (audit_ierr .eq. FEM_SUCCESS) res_norm = final_resid
call linear_solver_record(method, preconditioner, iter, res_norm, &
status, matrix_class, initial_resid, &
final_rel_resid)
final_rel_resid, failure_class, reason_text)
return
end if
status = LS_STATUS_CONVERGED
failure_class = LS_FAIL_NONE
call linear_solver_reason_text(method, failure_class, reason_text)
call csr_residual_norm(a, b, x, final_resid, final_rel_resid, &
audit_ierr)
if (audit_ierr .eq. FEM_SUCCESS) res_norm = final_resid
call linear_solver_record(method, preconditioner, iter, res_norm, &
status, matrix_class, initial_resid, &
final_rel_resid)
final_rel_resid, failure_class, reason_text)
end subroutine linear_solver_solve
subroutine linear_solver_configure(method, preconditioner, ierr)
@@ -174,9 +191,20 @@ contains
ierr = FEM_SUCCESS
end subroutine linear_solver_get_diagnostics
subroutine linear_solver_get_fail_info(failure_class, reason, ierr)
integer, intent(out) :: failure_class
character(len=*), intent(out) :: reason
integer, intent(out) :: ierr
failure_class = linsol_last_fail_class
reason = linear_solver_last_reason
ierr = FEM_SUCCESS
end subroutine linear_solver_get_fail_info
subroutine linear_solver_record(method, preconditioner, iteration, &
residual_norm, status_code, matrix_class, &
initial_residual, relative_residual)
initial_residual, relative_residual, &
failure_class, reason)
integer, intent(in) :: method
integer, intent(in) :: preconditioner
integer, intent(in) :: iteration
@@ -185,6 +213,8 @@ contains
integer, intent(in) :: matrix_class
real(rk), intent(in) :: initial_residual
real(rk), intent(in) :: relative_residual
integer, intent(in) :: failure_class
character(len=*), intent(in) :: reason
linear_solver_last_method = method
linear_solver_last_prec = preconditioner
@@ -194,6 +224,57 @@ contains
linear_solver_last_matrix_class = matrix_class
linear_solver_initial_resid = initial_residual
linear_solver_relative_resid = relative_residual
linsol_last_fail_class = failure_class
linear_solver_last_reason = reason
end subroutine linear_solver_record
integer function linear_solver_classify_failure(method, matrix_class) &
result(failure_class)
integer, intent(in) :: method
integer, intent(in) :: matrix_class
select case (method)
case (LSOLVER_CG)
if (matrix_class .lt. CSR_CLASS_SPD_CAND) then
failure_class = LS_FAIL_INVALID_MATRIX
else
failure_class = LS_FAIL_NONCONVERGENCE
end if
case (LSOLVER_DENSE)
failure_class = LS_FAIL_DENSE_FALLBACK
case (LSOLVER_BICGSTAB, LSOLVER_GMRES)
failure_class = LS_FAIL_NONCONVERGENCE
case default
failure_class = LS_FAIL_CONFIGURATION
end select
end function linear_solver_classify_failure
subroutine linear_solver_reason_text(method, failure_class, reason)
integer, intent(in) :: method
integer, intent(in) :: failure_class
character(len=*), intent(out) :: reason
character(len=24) :: method_name
character(len=40) :: class_name
select case (method)
case (LSOLVER_CG)
method_name = 'cg'
case (LSOLVER_BICGSTAB)
method_name = 'bicgstab'
case (LSOLVER_GMRES)
method_name = 'gmres'
case (LSOLVER_DENSE)
method_name = 'dense'
case default
method_name = 'unknown'
end select
call linsol_fail_class_name(failure_class, class_name)
if (failure_class .eq. LS_FAIL_NONE) then
reason = trim(method_name)//'-selected'
else
reason = trim(method_name)//'-'//trim(class_name)
end if
end subroutine linear_solver_reason_text
end module fem_linear_solver_dispatch
+1
View File
@@ -280,6 +280,7 @@ contains
convergence_last_accepted_time = current_time
convergence_status_code = CONVERGENCE_STATUS_ITERATING
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
nlc_last_target_dt = ZERO
nlc_last_actual_dt = ZERO
nlc_next_target_dt = ZERO
+30 -1
View File
@@ -64,10 +64,17 @@ contains
convergence_correction_norm = ZERO
convergence_contact_gap_norm = ZERO
convergence_combined_norm = ZERO
convergence_total_resid_norm = ZERO
convergence_force_resid_norm = ZERO
convergence_contact_resid_norm = ZERO
convergence_cons_resid_norm = ZERO
convergence_arc_resid_norm = ZERO
convergence_material_fail_count = 0
convergence_last_dt = dt
convergence_converged = .false.
convergence_status_code = CONVERGENCE_STATUS_ITERATING
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
end subroutine begin_newmark_convergence
subroutine begin_static_convergence(increment_id, dt_inc)
@@ -81,10 +88,17 @@ contains
convergence_correction_norm = ZERO
convergence_contact_gap_norm = ZERO
convergence_combined_norm = ZERO
convergence_total_resid_norm = ZERO
convergence_force_resid_norm = ZERO
convergence_contact_resid_norm = ZERO
convergence_cons_resid_norm = ZERO
convergence_arc_resid_norm = ZERO
convergence_material_fail_count = 0
convergence_last_dt = dt_inc
convergence_converged = .false.
convergence_status_code = CONVERGENCE_STATUS_ITERATING
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
nlc_last_damping = ONE
nlc_last_merit_ratio = ZERO
nlc_last_rejections = 0
@@ -131,14 +145,25 @@ contains
convergence_converged = .true.
convergence_status_code = CONVERGENCE_STATUS_CONVERGED
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
end subroutine mark_convergence_success
subroutine mark_convergence_failure(failure_code)
subroutine mark_convergence_failure(failure_code, reason_id)
integer, intent(in) :: failure_code
integer, intent(in), optional :: reason_id
convergence_converged = .false.
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = failure_code
if (present(reason_id)) then
convergence_failure_reason_id = reason_id
else if (failure_code .eq. CONV_FAIL_NONCONVERGENCE .and. &
linear_solver_last_status .eq. LS_STATUS_FAILED) then
convergence_failure_reason_id = NFAIL_LINEAR_SOLVE
else
convergence_failure_reason_id = &
convergence_reason_from_failure(failure_code)
end if
end subroutine mark_convergence_failure
subroutine update_convergence_metrics(res_norm, ref_norm)
@@ -154,6 +179,10 @@ contains
if (allocated(contact_pair_gap_residual)) then
convergence_contact_gap_norm = maxval(contact_pair_gap_residual)
end if
convergence_total_resid_norm = res_norm
convergence_force_resid_norm = res_norm
convergence_contact_resid_norm = convergence_contact_gap_norm
convergence_cons_resid_norm = ZERO
convergence_combined_norm = max(convergence_rel_resid_norm, &
max(convergence_correction_norm, convergence_contact_gap_norm))
end subroutine update_convergence_metrics
@@ -60,6 +60,7 @@ contains
if (.not. arc_disp_mode) then
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_STOPPED
convergence_failure_reason_id = NFAIL_ARC_CONSTRAINT
nlc_last_adjust = NLC_ADJ_FAILED
call error_set(FEM_ERR_SOLVER, &
'METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL requires a nonzero '// &
@@ -342,6 +343,7 @@ contains
current_time = sub_target_time
convergence_last_accepted_time = current_time
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
current_step = current_step + 1
nlc_last_iter = iter_inc
nlc_last_actual_dt = dt_try
@@ -435,6 +437,7 @@ contains
convergence_last_dt = dt_try
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
nlc_last_adjust = NLC_ADJ_CUTBACK
nlc_next_target_dt = dt_try
call error_clear(ierr)
@@ -448,6 +451,11 @@ contains
if (use_static_predictor) u = u_equil
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT
if (linear_solver_last_status .eq. LS_STATUS_FAILED) then
convergence_failure_reason_id = NFAIL_LINEAR_SOLVE
else
convergence_failure_reason_id = NFAIL_MIN_STEP
end if
nlc_last_adjust = NLC_ADJ_FAILED
nlc_next_target_dt = ZERO
end subroutine fail_static_increment
@@ -503,6 +511,7 @@ contains
current_time = sub_target_time
convergence_last_accepted_time = current_time
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
current_step = current_step + 1
nlc_last_iter = iter_inc
nlc_last_actual_dt = dt_try
@@ -521,12 +530,18 @@ contains
convergence_last_dt = dt_try
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
nlc_last_adjust = NLC_ADJ_CUTBACK
nlc_next_target_dt = dt_try
ierr = FEM_SUCCESS
else
convergence_status_code = CONVERGENCE_STATUS_FAILED
convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT
if (linear_solver_last_status .eq. LS_STATUS_FAILED) then
convergence_failure_reason_id = NFAIL_LINEAR_SOLVE
else
convergence_failure_reason_id = NFAIL_MIN_STEP
end if
nlc_last_adjust = NLC_ADJ_FAILED
nlc_next_target_dt = ZERO
return
@@ -999,6 +1014,7 @@ contains
iter_used = iter
call record_convergence_iteration(iter, res_norm, ref_norm, &
correction_norm)
convergence_arc_resid_norm = abs(arc_residual)
if ((res_norm .le. tol .or. res_norm / ref_norm .le. tol) .and. &
abs(arc_residual) .le. arc_tol) then
converged = .true.