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

This commit is contained in:
shenw
2026-06-23 19:28:44 +08:00
parent f838ccc099
commit be02684827
74 changed files with 11618 additions and 201 deletions
+141 -7
View File
@@ -1,5 +1,7 @@
program femlite
use fem_precision
use fem_control, only: max_increment, max_newton_iter, newton_tol_force, &
output_interval
use fem_api
implicit none
@@ -22,10 +24,19 @@ program femlite
integer :: num_dload
integer :: step
integer :: iter
integer :: iarg
integer :: output_interval_arg
integer :: ios
real(rk) :: time
real(rk) :: res_norm
character(len=256) :: filename
character(len=256) :: arg
character(len=256) :: output_dir_arg
logical :: do_run
logical :: do_static_linear
logical :: do_static_nonlinear
logical :: do_implicit_newmark
logical :: do_implicit_newmark_nonlinear
intrinsic iargc
intrinsic getarg
@@ -45,6 +56,76 @@ program femlite
call fem_read_inp(trim(filename), ierr)
call exit_if_error(ierr)
do_run = .false.
do_static_linear = .false.
do_static_nonlinear = .false.
do_implicit_newmark = .false.
do_implicit_newmark_nonlinear = .false.
output_dir_arg = ' '
output_interval_arg = -1
iarg = 2
do while (iarg .le. argc)
call getarg(iarg, arg)
if (trim(arg) .eq. '--run') then
do_run = .true.
else if (trim(arg) .eq. '--implicit-linear') then
do_static_linear = .true.
else if (trim(arg) .eq. '--static-linear') then
do_static_linear = .true.
else if (trim(arg) .eq. '--static-nonlinear') then
do_static_nonlinear = .true.
else if (trim(arg) .eq. '--implicit-newmark') then
do_implicit_newmark = .true.
else if (trim(arg) .eq. '--implicit-newmark-nonlinear') then
do_implicit_newmark_nonlinear = .true.
else if (trim(arg) .eq. '--output-dir') then
if (iarg + 1 .gt. argc) then
write(*,'(A)') 'missing value after --output-dir'
call fem_finalize(ierr)
call exit(2)
end if
iarg = iarg + 1
call getarg(iarg, output_dir_arg)
else if (trim(arg) .eq. '--output-interval') then
if (iarg + 1 .gt. argc) then
write(*,'(A)') 'missing value after --output-interval'
call fem_finalize(ierr)
call exit(2)
end if
iarg = iarg + 1
call getarg(iarg, arg)
read(arg,*,iostat=ios) output_interval_arg
if (ios .ne. 0) then
write(*,'(A,A)') 'invalid --output-interval value: ', trim(arg)
call fem_finalize(ierr)
call exit(2)
end if
else
write(*,'(A,A)') 'unknown argument: ', trim(arg)
call fem_finalize(ierr)
call exit(2)
end if
iarg = iarg + 1
end do
if (count_true(do_run, do_static_linear, do_static_nonlinear, &
do_implicit_newmark, do_implicit_newmark_nonlinear) .gt. 1) then
write(*,'(A)') 'analysis mode options cannot be used together'
call fem_finalize(ierr)
call exit(2)
end if
if (len_trim(output_dir_arg) .gt. 0) then
call fem_set_output_directory(trim(output_dir_arg), ierr)
call exit_if_error(ierr)
end if
if (output_interval_arg .ge. 0) then
call fem_set_output_interval(output_interval_arg, ierr)
call exit_if_error(ierr)
end if
call fem_build_model(ierr)
call exit_if_error(ierr)
@@ -67,9 +148,7 @@ program femlite
write(*,'(A,I8)') ' cload: ', num_cload
write(*,'(A,I8)') ' dload: ', num_dload
if (argc .ge. 2) then
call getarg(2, arg)
if (trim(arg) .eq. '--run') then
if (do_run) then
call fem_run_explicit(ierr)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
@@ -77,17 +156,57 @@ program femlite
write(*,'(A)') 'Run completed'
write(*,'(A,I8)') ' steps: ', step
write(*,'(A,ES12.5)') ' time: ', time
else if (trim(arg) .eq. '--implicit-linear') then
call fem_solve_implicit_linear(500, 1.0e-10_rk, iter, res_norm, ierr)
else if (do_static_linear) then
call fem_solve_static_linear(500, 1.0e-10_rk, iter, res_norm, ierr)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
call exit_if_error(ierr)
write(*,'(A)') 'Implicit linear solve completed'
if (output_interval .gt. 0) then
call fem_write_output(step, time, ierr)
call exit_if_error(ierr)
end if
write(*,'(A)') 'Static linear solve completed'
write(*,'(A,I8)') ' steps: ', step
write(*,'(A,ES12.5)') ' time: ', time
write(*,'(A,I8)') ' cg iter: ', iter
write(*,'(A,ES12.5)') ' residual: ', res_norm
end if
else if (do_static_nonlinear) then
call fem_solve_static_nonlinear(max_increment, max_newton_iter, &
newton_tol_force, iter, res_norm, ierr)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
call exit_if_error(ierr)
if (output_interval .gt. 0) then
call fem_write_output(step, time, ierr)
call exit_if_error(ierr)
end if
write(*,'(A)') 'Static nonlinear solve completed'
write(*,'(A,I8)') ' increments:', step
write(*,'(A,ES12.5)') ' time: ', time
write(*,'(A,I8)') ' iterations:', iter
write(*,'(A,ES12.5)') ' residual: ', res_norm
else if (do_implicit_newmark) then
call fem_run_implicit_newmark(max_newton_iter, newton_tol_force, &
iter, res_norm, ierr)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
call exit_if_error(ierr)
write(*,'(A)') 'Implicit Newmark run completed'
write(*,'(A,I8)') ' steps: ', step
write(*,'(A,ES12.5)') ' time: ', time
write(*,'(A,I8)') ' iterations:', iter
write(*,'(A,ES12.5)') ' residual: ', res_norm
else if (do_implicit_newmark_nonlinear) then
call fem_run_newmark_nonlinear(max_newton_iter, newton_tol_force, &
iter, res_norm, ierr)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
call exit_if_error(ierr)
write(*,'(A)') 'Nonlinear Newmark run completed'
write(*,'(A,I8)') ' steps: ', step
write(*,'(A,ES12.5)') ' time: ', time
write(*,'(A,I8)') ' iterations:', iter
write(*,'(A,ES12.5)') ' residual: ', res_norm
end if
end if
@@ -110,4 +229,19 @@ contains
call fem_finalize(ierr_local)
call exit(1)
end subroutine exit_if_error
integer function count_true(a, b, c, d, e)
logical, intent(in) :: a
logical, intent(in) :: b
logical, intent(in) :: c
logical, intent(in) :: d
logical, intent(in) :: e
count_true = 0
if (a) count_true = count_true + 1
if (b) count_true = count_true + 1
if (c) count_true = count_true + 1
if (d) count_true = count_true + 1
if (e) count_true = count_true + 1
end function count_true
end program femlite