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

This commit is contained in:
shenw
2026-07-01 20:44:15 +08:00
parent 2b7962eb96
commit 175531e24d
33 changed files with 2318 additions and 298 deletions
+9
View File
@@ -8,6 +8,8 @@ module fem_api
use fem_element_mass
use fem_element_internal
use fem_solver_implicit
use fem_nonlinear_lifecycle, only: NLC_EVENT_CUTBACK, NLC_EVENT_REJECT, &
nl_lifecycle_record_event, nl_lifecycle_reset
use fem_coupling
use fem_boundary
use fem_contact
@@ -28,6 +30,7 @@ contains
call error_clear(ierr)
call control_set_defaults()
call contact_reset_search_stats()
call nl_lifecycle_reset()
call log_open('femlite.log', log_ierr)
if (log_ierr .ne. FEM_SUCCESS) then
call error_set(FEM_ERR_OUTPUT, 'failed to open femlite.log', ierr)
@@ -42,6 +45,7 @@ contains
integer, intent(out) :: ierr
call cpl_finalize_facets()
call contact_reset_search_stats()
call nl_lifecycle_reset()
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) return
call log_info('FemLite finalized')
@@ -667,6 +671,8 @@ contains
convergence_status_code = CONVERGENCE_STATUS_CUTBACK
convergence_failure_code = CONV_FAIL_NONE
convergence_failure_reason_id = NFAIL_NONE
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter, NLC_EVENT_CUTBACK, NFAIL_NONE)
ierr = FEM_SUCCESS
else
convergence_cutback_count = total_cutback
@@ -677,6 +683,9 @@ contains
else
convergence_failure_reason_id = NFAIL_MIN_STEP
end if
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter, NLC_EVENT_REJECT, &
convergence_failure_reason_id)
return
end if
end do
+94
View File
@@ -5,6 +5,9 @@ module fem_api_diagnostics
use fem_linear_solver_cg, only: linear_solver_configure, &
linear_solver_get_settings, linear_solver_get_stats, &
linear_solver_get_diagnostics, linear_solver_get_fail_info
use fem_nonlinear_lifecycle, only: nl_lifecycle_get_arc_state, &
nl_lifecycle_get_audit, &
nl_lifecycle_get_snapshot
use fem_api_state, only: api_initialized
implicit none
private
@@ -14,6 +17,9 @@ module fem_api_diagnostics
public :: fem_get_convergence_diagnostics
public :: fem_get_convergence_reason
public :: fem_get_residual_breakdown
public :: fem_get_nl_lifecycle_snapshot
public :: fem_get_nl_lifecycle_arc
public :: fem_get_nl_lifecycle_audit
public :: fem_get_continuation_path_count
public :: fem_get_continuation_path_row
public :: fem_set_linear_solver
@@ -207,6 +213,94 @@ contains
ierr = FEM_SUCCESS
end subroutine fem_get_residual_breakdown
subroutine fem_get_nl_lifecycle_snapshot(step, increment, iteration, &
event_id, event_name, reason_id, &
reason_name, ierr)
integer, intent(out) :: step
integer, intent(out) :: increment
integer, intent(out) :: iteration
integer, intent(out) :: event_id
character(len=*), intent(out) :: event_name
integer, intent(out) :: reason_id
character(len=*), intent(out) :: reason_name
integer, intent(out) :: ierr
step = 0
increment = 0
iteration = 0
event_id = 0
event_name = 'none'
reason_id = NFAIL_NONE
reason_name = 'none'
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_nl_lifecycle_snapshot called before fem_initialize', &
ierr)
return
end if
call nl_lifecycle_get_snapshot(step, increment, iteration, event_id, &
event_name, reason_id, reason_name)
ierr = FEM_SUCCESS
end subroutine fem_get_nl_lifecycle_snapshot
subroutine fem_get_nl_lifecycle_arc(load_factor, arc_residual, &
path_appended, ierr)
real(rk), intent(out) :: load_factor
real(rk), intent(out) :: arc_residual
logical, intent(out) :: path_appended
integer, intent(out) :: ierr
load_factor = ZERO
arc_residual = ZERO
path_appended = .false.
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_nl_lifecycle_arc called before fem_initialize', ierr)
return
end if
call nl_lifecycle_get_arc_state(load_factor, arc_residual, path_appended)
ierr = FEM_SUCCESS
end subroutine fem_get_nl_lifecycle_arc
subroutine fem_get_nl_lifecycle_audit(status_id, status_name, &
begin_trial_count, &
rollback_requested_count, &
rollback_ok_count, &
rollback_failed_count, &
commit_ok_count, ierr)
integer, intent(out) :: status_id
character(len=*), intent(out) :: status_name
integer, intent(out) :: begin_trial_count
integer, intent(out) :: rollback_requested_count
integer, intent(out) :: rollback_ok_count
integer, intent(out) :: rollback_failed_count
integer, intent(out) :: commit_ok_count
integer, intent(out) :: ierr
status_id = 0
status_name = 'none'
begin_trial_count = 0
rollback_requested_count = 0
rollback_ok_count = 0
rollback_failed_count = 0
commit_ok_count = 0
if (.not. api_initialized) then
call error_set(FEM_ERR_INTERNAL, &
'fem_get_nl_lifecycle_audit called before fem_initialize', ierr)
return
end if
call nl_lifecycle_get_audit(status_id, status_name, begin_trial_count, &
rollback_requested_count, rollback_ok_count, &
rollback_failed_count, commit_ok_count)
ierr = FEM_SUCCESS
end subroutine fem_get_nl_lifecycle_audit
subroutine fem_get_continuation_path_count(count, ierr)
integer, intent(out) :: count
integer, intent(out) :: ierr
+2 -2
View File
@@ -15,8 +15,8 @@ module fem_precision
integer, parameter :: NSTATEV_MAX = 32
integer, parameter :: FEMLITE_VERSION_MAJOR = 0
integer, parameter :: FEMLITE_VERSION_MINOR = 5
integer, parameter :: FEMLITE_VERSION_PATCH = 3
integer, parameter :: FEMLITE_VERSION_MINOR = 6
integer, parameter :: FEMLITE_VERSION_PATCH = 0
real(rk), parameter :: ZERO = 0.0_rk
real(rk), parameter :: ONE = 1.0_rk
+47 -1
View File
@@ -2,6 +2,10 @@ module fem_cohesive_state
use fem_precision
use fem_error
use fem_cohesive_law
use fem_nonlinear_lifecycle, only: NLC_AUDIT_BEGIN_TRIAL, &
NLC_AUDIT_COMMIT_OK, NLC_AUDIT_ROLLBACK_FAILED, &
NLC_AUDIT_ROLLBACK_OK, NLC_AUDIT_ROLLBACK_REQUESTED, &
nl_lifecycle_record_audit
implicit none
private
@@ -34,6 +38,7 @@ module fem_cohesive_state
real(rk), allocatable :: coh_trial_energy(:)
integer :: coh_count = 0
integer :: coh_capacity = 0
integer :: coh_audit_slot_count = 0
contains
@@ -49,9 +54,12 @@ contains
end if
coh_count = 0
coh_capacity = 0
coh_audit_slot_count = 0
end subroutine cohesive_state_reset
subroutine cohesive_state_begin_trial()
coh_audit_slot_count = coh_count
call nl_lifecycle_record_audit(NLC_AUDIT_BEGIN_TRIAL)
if (coh_count .le. 0 .or. .not. allocated(coh_damage)) return
coh_trial_damage(1:coh_count) = coh_damage(1:coh_count)
coh_trial_opening(1:coh_count) = coh_max_opening(1:coh_count)
@@ -109,16 +117,54 @@ contains
coh_max_opening(1:coh_count) = coh_trial_opening(1:coh_count)
coh_max_effective(1:coh_count) = coh_trial_effective(1:coh_count)
coh_energy(1:coh_count) = coh_trial_energy(1:coh_count)
call nl_lifecycle_record_audit(NLC_AUDIT_COMMIT_OK)
end subroutine cohesive_state_commit
subroutine cohesive_state_rollback()
if (coh_count .le. 0 .or. .not. allocated(coh_damage)) return
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_REQUESTED)
if (coh_count .le. 0 .or. .not. allocated(coh_damage)) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_OK)
return
end if
coh_trial_damage(1:coh_count) = coh_damage(1:coh_count)
coh_trial_opening(1:coh_count) = coh_max_opening(1:coh_count)
coh_trial_effective(1:coh_count) = coh_max_effective(1:coh_count)
coh_trial_energy(1:coh_count) = coh_energy(1:coh_count)
if (cohesive_state_rollback_ok()) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_OK)
else
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_FAILED)
end if
end subroutine cohesive_state_rollback
logical function cohesive_state_rollback_ok()
real(rk) :: max_error
real(rk) :: max_scale
cohesive_state_rollback_ok = .false.
if (coh_count .ne. coh_audit_slot_count) return
if (coh_count .le. 0) then
cohesive_state_rollback_ok = .true.
return
end if
if (.not. allocated(coh_damage) .or. &
.not. allocated(coh_trial_damage)) return
max_error = max(maxval(abs(coh_trial_damage(1:coh_count) - &
coh_damage(1:coh_count))), &
max(maxval(abs(coh_trial_opening(1:coh_count) - &
coh_max_opening(1:coh_count))), &
max(maxval(abs(coh_trial_effective(1:coh_count) - &
coh_max_effective(1:coh_count))), &
maxval(abs(coh_trial_energy(1:coh_count) - &
coh_energy(1:coh_count))))))
max_scale = max(ONE, maxval(abs(coh_damage(1:coh_count))), &
maxval(abs(coh_max_opening(1:coh_count))), &
maxval(abs(coh_max_effective(1:coh_count))), &
maxval(abs(coh_energy(1:coh_count))))
cohesive_state_rollback_ok = max_error .le. &
100.0_rk * epsilon(ONE) * max_scale
end function cohesive_state_rollback_ok
subroutine cohesive_state_old(pair, selem, sface, melem, mface, point_id, &
damage, max_opening, max_effective, energy, &
status)
+38 -1
View File
@@ -5,6 +5,10 @@ module fem_contact_multiplier
CONTACT_STATE_CLOSED_STICK, CONTACT_STATE_CLOSED_SLIP, &
CONTACT_STATE_CLOSED_RESTICK, CONTACT_STATE_SEPARATING, &
CONTACT_STATE_FAILED_PROJ
use fem_nonlinear_lifecycle, only: NLC_AUDIT_BEGIN_TRIAL, &
NLC_AUDIT_COMMIT_OK, NLC_AUDIT_ROLLBACK_FAILED, &
NLC_AUDIT_ROLLBACK_OK, NLC_AUDIT_ROLLBACK_REQUESTED, &
nl_lifecycle_record_audit
implicit none
private
@@ -42,6 +46,7 @@ module fem_contact_multiplier
real(rk), allocatable :: mult_trial_gap(:)
integer :: mult_count = 0
integer :: mult_capacity = 0
integer :: mult_audit_slot_count = 0
contains
@@ -53,9 +58,12 @@ contains
mult_trial_gap)
mult_count = 0
mult_capacity = 0
mult_audit_slot_count = 0
end subroutine contact_multiplier_reset
subroutine contact_multiplier_begin_trial()
mult_audit_slot_count = mult_count
call nl_lifecycle_record_audit(NLC_AUDIT_BEGIN_TRIAL)
if (mult_count .le. 0 .or. .not. allocated(mult_lambda)) return
mult_trial_lambda(1:mult_count) = mult_lambda(1:mult_count)
mult_trial_gap(1:mult_count) = ZERO
@@ -100,14 +108,43 @@ contains
subroutine contact_multiplier_commit()
if (mult_count .le. 0 .or. .not. allocated(mult_lambda)) return
mult_lambda(1:mult_count) = mult_trial_lambda(1:mult_count)
call nl_lifecycle_record_audit(NLC_AUDIT_COMMIT_OK)
end subroutine contact_multiplier_commit
subroutine contact_multiplier_rollback()
if (mult_count .le. 0 .or. .not. allocated(mult_lambda)) return
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_REQUESTED)
if (mult_count .le. 0 .or. .not. allocated(mult_lambda)) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_OK)
return
end if
mult_trial_lambda(1:mult_count) = mult_lambda(1:mult_count)
mult_trial_gap(1:mult_count) = ZERO
if (contact_multiplier_rollback_ok()) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_OK)
else
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_FAILED)
end if
end subroutine contact_multiplier_rollback
logical function contact_multiplier_rollback_ok()
real(rk) :: max_error
contact_multiplier_rollback_ok = .false.
if (mult_count .ne. mult_audit_slot_count) return
if (mult_count .le. 0) then
contact_multiplier_rollback_ok = .true.
return
end if
if (.not. allocated(mult_lambda) .or. &
.not. allocated(mult_trial_lambda) .or. &
.not. allocated(mult_trial_gap)) return
max_error = max(maxval(abs(mult_trial_lambda(1:mult_count) - &
mult_lambda(1:mult_count))), &
maxval(abs(mult_trial_gap(1:mult_count))))
contact_multiplier_rollback_ok = max_error .le. &
100.0_rk * epsilon(ONE) * max(ONE, maxval(abs(mult_lambda(1:mult_count))))
end function contact_multiplier_rollback_ok
subroutine contact_multiplier_old(pair, selem, sface, melem, mface, &
point_id, lambda_value)
integer, intent(in) :: pair
+64 -1
View File
@@ -4,6 +4,10 @@ module fem_element_state
use fem_database
use fem_element_topology
use fem_shell_rotation
use fem_nonlinear_lifecycle, only: NLC_AUDIT_BEGIN_TRIAL, &
NLC_AUDIT_COMMIT_OK, NLC_AUDIT_ROLLBACK_FAILED, &
NLC_AUDIT_ROLLBACK_OK, NLC_AUDIT_ROLLBACK_REQUESTED, &
nl_lifecycle_record_audit
implicit none
private
@@ -17,6 +21,8 @@ module fem_element_state
real(rk), allocatable :: shell_layer_statev_backup(:,:)
integer, allocatable :: status_trial_backup(:)
logical :: trial_backup_active = .false.
logical :: trial_abort_in_progress = .false.
real(rk) :: trial_state_checksum = ZERO
integer, parameter :: SHELL_TP_PER_LAYER = 2
public :: element_state_ensure
@@ -219,6 +225,8 @@ contains
end if
status_trial_backup = elem_status
trial_backup_active = .true.
trial_state_checksum = element_state_checksum()
call nl_lifecycle_record_audit(NLC_AUDIT_BEGIN_TRIAL)
ierr = FEM_SUCCESS
end subroutine element_state_begin_trial
@@ -285,6 +293,10 @@ contains
subroutine element_state_commit_trial(ierr)
integer, intent(out) :: ierr
logical :: should_record_commit
should_record_commit = trial_backup_active .and. &
(.not. trial_abort_in_progress)
if (allocated(stress_trial_backup)) deallocate(stress_trial_backup)
if (allocated(strain_trial_backup)) deallocate(strain_trial_backup)
if (allocated(statev_trial_backup)) deallocate(statev_trial_backup)
@@ -296,17 +308,68 @@ contains
call shell_rotation_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) return
trial_backup_active = .false.
trial_state_checksum = ZERO
if (should_record_commit) then
call nl_lifecycle_record_audit(NLC_AUDIT_COMMIT_OK)
end if
ierr = FEM_SUCCESS
end subroutine element_state_commit_trial
subroutine element_state_abort_trial(ierr)
integer, intent(out) :: ierr
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_REQUESTED)
call element_state_restore_trial(ierr)
if (ierr .ne. FEM_SUCCESS) return
if (ierr .ne. FEM_SUCCESS) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_FAILED)
return
end if
if (abs(element_state_checksum() - trial_state_checksum) .le. &
100.0_rk * epsilon(ONE) * max(ONE, abs(trial_state_checksum))) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_OK)
else
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_FAILED)
end if
trial_abort_in_progress = .true.
call element_state_commit_trial(ierr)
trial_abort_in_progress = .false.
end subroutine element_state_abort_trial
real(rk) function element_state_checksum()
element_state_checksum = ZERO
if (allocated(stress)) then
element_state_checksum = element_state_checksum + sum(abs(stress))
end if
if (allocated(strain)) then
element_state_checksum = element_state_checksum + 2.0_rk * &
sum(abs(strain))
end if
if (allocated(statev)) then
element_state_checksum = element_state_checksum + 3.0_rk * &
sum(abs(statev))
end if
if (allocated(shell_resultant)) then
element_state_checksum = element_state_checksum + 4.0_rk * &
sum(abs(shell_resultant))
end if
if (allocated(shell_layer_stress)) then
element_state_checksum = element_state_checksum + 5.0_rk * &
sum(abs(shell_layer_stress))
end if
if (allocated(shell_layer_strain)) then
element_state_checksum = element_state_checksum + 6.0_rk * &
sum(abs(shell_layer_strain))
end if
if (allocated(shell_layer_statev)) then
element_state_checksum = element_state_checksum + 7.0_rk * &
sum(abs(shell_layer_statev))
end if
if (allocated(elem_status)) then
element_state_checksum = element_state_checksum + 8.0_rk * &
real(sum(abs(elem_status)), rk)
end if
end function element_state_checksum
subroutine state_count_shell_layers(ierr)
integer, intent(out) :: ierr
integer :: elem
+52 -3
View File
@@ -7,6 +7,9 @@ module fem_output_csv
use fem_contact_state, only: contact_get_search_stats, contact_get_perf_stats, &
contact_get_cache_stats, contact_get_pair_stats
use fem_element_state
use fem_nonlinear_lifecycle, only: NLC_EVENT_ACCEPT, NLC_EVENT_REJECT, &
nl_lifecycle_event_name, nl_lifecycle_get_audit, &
nl_lifecycle_get_event_count, nl_lifecycle_get_event
implicit none
character(len=256) :: csv_output_directory = '.'
@@ -345,7 +348,26 @@ contains
integer :: unit_id
integer :: ios
integer :: row
integer :: audit_status
integer :: audit_begin_trial
integer :: audit_rollback_requested
integer :: audit_rollback_ok
integer :: audit_rollback_failed
integer :: audit_commit_ok
integer :: lifecycle_event_total
integer :: lifecycle_event_index
integer :: lifecycle_step
integer :: lifecycle_increment
integer :: lifecycle_iteration
integer :: lifecycle_event_id
integer :: lifecycle_reason_id
integer :: lifecycle_accept_count
integer :: lifecycle_reject_count
character(len=64) :: reason_name
character(len=64) :: event_name
character(len=64) :: audit_name
character(len=64) :: lifecycle_name
character(len=64) :: lifecycle_reason_name
if (nlc_path_count .le. 0) then
ierr = FEM_SUCCESS
@@ -376,7 +398,10 @@ contains
'linear_final_residual,linear_relative_residual,'// &
'residual_total,residual_force,residual_contact,'// &
'residual_constraint,residual_arc,material_failure_count,'// &
'reason_id,reason_name'
'reason_id,reason_name,lifecycle_event_id,lifecycle_event_name,'// &
'lifecycle_audit_status,lifecycle_audit_name,'// &
'lifecycle_increment,lifecycle_iteration,'// &
'lifecycle_accept_count,lifecycle_reject_count'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, &
@@ -384,9 +409,27 @@ contains
return
end if
lifecycle_accept_count = 0
lifecycle_reject_count = 0
lifecycle_event_total = nl_lifecycle_get_event_count()
do lifecycle_event_index = 1, lifecycle_event_total
call nl_lifecycle_get_event(lifecycle_event_index, lifecycle_step, &
lifecycle_increment, lifecycle_iteration, lifecycle_event_id, &
lifecycle_name, lifecycle_reason_id, lifecycle_reason_name)
if (lifecycle_event_id .eq. NLC_EVENT_ACCEPT) then
lifecycle_accept_count = lifecycle_accept_count + 1
else if (lifecycle_event_id .eq. NLC_EVENT_REJECT) then
lifecycle_reject_count = lifecycle_reject_count + 1
end if
end do
do row = 1, nlc_path_count
call convergence_failure_reason_name( &
nlc_path_int(NLC_PATH_I_REASON_ID, row), reason_name)
call nl_lifecycle_event_name(NLC_EVENT_ACCEPT, event_name)
call nl_lifecycle_get_audit(audit_status, audit_name, &
audit_begin_trial, audit_rollback_requested, audit_rollback_ok, &
audit_rollback_failed, audit_commit_ok)
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, advance='no') &
@@ -437,9 +480,15 @@ contains
',', 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) &
write(unit_id,'(A,I12,A,A,A,I12,A,A,A,I12,A,A,4(A,I12))', &
iostat=ios) &
',', nlc_path_int(NLC_PATH_I_REASON_ID, row), &
',', trim(reason_name)
',', trim(reason_name), &
',', NLC_EVENT_ACCEPT, ',', trim(event_name), &
',', audit_status, ',', trim(audit_name), &
',', nlc_path_int(NLC_PATH_I_STEP, row), &
',', nlc_path_int(NLC_PATH_I_ITERATION, row), &
',', lifecycle_accept_count, ',', lifecycle_reject_count
end if
if (ios .ne. 0) then
close(unit_id)
+130 -3
View File
@@ -9,6 +9,9 @@ module fem_restart
use fem_contact_history, only: contact_history_write, contact_history_read
use fem_contact_multiplier, only: contact_multiplier_write, &
contact_multiplier_read
use fem_nonlinear_lifecycle, only: nl_lifecycle_get_snapshot, &
nl_lifecycle_get_arc_state, nl_lifecycle_get_audit, &
nl_lifecycle_restore
implicit none
private
@@ -58,6 +61,8 @@ contains
if (ios .ne. 0) go to 900
call write_contact_pair_diag(unit_id, ios)
if (ios .ne. 0) go to 900
call write_lifecycle_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
@@ -104,7 +109,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. 4) then
if (version .lt. 1 .or. version .gt. 5) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'unsupported restart version', ierr)
return
@@ -170,7 +175,7 @@ contains
integer, intent(in) :: unit_id
integer, intent(out) :: ios
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 4
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 5
if (ios .ne. 0) return
write(unit_id,'(A,4(1X,I12))',iostat=ios) 'COUNTS', nnode, nelem, &
ndof, ngauss_total
@@ -225,6 +230,11 @@ contains
else if (trim(tag) .eq. 'END') then
call contact_multiplier_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
else if (trim(tag) .eq. 'LIFECYCLE_DIAGNOSTICS') then
call contact_multiplier_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call read_lifecycle_then_end(unit_id, line, ierr)
if (ierr .ne. FEM_SUCCESS) return
else
go to 920
end if
@@ -245,6 +255,13 @@ contains
if (ierr .ne. FEM_SUCCESS) return
call contact_multiplier_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
else if (trim(tag) .eq. 'LIFECYCLE_DIAGNOSTICS') then
call contact_history_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call contact_multiplier_read(unit_id, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call read_lifecycle_then_end(unit_id, line, ierr)
if (ierr .ne. FEM_SUCCESS) return
else
call error_set(FEM_ERR_OUTPUT, 'invalid restart file tail', ierr)
return
@@ -348,6 +365,44 @@ contains
end do
end subroutine write_contact_pair_diag
subroutine write_lifecycle_diag(unit_id, ios)
integer, intent(in) :: unit_id
integer, intent(out) :: ios
integer :: step
integer :: increment
integer :: iteration
integer :: event_id
integer :: reason_id
integer :: audit_status
integer :: begin_trial_count
integer :: rollback_requested_count
integer :: rollback_ok_count
integer :: rollback_failed_count
integer :: commit_ok_count
integer :: path_value
real(rk) :: load_factor
real(rk) :: arc_residual
logical :: path_appended
character(len=64) :: event_name
character(len=64) :: reason_name
character(len=64) :: audit_name
call nl_lifecycle_get_snapshot(step, increment, iteration, event_id, &
event_name, reason_id, reason_name, audit_status, audit_name)
call nl_lifecycle_get_arc_state(load_factor, arc_residual, path_appended)
call nl_lifecycle_get_audit(audit_status, audit_name, begin_trial_count, &
rollback_requested_count, rollback_ok_count, rollback_failed_count, &
commit_ok_count)
path_value = 0
if (path_appended) path_value = 1
write(unit_id,'(A,7(1X,I12),2(1X,ES24.16),5(1X,I12))',iostat=ios) &
'LIFECYCLE_DIAGNOSTICS', step, increment, iteration, event_id, &
reason_id, audit_status, path_value, load_factor, arc_residual, &
begin_trial_count, rollback_requested_count, rollback_ok_count, &
rollback_failed_count, commit_ok_count
end subroutine write_lifecycle_diag
subroutine read_diag_or_end(unit_id, ierr)
integer, intent(in) :: unit_id
integer, intent(out) :: ierr
@@ -377,6 +432,10 @@ contains
ierr = FEM_SUCCESS
return
end if
if (trim(tag) .eq. 'LIFECYCLE_DIAGNOSTICS') then
call read_lifecycle_then_end(unit_id, line, ierr)
return
end if
if (trim(tag) .ne. 'CONTACT_PAIR_DIAGNOSTICS') then
call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr)
return
@@ -399,13 +458,81 @@ contains
call read_contact_pair_diag_rows(unit_id, pair_count, ierr)
if (ierr .ne. FEM_SUCCESS) return
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. 'LIFECYCLE_DIAGNOSTICS') then
call read_lifecycle_then_end(unit_id, line, ierr)
return
end if
if (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_lifecycle_then_end(unit_id, line, ierr)
integer, intent(in) :: unit_id
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=32) :: tag
integer :: ios
call read_lifecycle_diag_line(line, 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
end subroutine read_lifecycle_then_end
subroutine read_lifecycle_diag_line(line, ierr)
character(len=*), intent(in) :: line
integer, intent(out) :: ierr
character(len=32) :: tag
integer :: ios
integer :: step
integer :: increment
integer :: iteration
integer :: event_id
integer :: reason_id
integer :: audit_status
integer :: path_value
integer :: begin_trial_count
integer :: rollback_requested_count
integer :: rollback_ok_count
integer :: rollback_failed_count
integer :: commit_ok_count
real(rk) :: load_factor
real(rk) :: arc_residual
read(line,*,iostat=ios) tag, step, increment, iteration, event_id, &
reason_id, audit_status, path_value, load_factor, arc_residual, &
begin_trial_count, rollback_requested_count, rollback_ok_count, &
rollback_failed_count, commit_ok_count
if (ios .ne. 0 .or. trim(tag) .ne. 'LIFECYCLE_DIAGNOSTICS') then
call error_set(FEM_ERR_OUTPUT, 'invalid restart lifecycle diagnostics', &
ierr)
return
end if
call nl_lifecycle_restore(step, increment, iteration, event_id, reason_id, &
load_factor, arc_residual, path_value .ne. 0, audit_status, &
begin_trial_count, rollback_requested_count, rollback_ok_count, &
rollback_failed_count, commit_ok_count)
ierr = FEM_SUCCESS
end subroutine read_lifecycle_diag_line
subroutine read_contact_pair_diag_rows(unit_id, pair_count, ierr)
integer, intent(in) :: unit_id
+7
View File
@@ -3,6 +3,8 @@ module fem_particle_audit
use fem_error
use fem_particle_state
use fem_particle_step
use fem_nonlinear_lifecycle, only: NLC_AUDIT_COMMIT_OK, &
NLC_AUDIT_ROLLBACK_FAILED, nl_lifecycle_record_audit
implicit none
private
@@ -86,6 +88,11 @@ contains
audit%energy_change .gt. energy_tol) then
audit%status = max(audit%status, PAUDIT_WARN)
end if
if (audit%status .eq. PAUDIT_FAIL) then
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_FAILED)
else
call nl_lifecycle_record_audit(NLC_AUDIT_COMMIT_OK)
end if
call error_clear(ierr)
end subroutine paudit_step
+359
View File
@@ -0,0 +1,359 @@
module fem_nonlinear_lifecycle
use fem_precision
use fem_control, only: NFAIL_NONE, convergence_failure_reason_name
implicit none
private
integer, parameter, public :: NLC_EVENT_NONE = 0
integer, parameter, public :: NLC_EVENT_INCREMENT_BEGIN = 10
integer, parameter, public :: NLC_EVENT_TRIAL_BEGIN = 20
integer, parameter, public :: NLC_EVENT_ITERATION_BEGIN = 25
integer, parameter, public :: NLC_EVENT_ITERATION_RESULT = 30
integer, parameter, public :: NLC_EVENT_ACCEPT = 40
integer, parameter, public :: NLC_EVENT_REJECT = 50
integer, parameter, public :: NLC_EVENT_CUTBACK = 60
integer, parameter, public :: NLC_EVENT_COMMIT = 70
integer, parameter, public :: NLC_EVENT_ROLLBACK = 80
integer, parameter, public :: NLC_AUDIT_NONE = 0
integer, parameter, public :: NLC_AUDIT_BEGIN_TRIAL = 10
integer, parameter, public :: NLC_AUDIT_ROLLBACK_REQUESTED = 20
integer, parameter, public :: NLC_AUDIT_ROLLBACK_OK = 30
integer, parameter, public :: NLC_AUDIT_ROLLBACK_FAILED = 40
integer, parameter, public :: NLC_AUDIT_COMMIT_OK = 50
public :: nl_lifecycle_reset
public :: nl_lifecycle_event_name
public :: nl_lifecycle_audit_status_name
public :: nl_lifecycle_begin_increment
public :: nl_lifecycle_record_event
public :: nl_lifecycle_record_audit
public :: nl_lifecycle_get_snapshot
public :: nl_lifecycle_record_arc_state
public :: nl_lifecycle_mark_path_appended
public :: nl_lifecycle_get_arc_state
public :: nl_lifecycle_get_audit
public :: nl_lifecycle_restore
public :: nl_lifecycle_get_event_count
public :: nl_lifecycle_get_event
integer, parameter :: NLC_EVENT_HISTORY_MAX = 256
integer :: lifecycle_step = 0
integer :: lifecycle_increment = 0
integer :: lifecycle_iteration = 0
integer :: lifecycle_event_id = NLC_EVENT_NONE
integer :: lifecycle_reason_id = NFAIL_NONE
real(rk) :: lifecycle_load_factor = ZERO
real(rk) :: lifecycle_arc_residual = ZERO
logical :: lifecycle_path_appended = .false.
integer :: lifecycle_audit_status = NLC_AUDIT_NONE
integer :: audit_begin_trial_count = 0
integer :: audit_rollback_req_count = 0
integer :: audit_rollback_ok_count = 0
integer :: audit_rollback_fail_count = 0
integer :: audit_commit_ok_count = 0
integer :: lifecycle_event_count = 0
integer :: event_step(NLC_EVENT_HISTORY_MAX) = 0
integer :: event_increment(NLC_EVENT_HISTORY_MAX) = 0
integer :: event_iteration(NLC_EVENT_HISTORY_MAX) = 0
integer :: event_id_hist(NLC_EVENT_HISTORY_MAX) = NLC_EVENT_NONE
integer :: event_reason_id(NLC_EVENT_HISTORY_MAX) = NFAIL_NONE
contains
subroutine nl_lifecycle_reset()
lifecycle_step = 0
lifecycle_increment = 0
lifecycle_iteration = 0
lifecycle_event_id = NLC_EVENT_NONE
lifecycle_reason_id = NFAIL_NONE
lifecycle_load_factor = ZERO
lifecycle_arc_residual = ZERO
lifecycle_path_appended = .false.
lifecycle_audit_status = NLC_AUDIT_NONE
audit_begin_trial_count = 0
audit_rollback_req_count = 0
audit_rollback_ok_count = 0
audit_rollback_fail_count = 0
audit_commit_ok_count = 0
lifecycle_event_count = 0
event_step = 0
event_increment = 0
event_iteration = 0
event_id_hist = NLC_EVENT_NONE
event_reason_id = NFAIL_NONE
end subroutine nl_lifecycle_reset
subroutine nl_lifecycle_event_name(event_id, event_name)
integer, intent(in) :: event_id
character(len=*), intent(out) :: event_name
event_name = 'unknown'
select case (event_id)
case (NLC_EVENT_NONE)
event_name = 'none'
case (NLC_EVENT_INCREMENT_BEGIN)
event_name = 'increment-begin'
case (NLC_EVENT_TRIAL_BEGIN)
event_name = 'trial-begin'
case (NLC_EVENT_ITERATION_BEGIN)
event_name = 'iteration-begin'
case (NLC_EVENT_ITERATION_RESULT)
event_name = 'iteration-result'
case (NLC_EVENT_ACCEPT)
event_name = 'accept'
case (NLC_EVENT_REJECT)
event_name = 'reject'
case (NLC_EVENT_CUTBACK)
event_name = 'cutback'
case (NLC_EVENT_COMMIT)
event_name = 'commit'
case (NLC_EVENT_ROLLBACK)
event_name = 'rollback'
end select
end subroutine nl_lifecycle_event_name
subroutine nl_lifecycle_audit_status_name(status_id, status_name)
integer, intent(in) :: status_id
character(len=*), intent(out) :: status_name
status_name = 'unknown'
select case (status_id)
case (NLC_AUDIT_NONE)
status_name = 'none'
case (NLC_AUDIT_BEGIN_TRIAL)
status_name = 'begin-trial'
case (NLC_AUDIT_ROLLBACK_REQUESTED)
status_name = 'rollback-requested'
case (NLC_AUDIT_ROLLBACK_OK)
status_name = 'rollback-ok'
case (NLC_AUDIT_ROLLBACK_FAILED)
status_name = 'rollback-failed'
case (NLC_AUDIT_COMMIT_OK)
status_name = 'commit-ok'
end select
end subroutine nl_lifecycle_audit_status_name
subroutine nl_lifecycle_begin_increment(step, increment)
integer, intent(in) :: step
integer, intent(in) :: increment
call nl_lifecycle_record_event(step, increment, 0, &
NLC_EVENT_INCREMENT_BEGIN, NFAIL_NONE)
end subroutine nl_lifecycle_begin_increment
subroutine nl_lifecycle_record_event(step, increment, iteration, event_id, &
reason_id)
integer, intent(in) :: step
integer, intent(in) :: increment
integer, intent(in) :: iteration
integer, intent(in) :: event_id
integer, intent(in), optional :: reason_id
integer :: slot
lifecycle_step = step
lifecycle_increment = increment
lifecycle_iteration = iteration
lifecycle_event_id = event_id
if (present(reason_id)) then
lifecycle_reason_id = reason_id
else
lifecycle_reason_id = NFAIL_NONE
end if
if (event_id .eq. NLC_EVENT_INCREMENT_BEGIN) then
lifecycle_path_appended = .false.
end if
if (lifecycle_event_count .lt. NLC_EVENT_HISTORY_MAX) then
lifecycle_event_count = lifecycle_event_count + 1
slot = lifecycle_event_count
else
slot = NLC_EVENT_HISTORY_MAX
end if
event_step(slot) = lifecycle_step
event_increment(slot) = lifecycle_increment
event_iteration(slot) = lifecycle_iteration
event_id_hist(slot) = lifecycle_event_id
event_reason_id(slot) = lifecycle_reason_id
end subroutine nl_lifecycle_record_event
subroutine nl_lifecycle_get_snapshot(step, increment, iteration, event_id, &
event_name, reason_id, reason_name, &
audit_status, audit_status_name)
integer, intent(out) :: step
integer, intent(out) :: increment
integer, intent(out) :: iteration
integer, intent(out) :: event_id
character(len=*), intent(out) :: event_name
integer, intent(out) :: reason_id
character(len=*), intent(out) :: reason_name
integer, intent(out), optional :: audit_status
character(len=*), intent(out), optional :: audit_status_name
step = lifecycle_step
increment = lifecycle_increment
iteration = lifecycle_iteration
event_id = lifecycle_event_id
call nl_lifecycle_event_name(lifecycle_event_id, event_name)
reason_id = lifecycle_reason_id
call convergence_failure_reason_name(lifecycle_reason_id, reason_name)
if (present(audit_status)) audit_status = lifecycle_audit_status
if (present(audit_status_name)) then
call nl_lifecycle_audit_status_name(lifecycle_audit_status, &
audit_status_name)
end if
end subroutine nl_lifecycle_get_snapshot
subroutine nl_lifecycle_record_audit(status_id)
integer, intent(in) :: status_id
lifecycle_audit_status = status_id
select case (status_id)
case (NLC_AUDIT_BEGIN_TRIAL)
audit_begin_trial_count = audit_begin_trial_count + 1
case (NLC_AUDIT_ROLLBACK_REQUESTED)
audit_rollback_req_count = audit_rollback_req_count + 1
case (NLC_AUDIT_ROLLBACK_OK)
audit_rollback_ok_count = audit_rollback_ok_count + 1
case (NLC_AUDIT_ROLLBACK_FAILED)
audit_rollback_fail_count = audit_rollback_fail_count + 1
case (NLC_AUDIT_COMMIT_OK)
audit_commit_ok_count = audit_commit_ok_count + 1
end select
end subroutine nl_lifecycle_record_audit
subroutine nl_lifecycle_get_audit(status_id, status_name, begin_trial_count, &
rollback_requested_count, &
rollback_ok_count, rollback_failed_count, &
commit_ok_count)
integer, intent(out) :: status_id
character(len=*), intent(out) :: status_name
integer, intent(out) :: begin_trial_count
integer, intent(out) :: rollback_requested_count
integer, intent(out) :: rollback_ok_count
integer, intent(out) :: rollback_failed_count
integer, intent(out) :: commit_ok_count
status_id = lifecycle_audit_status
call nl_lifecycle_audit_status_name(status_id, status_name)
begin_trial_count = audit_begin_trial_count
rollback_requested_count = audit_rollback_req_count
rollback_ok_count = audit_rollback_ok_count
rollback_failed_count = audit_rollback_fail_count
commit_ok_count = audit_commit_ok_count
end subroutine nl_lifecycle_get_audit
subroutine nl_lifecycle_restore(step, increment, iteration, event_id, &
reason_id, load_factor, arc_residual, &
path_appended, audit_status, &
begin_trial_count, &
rollback_requested_count, &
rollback_ok_count, rollback_failed_count, &
commit_ok_count)
integer, intent(in) :: step
integer, intent(in) :: increment
integer, intent(in) :: iteration
integer, intent(in) :: event_id
integer, intent(in) :: reason_id
real(rk), intent(in) :: load_factor
real(rk), intent(in) :: arc_residual
logical, intent(in) :: path_appended
integer, intent(in) :: audit_status
integer, intent(in) :: begin_trial_count
integer, intent(in) :: rollback_requested_count
integer, intent(in) :: rollback_ok_count
integer, intent(in) :: rollback_failed_count
integer, intent(in) :: commit_ok_count
lifecycle_step = step
lifecycle_increment = increment
lifecycle_iteration = iteration
lifecycle_event_id = event_id
lifecycle_reason_id = reason_id
lifecycle_load_factor = load_factor
lifecycle_arc_residual = arc_residual
lifecycle_path_appended = path_appended
lifecycle_audit_status = audit_status
audit_begin_trial_count = begin_trial_count
audit_rollback_req_count = rollback_requested_count
audit_rollback_ok_count = rollback_ok_count
audit_rollback_fail_count = rollback_failed_count
audit_commit_ok_count = commit_ok_count
lifecycle_event_count = 0
event_step = 0
event_increment = 0
event_iteration = 0
event_id_hist = NLC_EVENT_NONE
event_reason_id = NFAIL_NONE
if (event_id .ne. NLC_EVENT_NONE) then
lifecycle_event_count = 1
event_step(1) = step
event_increment(1) = increment
event_iteration(1) = iteration
event_id_hist(1) = event_id
event_reason_id(1) = reason_id
end if
end subroutine nl_lifecycle_restore
subroutine nl_lifecycle_record_arc_state(load_factor, arc_residual)
real(rk), intent(in) :: load_factor
real(rk), intent(in) :: arc_residual
lifecycle_load_factor = load_factor
lifecycle_arc_residual = arc_residual
end subroutine nl_lifecycle_record_arc_state
subroutine nl_lifecycle_mark_path_appended(appended)
logical, intent(in) :: appended
lifecycle_path_appended = appended
end subroutine nl_lifecycle_mark_path_appended
subroutine nl_lifecycle_get_arc_state(load_factor, arc_residual, &
path_appended)
real(rk), intent(out) :: load_factor
real(rk), intent(out) :: arc_residual
logical, intent(out) :: path_appended
load_factor = lifecycle_load_factor
arc_residual = lifecycle_arc_residual
path_appended = lifecycle_path_appended
end subroutine nl_lifecycle_get_arc_state
integer function nl_lifecycle_get_event_count()
nl_lifecycle_get_event_count = lifecycle_event_count
end function nl_lifecycle_get_event_count
subroutine nl_lifecycle_get_event(index, step, increment, iteration, &
event_id, event_name, reason_id, &
reason_name)
integer, intent(in) :: index
integer, intent(out) :: step
integer, intent(out) :: increment
integer, intent(out) :: iteration
integer, intent(out) :: event_id
character(len=*), intent(out) :: event_name
integer, intent(out) :: reason_id
character(len=*), intent(out) :: reason_name
if (index .lt. 1 .or. index .gt. lifecycle_event_count) then
step = 0
increment = 0
iteration = 0
event_id = NLC_EVENT_NONE
event_name = 'none'
reason_id = NFAIL_NONE
reason_name = 'none'
return
end if
step = event_step(index)
increment = event_increment(index)
iteration = event_iteration(index)
event_id = event_id_hist(index)
call nl_lifecycle_event_name(event_id, event_name)
reason_id = event_reason_id(index)
call convergence_failure_reason_name(reason_id, reason_name)
end subroutine nl_lifecycle_get_event
end module fem_nonlinear_lifecycle
+26
View File
@@ -12,6 +12,10 @@ module fem_solver_newmark
use fem_implicit_constraints, only: apply_nl_external_tangent, &
apply_implicit_dirichlet_zero, apply_implicit_dirichlet, &
apply_implicit_robin, apply_implicit_mpc
use fem_nonlinear_lifecycle, only: NLC_EVENT_ACCEPT, NLC_EVENT_COMMIT, &
NLC_EVENT_ITERATION_BEGIN, NLC_EVENT_ITERATION_RESULT, &
NLC_EVENT_REJECT, NLC_EVENT_TRIAL_BEGIN, &
nl_lifecycle_begin_increment, nl_lifecycle_record_event
use fem_solver_implicit_support, only: begin_newmark_convergence, &
record_convergence_iteration, record_convergence_correction, &
record_line_search_metrics, mark_convergence_success, &
@@ -273,8 +277,13 @@ contains
call element_state_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(current_step + 1, current_step + 1, 0, &
NLC_EVENT_TRIAL_BEGIN, NFAIL_NONE)
do iter = 1, max_iter
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter, NLC_EVENT_ITERATION_BEGIN, &
NFAIL_NONE)
call element_state_restore_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
@@ -288,6 +297,9 @@ contains
if (res_norm .le. tol .or. res_norm / ref_norm .le. tol) then
call finish_newmark_nl_success(kmat, external, damping_force, &
converged, stat)
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter, NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
exit
end if
@@ -298,6 +310,9 @@ contains
ref_norm, trial_res_norm, &
trial_ref_norm, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter, NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
end do
if (.not. converged) then
@@ -307,11 +322,21 @@ contains
call element_state_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter_used, NLC_EVENT_COMMIT, NFAIL_NONE)
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter_used, NLC_EVENT_ACCEPT, NFAIL_NONE)
ierr = FEM_SUCCESS
900 continue
if (ierr .ne. FEM_SUCCESS) then
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter_used, NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
iter_used, NLC_EVENT_REJECT, &
convergence_failure_reason_id)
call newmark_nl_restore_state(u_start, v_start, a_start, vhalf_start)
call element_state_abort_trial(state_ierr)
end if
@@ -369,6 +394,7 @@ contains
'nonlinear Newmark tolerance must be positive', ierr)
return
end if
call nl_lifecycle_begin_increment(current_step + 1, current_step + 1)
call error_clear(ierr)
end subroutine begin_newmark_nl_step
@@ -11,6 +11,11 @@ module fem_solver_static_nonlinear
use fem_implicit_constraints, only: apply_nl_external_tangent, &
collect_dirichlet_constraints
use fem_output_csv, only: output_csv_write_path
use fem_nonlinear_lifecycle, only: NLC_EVENT_ACCEPT, NLC_EVENT_COMMIT, &
NLC_EVENT_CUTBACK, NLC_EVENT_ITERATION_BEGIN, &
NLC_EVENT_ITERATION_RESULT, NLC_EVENT_REJECT, NLC_EVENT_TRIAL_BEGIN, &
nl_lifecycle_begin_increment, nl_lifecycle_mark_path_appended, &
nl_lifecycle_record_arc_state, nl_lifecycle_record_event
use fem_solver_implicit_support, only: zero_fixed_rhs, &
begin_static_convergence, record_convergence_iteration, &
record_convergence_correction, record_line_search_metrics, &
@@ -350,6 +355,8 @@ contains
if (nonlinear_continuation_method .ne. NLC_ARC_DISP) then
load_factor = base_load_factor
end if
call nl_lifecycle_record_event(current_step, current_step, iter_inc, &
NLC_EVENT_ACCEPT, NFAIL_NONE)
call error_clear(ierr)
end subroutine accept_static_increment
@@ -440,6 +447,9 @@ contains
convergence_failure_reason_id = NFAIL_NONE
nlc_last_adjust = NLC_ADJ_CUTBACK
nlc_next_target_dt = dt_try
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
convergence_iteration, &
NLC_EVENT_CUTBACK, NFAIL_NONE)
call error_clear(ierr)
end subroutine cutback_static_increment
@@ -458,6 +468,10 @@ contains
end if
nlc_last_adjust = NLC_ADJ_FAILED
nlc_next_target_dt = ZERO
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
convergence_iteration, &
NLC_EVENT_REJECT, &
convergence_failure_reason_id)
end subroutine fail_static_increment
subroutine implicit_solve_static_arc(final_time, num_increment, max_iter, &
@@ -517,6 +531,10 @@ contains
nlc_last_actual_dt = dt_try
call record_static_arc_path(sub_target_time, ierr)
if (ierr .ne. FEM_SUCCESS) return
call nl_lifecycle_mark_path_appended(.true.)
call nl_lifecycle_record_event(current_step, current_step, &
iter_inc, NLC_EVENT_ACCEPT, &
NFAIL_NONE)
remaining_time = final_time - current_time
call adapt_static_next_dt(iter_inc, dt_try, dt_min_eff, &
dt_max_eff, remaining_time, dt_next)
@@ -533,6 +551,9 @@ contains
convergence_failure_reason_id = NFAIL_NONE
nlc_last_adjust = NLC_ADJ_CUTBACK
nlc_next_target_dt = dt_try
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
convergence_iteration, &
NLC_EVENT_CUTBACK, NFAIL_NONE)
ierr = FEM_SUCCESS
else
convergence_status_code = CONVERGENCE_STATUS_FAILED
@@ -544,6 +565,10 @@ contains
end if
nlc_last_adjust = NLC_ADJ_FAILED
nlc_next_target_dt = ZERO
call nl_lifecycle_record_event(current_step + 1, current_step + 1, &
convergence_iteration, &
NLC_EVENT_REJECT, &
convergence_failure_reason_id)
return
end if
end do
@@ -785,8 +810,12 @@ contains
sign_dir, residual, fref, du_res, &
du_load, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(increment_id, increment_id, 0, &
NLC_EVENT_TRIAL_BEGIN, NFAIL_NONE)
do iter = 1, max_iter
call nl_lifecycle_record_event(increment_id, increment_id, iter, &
NLC_EVENT_ITERATION_BEGIN, NFAIL_NONE)
call eval_static_arc_iteration(target_time, dt_inc, tol, iter, u_start, &
lambda_start, load_scale, arc_radius, &
arc_tol, residual, external, u_arc, &
@@ -794,6 +823,10 @@ contains
correction_norm, iter_used, res_norm, &
ref_norm, converged, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_arc_state(load_factor, arc_residual)
call nl_lifecycle_record_event(increment_id, increment_id, iter, &
NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
if (converged) exit
call apply_static_arc_correction(target_time, max_iter, tol, residual, &
@@ -812,6 +845,8 @@ contains
call element_state_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(increment_id, increment_id, iter_used, &
NLC_EVENT_COMMIT, NFAIL_NONE)
call store_static_arc_direction(u_start, lambda_start, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
ierr = FEM_SUCCESS
@@ -874,6 +909,8 @@ contains
end if
arc_tol = max(tol, tol * max(ONE, arc_radius * arc_radius))
call begin_static_convergence(increment_id, dt_inc)
call nl_lifecycle_begin_increment(increment_id, increment_id)
call nl_lifecycle_record_arc_state(load_factor, ZERO)
call error_clear(ierr)
end subroutine init_static_arc_state
@@ -1390,8 +1427,12 @@ contains
call element_state_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(increment_id, increment_id, 0, &
NLC_EVENT_TRIAL_BEGIN, NFAIL_NONE)
do iter = 1, max_iter
call nl_lifecycle_record_event(increment_id, increment_id, iter, &
NLC_EVENT_ITERATION_BEGIN, NFAIL_NONE)
call element_state_restore_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
@@ -1404,6 +1445,9 @@ contains
if (res_norm .le. tol .or. res_norm / ref_norm .le. tol) then
converged = .true.
call mark_convergence_success()
call nl_lifecycle_record_event(increment_id, increment_id, iter, &
NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
if (allocated(freaction)) freaction = fint - external
exit
end if
@@ -1415,6 +1459,9 @@ contains
damping_alpha, trust_scale, &
line_rejections, trust_mode, ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(increment_id, increment_id, iter, &
NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
end do
if (.not. converged) then
@@ -1424,6 +1471,8 @@ contains
call element_state_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) go to 900
call nl_lifecycle_record_event(increment_id, increment_id, iter_used, &
NLC_EVENT_COMMIT, NFAIL_NONE)
ierr = FEM_SUCCESS
@@ -1431,6 +1480,9 @@ contains
if (ierr .ne. FEM_SUCCESS) then
if (allocated(u_start)) u = u_start
call mark_convergence_failure(CONV_FAIL_NONCONVERGENCE)
call nl_lifecycle_record_event(increment_id, increment_id, iter_used, &
NLC_EVENT_ITERATION_RESULT, &
convergence_failure_reason_id)
call element_state_abort_trial(state_ierr)
end if
if (allocated(residual)) deallocate(residual)
@@ -1473,6 +1525,7 @@ contains
(nonlinear_continuation_method .eq. NLC_ARC_DISP .and. &
nlc_trust_radius .gt. ZERO)
call begin_static_convergence(increment_id, dt_inc)
call nl_lifecycle_begin_increment(increment_id, increment_id)
end subroutine init_static_inc_state
subroutine apply_static_newton_step(target_time, dt_inc, max_iter, tol, &