Add implicit linear CLI workflow

This commit is contained in:
shenw
2026-06-22 22:06:11 +08:00
parent f852a93b91
commit fbbb9c344f
4 changed files with 120 additions and 0 deletions
+19
View File
@@ -151,6 +151,13 @@ add_executable(test_solver_implicit
target_link_libraries(test_solver_implicit PRIVATE femlite_core)
femlite_apply_fortran_options(test_solver_implicit)
add_executable(test_implicit_inp
tests/module/test_implicit_inp.f90
)
target_link_libraries(test_implicit_inp PRIVATE femlite_core)
femlite_apply_fortran_options(test_implicit_inp)
add_executable(perf_p1
tests/performance/perf_p1.f90
)
@@ -212,3 +219,15 @@ add_test(NAME solver_implicit COMMAND test_solver_implicit)
set_tests_properties(solver_implicit PROPERTIES
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
add_test(NAME implicit_inp COMMAND test_implicit_inp)
set_tests_properties(implicit_inp PROPERTIES
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
add_test(NAME cli_implicit_linear
COMMAND femlite tests/data/c3d4_implicit_pull.inp --implicit-linear
)
set_tests_properties(cli_implicit_linear PROPERTIES
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
+12
View File
@@ -21,7 +21,9 @@ program femlite
integer :: num_cload
integer :: num_dload
integer :: step
integer :: iter
real(rk) :: time
real(rk) :: res_norm
character(len=256) :: filename
character(len=256) :: arg
@@ -75,6 +77,16 @@ 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)
call exit_if_error(ierr)
call fem_get_current_time(time, step, ierr)
call exit_if_error(ierr)
write(*,'(A)') 'Implicit 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
end if
end if
+26
View File
@@ -0,0 +1,26 @@
*HEADING
FemLite C3D4 implicit linear pull verification
*NODE
1, 0.0, 0.0, 0.0
2, 1.0, 0.0, 0.0
3, 0.0, 1.0, 0.0
4, 0.0, 0.0, 1.0
*ELEMENT, TYPE=C3D4, ELSET=EALL
1, 1, 2, 3, 4
*MATERIAL, NAME=MAT
*DENSITY
1.0
*ELASTIC
30.0, 0.25
*SOLID SECTION, ELSET=EALL, MATERIAL=MAT
*BOUNDARY
1, 1, 3, 0.0
2, 2, 3, 0.0
3, 1, 3, 0.0
4, 1, 3, 0.0
*CLOAD
2, 1, 5.0
*STEP
*DYNAMIC
1.0
*END STEP
+63
View File
@@ -0,0 +1,63 @@
program test_implicit_inp
use fem_precision
use fem_api
implicit none
real(rk), parameter :: TOL = 1.0e-10_rk
integer :: ierr
integer :: iter
integer :: step
real(rk) :: res_norm
real(rk) :: time
real(rk) :: displacement(NDIM)
real(rk) :: velocity(NDIM)
real(rk) :: acceleration(NDIM)
call fem_initialize(ierr)
if (ierr .ne. 0) call fail(1)
call fem_read_inp('tests/data/c3d4_implicit_pull.inp', ierr)
if (ierr .ne. 0) call fail(2)
call fem_build_model(ierr)
if (ierr .ne. 0) call fail(3)
call fem_solve_implicit_linear(50, 1.0e-12_rk, iter, res_norm, ierr)
if (ierr .ne. 0) call fail(4)
if (iter .le. 0 .or. iter .gt. 5) call fail(5)
if (res_norm .gt. TOL) call fail(6)
call fem_get_node_kinematics(2, displacement, velocity, acceleration, ierr)
if (ierr .ne. 0) call fail(7)
call check_close(displacement(1), 5.0_rk / 6.0_rk, 8)
call check_close(displacement(2), ZERO, 9)
call check_close(displacement(3), ZERO, 10)
call check_close(maxval(abs(velocity)), ZERO, 11)
call check_close(maxval(abs(acceleration)), ZERO, 12)
call fem_get_current_time(time, step, ierr)
if (ierr .ne. 0) call fail(13)
call check_close(time, ZERO, 14)
if (step .ne. 1) call fail(15)
call fem_finalize(ierr)
if (ierr .ne. 0) call fail(16)
contains
subroutine check_close(actual, expected, code)
real(rk), intent(in) :: actual
real(rk), intent(in) :: expected
integer, intent(in) :: code
if (abs(actual - expected) .gt. TOL) call fail(code)
end subroutine check_close
subroutine fail(code)
integer, intent(in) :: code
write(*,*) 'test_implicit_inp failed:', code
stop 1
end subroutine fail
end program test_implicit_inp