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
+264 -1
View File
@@ -12,6 +12,10 @@ program test_element_stiffness
call check_c3d8_stiff()
call check_c3d10_stiff()
call check_c3d20_stiff()
call check_s3_stiff()
call check_s4_stiff()
call check_s6_stiff()
call check_s8_stiff()
call check_bad_stiff_type()
contains
@@ -108,6 +112,98 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(59)
end subroutine check_c3d20_stiff
subroutine check_s3_stiff()
integer :: ierr
integer :: elem_dofs(MAX_TEST_DOF)
integer :: n_elem_dof
real(rk) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
call setup_s3(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(80)
call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(81)
if (n_elem_dof .ne. 18) call fail(82)
if (elem_dofs(1) .ne. 1 .or. elem_dofs(18) .ne. 18) call fail(83)
call check_symmetric(ke, n_elem_dof, 84)
call check_shell_rigid_translation(ke, n_elem_dof, 1, 85)
call check_shell_rigid_translation(ke, n_elem_dof, 2, 86)
call check_shell_rigid_translation(ke, n_elem_dof, 3, 87)
call check_positive_energy(ke, n_elem_dof, 88)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(89)
end subroutine check_s3_stiff
subroutine check_s4_stiff()
integer :: ierr
integer :: elem_dofs(MAX_TEST_DOF)
integer :: n_elem_dof
real(rk) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
call setup_s4(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(60)
call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(61)
if (n_elem_dof .ne. 24) call fail(62)
if (elem_dofs(1) .ne. 1 .or. elem_dofs(24) .ne. 24) call fail(63)
call check_symmetric(ke, n_elem_dof, 64)
call check_shell_rigid_translation(ke, n_elem_dof, 1, 65)
call check_shell_rigid_translation(ke, n_elem_dof, 2, 66)
call check_shell_rigid_translation(ke, n_elem_dof, 3, 67)
call check_positive_energy(ke, n_elem_dof, 68)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(69)
end subroutine check_s4_stiff
subroutine check_s6_stiff()
integer :: ierr
integer :: elem_dofs(MAX_TEST_DOF)
integer :: n_elem_dof
real(rk) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
call setup_s6(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(90)
call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(91)
if (n_elem_dof .ne. 36) call fail(92)
if (elem_dofs(1) .ne. 1 .or. elem_dofs(36) .ne. 36) call fail(93)
call check_symmetric(ke, n_elem_dof, 94)
call check_shell_rigid_translation(ke, n_elem_dof, 1, 95)
call check_shell_rigid_translation(ke, n_elem_dof, 2, 96)
call check_shell_rigid_translation(ke, n_elem_dof, 3, 97)
call check_positive_energy(ke, n_elem_dof, 98)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(99)
end subroutine check_s6_stiff
subroutine check_s8_stiff()
integer :: ierr
integer :: elem_dofs(MAX_TEST_DOF)
integer :: n_elem_dof
real(rk) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
call setup_s8(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(100)
call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(101)
if (n_elem_dof .ne. 48) call fail(102)
if (elem_dofs(1) .ne. 1 .or. elem_dofs(48) .ne. 48) call fail(103)
call check_symmetric(ke, n_elem_dof, 104)
call check_shell_rigid_translation(ke, n_elem_dof, 1, 105)
call check_shell_rigid_translation(ke, n_elem_dof, 2, 106)
call check_shell_rigid_translation(ke, n_elem_dof, 3, 107)
call check_positive_energy(ke, n_elem_dof, 108)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(109)
end subroutine check_s8_stiff
subroutine check_bad_stiff_type()
integer :: ierr
integer :: elem_dofs(MAX_TEST_DOF)
@@ -119,7 +215,7 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(70)
call fill_node_ids(4)
elem_id_ext(1) = 1
elem_type(1) = 'S4'
elem_type(1) = 'BAD'
elem_nnode(1) = 4
elem_conn(:,1) = 0
elem_conn(1:4,1) = (/ 1, 2, 3, 4 /)
@@ -262,6 +358,153 @@ contains
call database_assign_dofs(ierr)
end subroutine setup_c3d20
subroutine setup_s3(ierr)
integer, intent(out) :: ierr
call database_allocate_model(3, 1, 0, 1, 0, 1, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call fill_node_ids(3)
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
coord0(:,2) = (/ ONE, ZERO, ZERO /)
coord0(:,3) = (/ ZERO, ONE, ZERO /)
elem_id_ext(1) = 1
elem_type(1) = 'S3'
elem_nnode(1) = 3
elem_conn(:,1) = 0
elem_conn(1:3,1) = (/ 1, 2, 3 /)
elem_mat(1) = 1
elem_sec(1) = 1
elset_name(1) = 'EALL'
elset_start(1) = 1
elset_count(1) = 1
elset_items(1) = 1
mat_name(1) = 'MAT'
mat_density(1) = ONE
mat_e(1) = 30.0_rk
mat_nu(1) = 0.25_rk
section_type(1) = 'SHELL'
section_elset_name(1) = 'EALL'
section_material_name(1) = 'MAT'
section_thickness(1) = 0.2_rk
call database_assign_dofs(ierr)
end subroutine setup_s3
subroutine setup_s4(ierr)
integer, intent(out) :: ierr
call database_allocate_model(4, 1, 0, 1, 0, 1, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call fill_node_ids(4)
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
coord0(:,2) = (/ ONE, ZERO, ZERO /)
coord0(:,3) = (/ ONE, ONE, ZERO /)
coord0(:,4) = (/ ZERO, ONE, ZERO /)
elem_id_ext(1) = 1
elem_type(1) = 'S4'
elem_nnode(1) = 4
elem_conn(:,1) = 0
elem_conn(1:4,1) = (/ 1, 2, 3, 4 /)
elem_mat(1) = 1
elem_sec(1) = 1
elset_name(1) = 'EALL'
elset_start(1) = 1
elset_count(1) = 1
elset_items(1) = 1
mat_name(1) = 'MAT'
mat_density(1) = ONE
mat_e(1) = 30.0_rk
mat_nu(1) = 0.25_rk
section_type(1) = 'SHELL'
section_elset_name(1) = 'EALL'
section_material_name(1) = 'MAT'
section_thickness(1) = 0.2_rk
call database_assign_dofs(ierr)
end subroutine setup_s4
subroutine setup_s6(ierr)
integer, intent(out) :: ierr
call database_allocate_model(6, 1, 0, 1, 0, 1, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call fill_node_ids(6)
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
coord0(:,2) = (/ ONE, ZERO, ZERO /)
coord0(:,3) = (/ ZERO, ONE, ZERO /)
coord0(:,4) = HALF * (coord0(:,1) + coord0(:,2))
coord0(:,5) = HALF * (coord0(:,2) + coord0(:,3))
coord0(:,6) = HALF * (coord0(:,3) + coord0(:,1))
elem_id_ext(1) = 1
elem_type(1) = 'S6'
elem_nnode(1) = 6
elem_conn(:,1) = 0
elem_conn(1:6,1) = (/ 1, 2, 3, 4, 5, 6 /)
call fill_shell_common()
call database_assign_dofs(ierr)
end subroutine setup_s6
subroutine setup_s8(ierr)
integer, intent(out) :: ierr
call database_allocate_model(8, 1, 0, 1, 0, 1, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
call fill_node_ids(8)
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
coord0(:,2) = (/ ONE, ZERO, ZERO /)
coord0(:,3) = (/ ONE, ONE, ZERO /)
coord0(:,4) = (/ ZERO, ONE, ZERO /)
coord0(:,5) = HALF * (coord0(:,1) + coord0(:,2))
coord0(:,6) = HALF * (coord0(:,2) + coord0(:,3))
coord0(:,7) = HALF * (coord0(:,3) + coord0(:,4))
coord0(:,8) = HALF * (coord0(:,4) + coord0(:,1))
elem_id_ext(1) = 1
elem_type(1) = 'S8'
elem_nnode(1) = 8
elem_conn(:,1) = 0
elem_conn(1:8,1) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)
call fill_shell_common()
call database_assign_dofs(ierr)
end subroutine setup_s8
subroutine fill_shell_common()
elem_mat(1) = 1
elem_sec(1) = 1
elset_name(1) = 'EALL'
elset_start(1) = 1
elset_count(1) = 1
elset_items(1) = 1
mat_name(1) = 'MAT'
mat_density(1) = ONE
mat_e(1) = 30.0_rk
mat_nu(1) = 0.25_rk
section_type(1) = 'SHELL'
section_elset_name(1) = 'EALL'
section_material_name(1) = 'MAT'
section_thickness(1) = 0.2_rk
end subroutine fill_shell_common
subroutine fill_node_ids(count)
integer, intent(in) :: count
integer :: i
@@ -316,6 +559,26 @@ contains
if (maxval(abs(y(1:n))) .gt. TOL) call fail(code)
end subroutine check_rigid_translation
subroutine check_shell_rigid_translation(ke, n, idir, code)
real(rk), intent(in) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
integer, intent(in) :: n
integer, intent(in) :: idir
integer, intent(in) :: code
real(rk) :: x(MAX_TEST_DOF)
real(rk) :: y(MAX_TEST_DOF)
integer :: local_node
integer :: pos
x = ZERO
y = ZERO
do local_node = 1, n / NDOF_NODE
pos = NDOF_NODE * (local_node - 1) + idir
x(pos) = ONE
end do
y(1:n) = matmul(ke(1:n,1:n), x(1:n))
if (maxval(abs(y(1:n))) .gt. TOL) call fail(code)
end subroutine check_shell_rigid_translation
subroutine check_positive_energy(ke, n, code)
real(rk), intent(in) :: ke(MAX_TEST_DOF,MAX_TEST_DOF)
integer, intent(in) :: n