This commit is contained in:
@@ -3,8 +3,12 @@ program test_nonlinear_lifecycle
|
||||
use fem_error
|
||||
use fem_control
|
||||
use fem_api, only: fem_initialize, fem_finalize
|
||||
use fem_api_diagnostics, only: fem_get_nl_lifecycle_snapshot
|
||||
use fem_api_diagnostics, only: fem_record_convergence, &
|
||||
fem_get_cutback_reason, fem_get_nl_lifecycle_snapshot, &
|
||||
fem_get_nl_lifecycle_summary
|
||||
use fem_nonlinear_lifecycle
|
||||
use fem_output_csv, only: output_csv_set_directory, &
|
||||
output_csv_write_nl_lifecycle
|
||||
implicit none
|
||||
|
||||
call check_event_names()
|
||||
@@ -12,7 +16,11 @@ program test_nonlinear_lifecycle
|
||||
call check_recorded_snapshot()
|
||||
call check_begin_increment()
|
||||
call check_audit_core()
|
||||
call check_cutback_reason_names()
|
||||
call check_summary_core()
|
||||
call check_lifecycle_report_empty()
|
||||
call check_api_snapshot()
|
||||
call check_api_summary()
|
||||
|
||||
contains
|
||||
|
||||
@@ -174,6 +182,121 @@ contains
|
||||
if (trim(audit_name) .ne. 'commit-ok') call fail(902)
|
||||
end subroutine check_audit_core
|
||||
|
||||
subroutine check_cutback_reason_names()
|
||||
character(len=64) :: name
|
||||
|
||||
call cutback_reason_name(CUTBACK_REASON_NONE, name)
|
||||
if (trim(name) .ne. 'none') call fail(950)
|
||||
call cutback_reason_name(CUTBACK_REASON_NONCONVERGENCE, name)
|
||||
if (trim(name) .ne. 'nonlinear-nonconvergence') call fail(951)
|
||||
call cutback_reason_name(CUTBACK_REASON_MIN_STEP, name)
|
||||
if (trim(name) .ne. 'minimum-step-exhausted') call fail(952)
|
||||
call cutback_reason_name(CUTBACK_REASON_LINEAR_SOLVE, name)
|
||||
if (trim(name) .ne. 'linear-solve-failure') call fail(953)
|
||||
call cutback_reason_name(-999, name)
|
||||
if (trim(name) .ne. 'unknown') call fail(954)
|
||||
if (cutback_reason_from_failure(CONV_FAIL_CUTBACK_LIMIT, &
|
||||
NFAIL_NONE) .ne. CUTBACK_REASON_MIN_STEP) call fail(955)
|
||||
if (cutback_reason_from_failure(CONV_FAIL_NONE, &
|
||||
NFAIL_LINEAR_SOLVE) .ne. CUTBACK_REASON_LINEAR_SOLVE) call fail(956)
|
||||
if (cutback_reason_from_failure(CONV_FAIL_NONCONVERGENCE, &
|
||||
NFAIL_NONE) .ne. CUTBACK_REASON_NONCONVERGENCE) call fail(957)
|
||||
end subroutine check_cutback_reason_names
|
||||
|
||||
subroutine check_summary_core()
|
||||
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 :: accept_count
|
||||
integer :: reject_count
|
||||
integer :: cutback_count
|
||||
character(len=64) :: event_name
|
||||
character(len=64) :: reason_name
|
||||
character(len=64) :: audit_name
|
||||
|
||||
call nl_lifecycle_reset()
|
||||
call nl_lifecycle_get_summary(step, increment, iteration, event_id, &
|
||||
event_name, reason_id, reason_name, audit_status, audit_name, &
|
||||
begin_trial_count, rollback_requested_count, rollback_ok_count, &
|
||||
rollback_failed_count, commit_ok_count, accept_count, reject_count, &
|
||||
cutback_count)
|
||||
if (step .ne. 0) call fail(1000)
|
||||
if (event_id .ne. NLC_EVENT_NONE) call fail(1001)
|
||||
if (trim(event_name) .ne. 'none') call fail(1002)
|
||||
if (audit_status .ne. NLC_AUDIT_NONE) call fail(1003)
|
||||
if (accept_count .ne. 0) call fail(1004)
|
||||
if (reject_count .ne. 0) call fail(1005)
|
||||
if (cutback_count .ne. 0) call fail(1006)
|
||||
|
||||
call nl_lifecycle_record_event(1, 2, 0, NLC_EVENT_INCREMENT_BEGIN, &
|
||||
NFAIL_NONE)
|
||||
call nl_lifecycle_record_event(1, 2, 1, NLC_EVENT_ACCEPT, NFAIL_NONE)
|
||||
call nl_lifecycle_record_event(1, 3, 1, NLC_EVENT_CUTBACK, &
|
||||
NFAIL_NONCONVERGENCE)
|
||||
call nl_lifecycle_record_event(1, 3, 1, NLC_EVENT_REJECT, &
|
||||
NFAIL_MIN_STEP)
|
||||
call nl_lifecycle_record_audit(NLC_AUDIT_BEGIN_TRIAL)
|
||||
call nl_lifecycle_record_audit(NLC_AUDIT_ROLLBACK_REQUESTED)
|
||||
call nl_lifecycle_get_summary(step, increment, iteration, event_id, &
|
||||
event_name, reason_id, reason_name, audit_status, audit_name, &
|
||||
begin_trial_count, rollback_requested_count, rollback_ok_count, &
|
||||
rollback_failed_count, commit_ok_count, accept_count, reject_count, &
|
||||
cutback_count)
|
||||
if (step .ne. 1) call fail(1010)
|
||||
if (increment .ne. 3) call fail(1011)
|
||||
if (iteration .ne. 1) call fail(1012)
|
||||
if (event_id .ne. NLC_EVENT_REJECT) call fail(1013)
|
||||
if (trim(event_name) .ne. 'reject') call fail(1014)
|
||||
if (reason_id .ne. NFAIL_MIN_STEP) call fail(1015)
|
||||
if (trim(reason_name) .ne. 'minimum-step-exhausted') call fail(1016)
|
||||
if (audit_status .ne. NLC_AUDIT_ROLLBACK_REQUESTED) call fail(1017)
|
||||
if (trim(audit_name) .ne. 'rollback-requested') call fail(1018)
|
||||
if (begin_trial_count .ne. 1) call fail(1019)
|
||||
if (rollback_requested_count .ne. 1) call fail(1020)
|
||||
if (rollback_ok_count .ne. 0) call fail(1021)
|
||||
if (rollback_failed_count .ne. 0) call fail(1022)
|
||||
if (commit_ok_count .ne. 0) call fail(1023)
|
||||
if (accept_count .ne. 1) call fail(1024)
|
||||
if (reject_count .ne. 1) call fail(1025)
|
||||
if (cutback_count .ne. 1) call fail(1026)
|
||||
end subroutine check_summary_core
|
||||
|
||||
subroutine check_lifecycle_report_empty()
|
||||
integer :: ierr
|
||||
integer :: ios
|
||||
integer :: unit_id
|
||||
character(len=2048) :: header
|
||||
character(len=2048) :: row_line
|
||||
|
||||
call nl_lifecycle_reset()
|
||||
call output_csv_set_directory( &
|
||||
'build-codex-gcc/test_nonlinear_lifecycle_report_empty', ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1030)
|
||||
call output_csv_write_nl_lifecycle(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1031)
|
||||
|
||||
unit_id = 93
|
||||
open(unit=unit_id, &
|
||||
file='build-codex-gcc/test_nonlinear_lifecycle_report_empty/nonlinear_lifecycle.csv', &
|
||||
status='old', action='read', iostat=ios)
|
||||
if (ios .ne. 0) call fail(1032)
|
||||
read(unit_id,'(A)',iostat=ios) header
|
||||
if (ios .ne. 0) call fail(1033)
|
||||
read(unit_id,'(A)',iostat=ios) row_line
|
||||
close(unit_id)
|
||||
if (ios .ne. 0) call fail(1034)
|
||||
call check_lifecycle_report_header(header, 1035)
|
||||
if (index(row_line, ',none,') .le. 0) call fail(1045)
|
||||
end subroutine check_lifecycle_report_empty
|
||||
|
||||
subroutine check_api_snapshot()
|
||||
integer :: ierr
|
||||
integer :: step
|
||||
@@ -212,6 +335,107 @@ contains
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(105)
|
||||
end subroutine check_api_snapshot
|
||||
|
||||
subroutine check_api_summary()
|
||||
integer :: ierr
|
||||
integer :: step
|
||||
integer :: increment
|
||||
integer :: iteration
|
||||
integer :: event_id
|
||||
integer :: reason_id
|
||||
integer :: convergence_status
|
||||
integer :: failure_code
|
||||
integer :: failure_reason_id
|
||||
integer :: material_fail_count
|
||||
integer :: linear_matrix_class
|
||||
integer :: linear_status
|
||||
integer :: audit_status
|
||||
integer :: begin_trial_count
|
||||
integer :: rollback_requested_count
|
||||
integer :: rollback_ok_count
|
||||
integer :: rollback_failed_count
|
||||
integer :: commit_ok_count
|
||||
integer :: accept_count
|
||||
integer :: reject_count
|
||||
integer :: cutback_count
|
||||
integer :: cutback_reason_id
|
||||
real(rk) :: total_residual
|
||||
real(rk) :: force_residual
|
||||
real(rk) :: contact_residual
|
||||
real(rk) :: constraint_residual
|
||||
real(rk) :: arc_residual
|
||||
character(len=64) :: event_name
|
||||
character(len=64) :: reason_name
|
||||
character(len=64) :: failure_reason_name
|
||||
character(len=64) :: audit_name
|
||||
character(len=64) :: cutback_reason
|
||||
|
||||
call fem_initialize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1100)
|
||||
call nl_lifecycle_reset()
|
||||
call nl_lifecycle_record_event(4, 5, 6, NLC_EVENT_ACCEPT, NFAIL_NONE)
|
||||
call nl_lifecycle_record_audit(NLC_AUDIT_COMMIT_OK)
|
||||
call fem_record_convergence(5, 6, 0.25_rk, 0.125_rk, 0.1_rk, &
|
||||
0.5_rk, .true., 0.025_rk, 0.01_rk)
|
||||
call fem_get_cutback_reason(cutback_reason_id, cutback_reason, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1127)
|
||||
if (cutback_reason_id .ne. CUTBACK_REASON_NONE) call fail(1128)
|
||||
if (trim(cutback_reason) .ne. 'none') call fail(1129)
|
||||
|
||||
call fem_get_nl_lifecycle_summary(step, increment, iteration, event_id, &
|
||||
event_name, reason_id, reason_name, convergence_status, failure_code, &
|
||||
failure_reason_id, failure_reason_name, total_residual, &
|
||||
force_residual, contact_residual, constraint_residual, arc_residual, &
|
||||
material_fail_count, linear_matrix_class, linear_status, audit_status, &
|
||||
audit_name, begin_trial_count, rollback_requested_count, &
|
||||
rollback_ok_count, rollback_failed_count, commit_ok_count, &
|
||||
accept_count, reject_count, cutback_count, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1101)
|
||||
if (step .ne. 4) call fail(1102)
|
||||
if (increment .ne. 5) call fail(1103)
|
||||
if (iteration .ne. 6) call fail(1104)
|
||||
if (event_id .ne. NLC_EVENT_ACCEPT) call fail(1105)
|
||||
if (trim(event_name) .ne. 'accept') call fail(1106)
|
||||
if (reason_id .ne. NFAIL_NONE) call fail(1107)
|
||||
if (convergence_status .ne. CONVERGENCE_STATUS_CONVERGED) &
|
||||
call fail(1108)
|
||||
if (failure_code .ne. CONV_FAIL_NONE) call fail(1109)
|
||||
if (failure_reason_id .ne. NFAIL_NONE) call fail(1110)
|
||||
if (trim(failure_reason_name) .ne. 'none') call fail(1111)
|
||||
if (abs(total_residual - 0.25_rk) .gt. 1.0e-14_rk) call fail(1112)
|
||||
if (abs(force_residual - 0.25_rk) .gt. 1.0e-14_rk) call fail(1113)
|
||||
if (abs(contact_residual - 0.01_rk) .gt. 1.0e-14_rk) call fail(1114)
|
||||
if (abs(constraint_residual) .gt. 1.0e-14_rk) call fail(1115)
|
||||
if (abs(arc_residual) .gt. 1.0e-14_rk) call fail(1116)
|
||||
if (material_fail_count .ne. 0) call fail(1117)
|
||||
if (linear_matrix_class .lt. 1) call fail(1118)
|
||||
if (linear_status .lt. 0) call fail(1119)
|
||||
if (audit_status .ne. NLC_AUDIT_COMMIT_OK) call fail(1120)
|
||||
if (trim(audit_name) .ne. 'commit-ok') call fail(1121)
|
||||
if (commit_ok_count .ne. 1) call fail(1122)
|
||||
if (accept_count .ne. 1) call fail(1123)
|
||||
if (reject_count .ne. 0) call fail(1124)
|
||||
if (cutback_count .ne. 0) call fail(1125)
|
||||
|
||||
call fem_finalize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1126)
|
||||
end subroutine check_api_summary
|
||||
|
||||
subroutine check_lifecycle_report_header(header, code_base)
|
||||
character(len=*), intent(in) :: header
|
||||
integer, intent(in) :: code_base
|
||||
|
||||
if (index(header, 'event_id') .le. 0) call fail(code_base)
|
||||
if (index(header, 'event_name') .le. 0) call fail(code_base + 1)
|
||||
if (index(header, 'reason_id') .le. 0) call fail(code_base + 2)
|
||||
if (index(header, 'convergence_status') .le. 0) call fail(code_base + 3)
|
||||
if (index(header, 'cutback_reason_id') .le. 0) call fail(code_base + 4)
|
||||
if (index(header, 'residual_total') .le. 0) call fail(code_base + 5)
|
||||
if (index(header, 'linear_status') .le. 0) call fail(code_base + 6)
|
||||
if (index(header, 'audit_status') .le. 0) call fail(code_base + 7)
|
||||
if (index(header, 'accept_count') .le. 0) call fail(code_base + 8)
|
||||
if (index(header, 'reject_count') .le. 0) call fail(code_base + 9)
|
||||
end subroutine check_lifecycle_report_header
|
||||
|
||||
subroutine fail(code)
|
||||
integer, intent(in) :: code
|
||||
write(*,*) 'test_nonlinear_lifecycle failed:', code
|
||||
|
||||
Reference in New Issue
Block a user