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
+195 -1
View File
@@ -3,9 +3,20 @@ program test_element_state
use fem_error
use fem_database
use fem_element_state
use fem_shell_rotation, only: shell_rotation_ensure, &
shell_rotation_begin_trial, shell_rotation_update_trial, &
shell_rotation_commit_trial, shell_rotation_restore_trial, &
shell_rotation_abort_trial, shell_rotation_get_committed, &
shell_rotation_get_trial, shell_rotation_rotate_vector, &
shell_rotation_sync_trial
implicit none
real(rk), parameter :: TOL = 1.0e-10_rk
call check_state_map()
call check_shell_rotation_state()
call check_shell_rotation_dof_sync()
call check_rot_increment_sync()
call check_unsupported_element()
contains
@@ -13,14 +24,20 @@ contains
subroutine check_state_map()
integer :: ierr
call database_allocate_mesh(1, 5, ierr)
call database_allocate_model(1, 5, 0, 0, 0, 0, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(1)
mat_plastic_model(1) = 'ELASTIC'
section_type(1) = 'SHELL'
section_thickness(1) = ONE
elem_type(1) = 'C3D4'
elem_type(2) = 'C3D8'
elem_type(3) = 'S4'
elem_type(4) = 'C3D10'
elem_type(5) = 'S8'
elem_mat = 1
elem_sec = 1
call element_state_ensure(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(2)
@@ -56,6 +73,170 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(23)
end subroutine check_state_map
subroutine check_shell_rotation_state()
integer :: ierr
real(rk) :: theta
real(rk) :: dtheta(NDIM)
real(rk) :: q(4)
real(rk) :: vec(NDIM)
real(rk) :: rotated(NDIM)
call database_allocate_mesh(2, 0, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(40)
call shell_rotation_ensure(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(41)
if (.not. allocated(shell_rotation_committed)) call fail(42)
if (.not. allocated(shell_rotation_trial)) call fail(43)
if (size(shell_rotation_committed,2) .ne. 2) call fail(44)
call shell_rotation_get_committed(1, q, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(45)
call check_close(q(1), ONE, 46)
call check_close(maxval(abs(q(2:4))), ZERO, 47)
theta = HALF * 4.0_rk * atan(ONE)
dtheta = ZERO
dtheta(3) = theta
call shell_rotation_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(48)
call shell_rotation_update_trial(1, dtheta, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(49)
vec = (/ ONE, ZERO, ZERO /)
call shell_rotation_rotate_vector(1, vec, rotated, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(50)
call check_close(rotated(1), ZERO, 51)
call check_close(rotated(2), ONE, 52)
call check_close(rotated(3), ZERO, 53)
call shell_rotation_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(54)
call shell_rotation_rotate_vector(1, vec, rotated, ierr, .false.)
if (ierr .ne. FEM_SUCCESS) call fail(55)
call check_close(rotated(1), ZERO, 56)
call check_close(rotated(2), ONE, 57)
call shell_rotation_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(58)
dtheta = ZERO
dtheta(3) = -theta
call shell_rotation_update_trial(1, dtheta, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(59)
call shell_rotation_restore_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(60)
call shell_rotation_get_trial(1, q, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(61)
call shell_rotation_rotate_vector(1, vec, rotated, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(62)
call check_close(rotated(1), ZERO, 63)
call check_close(rotated(2), ONE, 64)
dtheta = ZERO
dtheta(1) = theta
call shell_rotation_update_trial(1, dtheta, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(65)
call shell_rotation_abort_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(66)
call shell_rotation_rotate_vector(1, vec, rotated, ierr, .false.)
if (ierr .ne. FEM_SUCCESS) call fail(67)
call check_close(rotated(1), ZERO, 68)
call check_close(rotated(2), ONE, 69)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(70)
end subroutine check_shell_rotation_state
subroutine check_shell_rotation_dof_sync()
integer :: ierr
integer :: node
integer :: idir
real(rk) :: theta
real(rk) :: vec(NDIM)
real(rk) :: rotated(NDIM)
call database_allocate_basic(2, 0, 12, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(80)
do node = 1, 2
do idir = 1, 6
dof_id(idir,node) = 6 * (node - 1) + idir
end do
end do
u = ZERO
theta = HALF * 4.0_rk * atan(ONE)
u(dof_id(6,1)) = 0.20_rk
call shell_rotation_ensure(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(81)
call shell_rotation_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(82)
u(dof_id(6,1)) = 0.20_rk + theta
call shell_rotation_sync_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(83)
vec = (/ ONE, ZERO, ZERO /)
call shell_rotation_rotate_vector(1, vec, rotated, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(84)
call check_close(rotated(1), ZERO, 85)
call check_close(rotated(2), ONE, 86)
call check_close(rotated(3), ZERO, 87)
call shell_rotation_restore_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(88)
u(dof_id(6,1)) = 0.20_rk + HALF * theta
call shell_rotation_sync_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(89)
call shell_rotation_rotate_vector(1, vec, rotated, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(90)
call check_close(rotated(1), sqrt(HALF), 91)
call check_close(rotated(2), sqrt(HALF), 92)
call check_close(rotated(3), ZERO, 93)
call shell_rotation_commit_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(94)
call shell_rotation_rotate_vector(1, vec, rotated, ierr, .false.)
if (ierr .ne. FEM_SUCCESS) call fail(95)
call check_close(rotated(1), sqrt(HALF), 96)
call check_close(rotated(2), sqrt(HALF), 97)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(98)
end subroutine check_shell_rotation_dof_sync
subroutine check_rot_increment_sync()
integer :: ierr
integer :: idir
real(rk) :: theta
real(rk) :: vec(NDIM)
real(rk) :: rotated(NDIM)
call database_allocate_basic(1, 0, 6, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(110)
do idir = 1, 6
dof_id(idir,1) = idir
end do
u = ZERO
theta = HALF * 4.0_rk * atan(ONE)
call shell_rotation_ensure(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(111)
call shell_rotation_begin_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(112)
u(dof_id(4,1)) = theta
call shell_rotation_sync_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(113)
u(dof_id(6,1)) = theta
call shell_rotation_sync_trial(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(114)
vec = (/ ZERO, ONE, ZERO /)
call shell_rotation_rotate_vector(1, vec, rotated, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(115)
call check_close(rotated(1), ZERO, 116)
call check_close(rotated(2), ZERO, 117)
call check_close(rotated(3), ONE, 118)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(119)
end subroutine check_rot_increment_sync
subroutine check_unsupported_element()
integer :: ierr
@@ -77,4 +258,17 @@ contains
stop 1
end subroutine fail
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 * max(ONE, abs(expected))) then
write(*,'(A,I0,A,ES16.8,A,ES16.8)') &
'test_element_state failed:', code, ' actual=', actual, &
' expected=', expected
stop 1
end if
end subroutine check_close
end program test_element_state