Release FemLite 0.5.2 V5 closeout
FemLite CI / build-test (push) Has been cancelled

This commit is contained in:
shenw
2026-07-01 14:51:40 +08:00
parent 5e90d58d0e
commit 75d4e735b1
82 changed files with 9972 additions and 2613 deletions
+18
View File
@@ -1,11 +1,13 @@
module fem_modal_output
use fem_precision
use fem_error
use fem_output_csv, only: output_csv_build_path
implicit none
private
public :: modal_write_csv
public :: modal_write_output_csv
public :: modal_summary
public :: modal_scale_to_max
@@ -50,6 +52,22 @@ contains
ierr = FEM_SUCCESS
end subroutine modal_write_csv
subroutine modal_write_output_csv(name, n, num_modes, eigenvalues, &
residuals, modes, ierr)
character(len=*), intent(in) :: name
integer, intent(in) :: n
integer, intent(in) :: num_modes
real(rk), intent(in) :: eigenvalues(num_modes)
real(rk), intent(in) :: residuals(num_modes)
real(rk), intent(in) :: modes(n,num_modes)
integer, intent(out) :: ierr
character(len=512) :: filename
call output_csv_build_path(name, filename)
call modal_write_csv(trim(filename), n, num_modes, eigenvalues, &
residuals, modes, ierr)
end subroutine modal_write_output_csv
subroutine modal_summary(n, num_modes, eigenvalues, residuals, modes, &
first_value, last_value, max_residual, &
max_component, ierr)
+136 -9
View File
@@ -17,17 +17,72 @@ contains
subroutine output_csv_set_directory(path, ierr)
character(len=*), intent(in) :: path
integer, intent(out) :: ierr
character(len=256) :: clean_path
if (len_trim(path) .eq. 0) then
call error_set(FEM_ERR_OUTPUT, 'output directory path is empty', ierr)
return
end if
csv_output_directory = adjustl(path)
clean_path = adjustl(path)
call output_csv_ensure_directory(trim(clean_path), ierr)
if (ierr .ne. FEM_SUCCESS) return
csv_output_directory = clean_path
history_header_written = .false.
ierr = FEM_SUCCESS
end subroutine output_csv_set_directory
subroutine output_csv_ensure_directory(path, ierr)
character(len=*), intent(in) :: path
integer, intent(out) :: ierr
character(len=512) :: command
character(len=128) :: os_name
integer :: os_len
integer :: os_end
integer :: exitstat
integer :: cmdstat
logical :: exists
if (len_trim(path) .eq. 0 .or. trim(path) .eq. '.') then
call error_clear(ierr)
return
end if
inquire(file=trim(path), exist=exists)
if (exists) then
call error_clear(ierr)
return
end if
os_name = ' '
call get_environment_variable('OS', os_name, os_len)
os_end = min(len(os_name), max(1, os_len))
if (index(os_name(1:os_end), 'Windows') .gt. 0) then
if (index(trim(path), '"') .gt. 0) then
call error_set(FEM_ERR_OUTPUT, &
'output directory path must not contain double quotes', ierr)
return
end if
command = 'mkdir "'//trim(path)//'" >nul 2>nul'
else
if (index(trim(path), "'") .gt. 0) then
call error_set(FEM_ERR_OUTPUT, &
'output directory path must not contain single quotes', ierr)
return
end if
command = "mkdir -p '"//trim(path)//"'"
end if
call execute_command_line(trim(command), exitstat=exitstat, &
cmdstat=cmdstat)
if (cmdstat .ne. 0 .or. exitstat .ne. 0) then
call error_set(FEM_ERR_OUTPUT, 'failed to create output directory', ierr)
return
end if
call error_clear(ierr)
end subroutine output_csv_ensure_directory
subroutine output_csv_set_interval(interval, ierr)
integer, intent(in) :: interval
integer, intent(out) :: ierr
@@ -143,6 +198,18 @@ contains
end if
end subroutine output_csv_path_filename
subroutine output_csv_build_path(name, filename)
character(len=*), intent(in) :: name
character(len=*), intent(out) :: filename
filename = ' '
if (trim(csv_output_directory) .eq. '.') then
filename = trim(name)
else
filename = trim(csv_output_directory)//'/'//trim(name)
end if
end subroutine output_csv_build_path
subroutine output_csv_step_filename(prefix, step, filename)
character(len=*), intent(in) :: prefix
integer, intent(in) :: step
@@ -300,7 +367,12 @@ contains
'constraint_residual_linf,constraint_residual_l2,'// &
'control_reaction_sum,control_reaction_generalized,control_work,'// &
'iterations,residual_norm,relative_residual,correction_norm,'// &
'status_code,failure_code'
'target_dt,actual_dt,next_dt,'// &
'trust_radius,next_trust_radius,trust_damping,trust_merit_ratio,'// &
'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'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, &
@@ -310,7 +382,7 @@ contains
do row = 1, nlc_path_count
write(unit_id,'(I12,2(A,ES24.16),A,I12,9(A,ES24.16),'// &
'A,I12,3(A,ES24.16),2(A,I12))',iostat=ios) &
'A,I12,10(A,ES24.16),10(A,I12),3(A,ES24.16))',iostat=ios) &
nlc_path_int(NLC_PATH_I_STEP, row), &
',', nlc_path_real(NLC_PATH_R_TIME, row), &
',', nlc_path_real(NLC_PATH_R_PARAMETER, row), &
@@ -328,8 +400,26 @@ contains
',', nlc_path_real(NLC_PATH_R_RESIDUAL_NORM, row), &
',', nlc_path_real(NLC_PATH_R_RELATIVE_RESIDUAL, row), &
',', nlc_path_real(NLC_PATH_R_CORRECTION_NORM, row), &
',', nlc_path_real(NLC_PATH_R_TARGET_DT, row), &
',', nlc_path_real(NLC_PATH_R_ACTUAL_DT, row), &
',', nlc_path_real(NLC_PATH_R_NEXT_DT, row), &
',', nlc_path_real(NLC_PATH_R_TRUST_RADIUS, row), &
',', nlc_path_real(NLC_PATH_R_NEXT_TRUST_RADIUS, row), &
',', nlc_path_real(NLC_PATH_R_TRUST_DAMPING, row), &
',', nlc_path_real(NLC_PATH_R_TRUST_MERIT_RATIO, row), &
',', nlc_path_int(NLC_PATH_I_ADAPT_ADJUST, row), &
',', nlc_path_int(NLC_PATH_I_CUTBACK_COUNT, row), &
',', nlc_path_int(NLC_PATH_I_TRUST_ADJUST, row), &
',', nlc_path_int(NLC_PATH_I_TRUST_REJECTIONS, row), &
',', nlc_path_int(NLC_PATH_I_STATUS_CODE, row), &
',', nlc_path_int(NLC_PATH_I_FAILURE_CODE, row)
',', nlc_path_int(NLC_PATH_I_FAILURE_CODE, row), &
',', nlc_path_int(NLC_PATH_I_LIN_METHOD, row), &
',', nlc_path_int(NLC_PATH_I_LIN_PRECOND, row), &
',', nlc_path_int(NLC_PATH_I_LIN_ITER, row), &
',', nlc_path_int(NLC_PATH_I_LIN_STATUS, row), &
',', 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 .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, &
@@ -354,6 +444,10 @@ contains
real(rk) :: peps(NSTRESS)
real(rk) :: eqps
real(rk) :: damage
real(rk) :: shell_mem_max
real(rk) :: shell_ben_max
real(rk) :: shell_shr_max
real(rk) :: shell_kappa(3)
call output_csv_step_filename('elements', step, filename)
unit_id = 63
@@ -366,7 +460,9 @@ contains
write(unit_id,'(A)',iostat=ios) &
'elem_id,status,s11,s22,s33,s12,s13,s23,e11,e22,e33,e12,e13,e23,'// &
'pe11,pe22,pe33,pe12,pe13,pe23,eqps,damage'
'pe11,pe22,pe33,pe12,pe13,pe23,eqps,damage,'// &
'shell_mem_max,shell_ben_max,shell_shr_max,'// &
'shell_k11,shell_k22,shell_k12'
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write element CSV header', ierr)
@@ -374,8 +470,10 @@ contains
end if
do elem = 1, nelem
call output_csv_average_element(elem, sig, eps, peps, eqps, damage)
write(unit_id,'(I12,A,I4,20(A,ES24.16))',iostat=ios) &
call output_csv_average_element(elem, sig, eps, peps, eqps, damage, &
shell_mem_max, shell_ben_max, &
shell_shr_max, shell_kappa)
write(unit_id,'(I12,A,I4,26(A,ES24.16))',iostat=ios) &
elem_id_ext(elem), ',', elem_status(elem), &
',', sig(1), ',', sig(2), ',', sig(3), &
',', sig(4), ',', sig(5), ',', sig(6), &
@@ -383,7 +481,9 @@ contains
',', eps(4), ',', eps(5), ',', eps(6), &
',', peps(1), ',', peps(2), ',', peps(3), &
',', peps(4), ',', peps(5), ',', peps(6), &
',', eqps, ',', damage
',', eqps, ',', damage, &
',', shell_mem_max, ',', shell_ben_max, ',', shell_shr_max, &
',', shell_kappa(1), ',', shell_kappa(2), ',', shell_kappa(3)
if (ios .ne. 0) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'failed to write element CSV row', ierr)
@@ -545,13 +645,23 @@ contains
subroutine output_csv_average_element(elem, sig, eps, peps, eqps, damage)
subroutine output_csv_average_element(elem, sig, eps, peps, eqps, damage, &
shell_mem_max, shell_ben_max, &
shell_shr_max, shell_kappa)
integer, intent(in) :: elem
real(rk), intent(out) :: sig(NSTRESS)
real(rk), intent(out) :: eps(NSTRESS)
real(rk), intent(out) :: peps(NSTRESS)
real(rk), intent(out) :: eqps
real(rk), intent(out) :: damage
real(rk), intent(out), optional :: shell_mem_max
real(rk), intent(out), optional :: shell_ben_max
real(rk), intent(out), optional :: shell_shr_max
real(rk), intent(out), optional :: shell_kappa(3)
real(rk) :: mem_max
real(rk) :: ben_max
real(rk) :: shr_max
real(rk) :: kappa(3)
integer :: gp
integer :: first_gp
integer :: last_gp
@@ -562,6 +672,14 @@ contains
peps = ZERO
eqps = ZERO
damage = ZERO
mem_max = ZERO
ben_max = ZERO
shr_max = ZERO
kappa = ZERO
if (present(shell_mem_max)) shell_mem_max = ZERO
if (present(shell_ben_max)) shell_ben_max = ZERO
if (present(shell_shr_max)) shell_shr_max = ZERO
if (present(shell_kappa)) shell_kappa = ZERO
if (.not. element_state_is_available()) return
if (elem .lt. 1 .or. elem .gt. nelem) return
@@ -577,6 +695,10 @@ contains
peps = peps + statev(5:10,gp)
eqps = eqps + statev(1,gp)
damage = damage + statev(2,gp)
kappa = kappa + statev(10:12,gp)
mem_max = max(mem_max, maxval(abs(strain((/1,2,4/),gp))))
ben_max = max(ben_max, maxval(abs(statev(10:12,gp))))
shr_max = max(shr_max, maxval(abs(strain(5:6,gp))))
end do
sig = sig / real(gp_count, rk)
@@ -584,6 +706,11 @@ contains
peps = peps / real(gp_count, rk)
eqps = eqps / real(gp_count, rk)
damage = damage / real(gp_count, rk)
kappa = kappa / real(gp_count, rk)
if (present(shell_mem_max)) shell_mem_max = mem_max
if (present(shell_ben_max)) shell_ben_max = ben_max
if (present(shell_shr_max)) shell_shr_max = shr_max
if (present(shell_kappa)) shell_kappa = kappa
end subroutine output_csv_average_element
subroutine output_csv_collect_history(total_mass, kinetic_energy, &
+15 -2
View File
@@ -4,6 +4,8 @@ module fem_restart
use fem_control
use fem_database
use fem_element_state
use fem_shell_rotation, only: shell_rotation_ensure, &
shell_rotation_write_restart, shell_rotation_read_restart
use fem_contact_history, only: contact_history_write, contact_history_read
use fem_contact_multiplier, only: contact_multiplier_write, &
contact_multiplier_read
@@ -48,6 +50,8 @@ contains
if (ios .ne. 0) go to 900
call write_restart_gauss(unit_id, ios)
if (ios .ne. 0) go to 900
call shell_rotation_write_restart(unit_id, ios)
if (ios .ne. 0) go to 900
call contact_history_write(unit_id, ios)
if (ios .ne. 0) go to 900
call contact_multiplier_write(unit_id, ios)
@@ -98,7 +102,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. 2) then
if (version .lt. 1 .or. version .gt. 3) then
close(unit_id)
call error_set(FEM_ERR_OUTPUT, 'unsupported restart version', ierr)
return
@@ -132,6 +136,15 @@ contains
close(unit_id)
return
end if
if (version .ge. 3) then
call shell_rotation_read_restart(unit_id, ierr)
else
call shell_rotation_ensure(ierr)
end if
if (ierr .ne. FEM_SUCCESS) then
close(unit_id)
return
end if
call read_restart_tail(unit_id, ierr)
if (ierr .ne. FEM_SUCCESS) then
@@ -155,7 +168,7 @@ contains
integer, intent(in) :: unit_id
integer, intent(out) :: ios
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 2
write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 3
if (ios .ne. 0) return
write(unit_id,'(A,4(1X,I12))',iostat=ios) 'COUNTS', nnode, nelem, &
ndof, ngauss_total