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
+165 -1
View File
@@ -6,9 +6,10 @@ program test_solver_implicit
use fem_boundary
use fem_element_mass
use fem_solver_implicit
use fem_output_csv
use fem_linear_solver_cg, only: linear_solver_configure, &
linear_solver_get_diagnostics, linear_solver_get_settings, &
linear_solver_get_stats
linear_solver_get_stats, linear_solver_get_fail_info
use fem_sparse_csr_diagnostics, only: CSR_CLASS_GENERAL, &
CSR_CLASS_SPD_CAND
implicit none
@@ -31,6 +32,7 @@ program test_solver_implicit
call check_newmark_nonlinear_contact()
call check_newmark_trial_rollback()
call check_static_cutback_rollback()
call check_newmark_nonconv_reason()
call check_static_adapt_newton()
call check_static_trust_damped()
call check_static_arc_load_riks()
@@ -40,6 +42,7 @@ program test_solver_implicit
call check_static_arc_disp_adaptive()
call check_static_arc_disp_trust()
call check_nonlinear_cg_fallback()
call check_nl_linear_failure_reason()
contains
@@ -359,6 +362,12 @@ contains
if (iter .le. 0 .or. iter .gt. 5) call fail(93)
if (res_norm .gt. TOL) call fail(94)
if (convergence_correction_norm .le. ZERO) call fail(101)
call check_close(convergence_total_resid_norm, res_norm, 5500)
call check_close(convergence_force_resid_norm, res_norm, 5501)
call check_close(convergence_contact_resid_norm, ZERO, 5502)
call check_close(convergence_cons_resid_norm, ZERO, 5503)
call check_close(convergence_arc_resid_norm, ZERO, 5504)
if (convergence_material_fail_count .ne. 0) call fail(5505)
dof = dof_id(1,2)
call check_close(u(dof), 15.0_rk / 68.0_rk, 95)
@@ -543,6 +552,8 @@ contains
call check_close(convergence_last_dt, 0.25_rk, 161)
if (convergence_failure_code .ne. CONV_FAIL_CUTBACK_LIMIT) &
call fail(162)
if (convergence_failure_reason_id .ne. NFAIL_MIN_STEP) call fail(5164)
call check_reason_name(NFAIL_MIN_STEP, 'minimum-step-exhausted', 5165)
call check_close(convergence_last_accepted_time, ZERO, 163)
allow_step_cutback = old_cutback
@@ -554,6 +565,34 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(157)
end subroutine check_static_cutback_rollback
subroutine check_newmark_nonconv_reason()
integer :: ierr
integer :: iter
real(rk) :: res_norm
call setup_pull_model(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5166)
call element_compute_lumped_mass(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5167)
current_time = ZERO
call implicit_newmark_nonlinear_step(0.1_rk, 0.25_rk, 0.5_rk, &
1, 1.0e-30_rk, iter, res_norm, ierr)
if (ierr .eq. FEM_SUCCESS) call fail(5168)
if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) &
call fail(5169)
if (convergence_failure_code .ne. CONV_FAIL_NONCONVERGENCE) &
call fail(5170)
if (convergence_failure_reason_id .ne. NFAIL_NONCONVERGENCE) &
call fail(5171)
call check_reason_name(NFAIL_NONCONVERGENCE, &
'nonlinear-nonconvergence', 5172)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5173)
end subroutine check_newmark_nonconv_reason
subroutine check_static_adapt_newton()
integer :: ierr
integer :: iter
@@ -600,6 +639,12 @@ contains
if (convergence_status_code .ne. CONVERGENCE_STATUS_CONVERGED) &
call fail(200)
if (.not. convergence_converged) call fail(201)
call check_close(convergence_total_resid_norm, res_norm, 5510)
call check_close(convergence_force_resid_norm, res_norm, 5511)
call check_close(convergence_contact_resid_norm, ZERO, 5512)
call check_close(convergence_cons_resid_norm, ZERO, 5513)
call check_close(convergence_arc_resid_norm, ZERO, 5514)
if (convergence_material_fail_count .ne. 0) call fail(5515)
nonlinear_continuation_method = old_method
nlc_target_newton = old_target
@@ -757,6 +802,10 @@ contains
if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) &
call fail(287)
if (convergence_failure_code .ne. CONV_FAIL_STOPPED) call fail(288)
if (convergence_failure_reason_id .ne. NFAIL_ARC_CONSTRAINT) &
call fail(5290)
call check_reason_name(NFAIL_ARC_CONSTRAINT, &
'arc-constraint-failure', 5291)
nonlinear_continuation_method = old_method
@@ -802,6 +851,14 @@ contains
CONVERGENCE_STATUS_CONVERGED) call fail(246)
if (nlc_path_int(NLC_PATH_I_FAILURE_CODE, 2) .ne. CONV_FAIL_NONE) &
call fail(247)
if (nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, 2) .gt. TOL) call fail(5520)
if (nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, 2) .gt. TOL) call fail(5521)
call check_close(nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, 2), ZERO, &
5522)
call check_close(nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, 2), ZERO, 5523)
if (nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, 2) .ne. 0) &
call fail(5524)
call check_path_breakdown_header(5530)
nonlinear_continuation_method = old_method
@@ -1000,6 +1057,61 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(262)
end subroutine check_nonlinear_cg_fallback
subroutine check_nl_linear_failure_reason()
integer :: ierr
integer :: iter
integer :: old_method
integer :: old_preconditioner
integer :: old_linear_limit
integer :: failure_class
integer :: status_code
real(rk) :: res_norm
real(rk) :: final_residual
real(rk) :: relative_residual
real(rk) :: initial_residual
character(len=64) :: failure_reason
call setup_unconstrained_load(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5400)
call linear_solver_get_settings(old_method, old_preconditioner, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5401)
old_linear_limit = nonlinear_linear_iter_limit
call linear_solver_configure(LSOLVER_DENSE, LPRECOND_NONE, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5402)
nonlinear_linear_iter_limit = 1
current_time = ZERO
current_step = 0
call implicit_solve_nonlinear_static(ONE, 1, 20, 1.0e-12_rk, &
iter, res_norm, ierr)
if (ierr .eq. FEM_SUCCESS) call fail(5403)
if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) &
call fail(5404)
if (convergence_failure_reason_id .ne. NFAIL_LINEAR_SOLVE) call fail(5405)
call linear_solver_get_diagnostics(failure_class, initial_residual, &
final_residual, relative_residual, status_code, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5406)
if (status_code .ne. LS_STATUS_FAILED) call fail(5407)
if (initial_residual .le. ZERO) call fail(5408)
if (relative_residual .le. ZERO) call fail(5409)
call linear_solver_get_fail_info(failure_class, failure_reason, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5410)
if (failure_class .ne. LS_FAIL_DENSE_FALLBACK) call fail(5411)
if (index(trim(failure_reason), 'dense-fallback-failure') .le. 0) &
call fail(5412)
nonlinear_linear_iter_limit = old_linear_limit
call linear_solver_configure(old_method, old_preconditioner, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5413)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(5414)
end subroutine check_nl_linear_failure_reason
subroutine setup_pull_model(ierr)
integer, intent(out) :: ierr
@@ -1060,6 +1172,18 @@ contains
ierr = FEM_SUCCESS
end subroutine setup_single_free_dof_model
subroutine setup_unconstrained_load(ierr)
integer, intent(out) :: ierr
call setup_base_tet(0, 1, ierr)
if (ierr .ne. FEM_SUCCESS) return
cload_target(1) = '2'
cload_dof(1) = 1
cload_value(1) = 5.0_rk
ierr = FEM_SUCCESS
end subroutine setup_unconstrained_load
subroutine setup_prescribed_model(ierr)
integer, intent(out) :: ierr
@@ -1197,6 +1321,46 @@ contains
if (abs(actual - expected) .gt. TOL) call fail(code)
end subroutine check_close
subroutine check_reason_name(reason_id, expected, code)
integer, intent(in) :: reason_id
character(len=*), intent(in) :: expected
integer, intent(in) :: code
character(len=64) :: actual
call convergence_failure_reason_name(reason_id, actual)
if (trim(actual) .ne. trim(expected)) call fail(code)
end subroutine check_reason_name
subroutine check_path_breakdown_header(code_base)
integer, intent(in) :: code_base
character(len=2048) :: header
integer :: ierr
integer :: ios
integer :: unit_id
call output_csv_set_directory('build-codex-gcc/test_solver_implicit_path', &
ierr)
if (ierr .ne. FEM_SUCCESS) call fail(code_base)
call output_csv_write_path(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(code_base + 1)
unit_id = 94
open(unit=unit_id, &
file='build-codex-gcc/test_solver_implicit_path/continuation_path.csv', &
status='old', action='read', iostat=ios)
if (ios .ne. 0) call fail(code_base + 2)
read(unit_id,'(A)',iostat=ios) header
close(unit_id)
if (ios .ne. 0) call fail(code_base + 3)
if (index(header, 'residual_total') .le. 0) call fail(code_base + 4)
if (index(header, 'residual_force') .le. 0) call fail(code_base + 5)
if (index(header, 'residual_contact') .le. 0) call fail(code_base + 6)
if (index(header, 'residual_constraint') .le. 0) call fail(code_base + 7)
if (index(header, 'residual_arc') .le. 0) call fail(code_base + 8)
if (index(header, 'material_failure_count') .le. 0) &
call fail(code_base + 9)
end subroutine check_path_breakdown_header
subroutine check_solver_diag(code_base)
integer, intent(in) :: code_base
integer :: ierr