Prepare FemLite 0.3.1 contact and shell updates

This commit is contained in:
shenw
2026-06-23 19:45:33 +08:00
parent be02684827
commit 8710688540
16 changed files with 470 additions and 123 deletions
+142
View File
@@ -15,6 +15,8 @@ program test_contact
call check_explicit_contact_step()
call check_surface_pair_force()
call check_surface_pair_tangent()
call check_surface_pair_friction()
call check_surface_pair_multimaster()
contains
@@ -168,6 +170,81 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(47)
end subroutine check_surface_pair_tangent
subroutine check_surface_pair_friction()
type(csr_matrix) :: kmat
integer :: ierr
integer :: stat
integer :: node
integer :: dof
integer :: row
integer :: col
real(rk) :: value
call setup_contact_shell_pair(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(50)
contact_pair_friction(1) = 0.2_rk
do node = 5, 8
dof = dof_id(1,node)
v(dof) = ONE
end do
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(51)
do node = 1, 4
dof = dof_id(1,node)
call check_close(fcontact(dof), 0.5_rk, 52)
end do
do node = 5, 8
dof = dof_id(1,node)
call check_close(fcontact(dof), -0.5_rk, 53)
end do
call csr_init(kmat)
call assembly_build_csr_pattern(kmat, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(54)
call contact_apply_plane_tangent(kmat, ZERO, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(55)
row = dof_id(1,5)
col = dof_id(1,5)
call csr_get_value(kmat, row, col, value, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(56)
call check_close(value, 12.5_rk, 57)
call csr_free(kmat, stat)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(58)
end subroutine check_surface_pair_friction
subroutine check_surface_pair_multimaster()
integer :: ierr
integer :: node
integer :: dof
call setup_contact_shell_multimaster(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(60)
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(61)
do node = 5, 8
dof = dof_id(3,node)
call check_close(fcontact(dof), 2.5_rk, 62)
end do
do node = 1, 4
dof = dof_id(3,node)
call check_close(fcontact(dof), -1.25_rk, 63)
end do
do node = 9, 12
dof = dof_id(3,node)
call check_close(fcontact(dof), -1.25_rk, 64)
end do
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(65)
end subroutine check_surface_pair_multimaster
subroutine setup_basic_nodes(num_nodes, ierr)
integer, intent(in) :: num_nodes
integer, intent(out) :: ierr
@@ -254,9 +331,74 @@ contains
contact_pair_penalty(1) = 1000.0_rk
contact_pair_damping(1) = ZERO
contact_pair_search(1) = 0.1_rk
contact_pair_friction(1) = ZERO
ierr = FEM_SUCCESS
end subroutine setup_contact_shell_pair
subroutine setup_contact_shell_multimaster(ierr)
integer, intent(out) :: ierr
call database_allocate_model(12, 3, 0, 2, 0, 3, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
node_id_ext(1:12) = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 /)
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
coord0(:,2) = (/ ONE, ZERO, ZERO /)
coord0(:,3) = (/ ONE, ONE, ZERO /)
coord0(:,4) = (/ ZERO, ONE, ZERO /)
coord0(:,5) = (/ ZERO, ZERO, -0.01_rk /)
coord0(:,6) = (/ ONE, ZERO, -0.01_rk /)
coord0(:,7) = (/ ONE, ONE, -0.01_rk /)
coord0(:,8) = (/ ZERO, ONE, -0.01_rk /)
coord0(:,9) = coord0(:,1)
coord0(:,10) = coord0(:,2)
coord0(:,11) = coord0(:,3)
coord0(:,12) = coord0(:,4)
coord = coord0
elem_id_ext(1:3) = (/ 1, 2, 3 /)
elem_type(1:3) = 'S4'
elem_nnode(1:3) = 4
elem_conn(:,1:3) = 0
elem_conn(1:4,1) = (/ 1, 2, 3, 4 /)
elem_conn(1:4,2) = (/ 5, 6, 7, 8 /)
elem_conn(1:4,3) = (/ 9, 10, 11, 12 /)
elem_mat(1:3) = 1
elem_sec(1:3) = 1
elset_name(1) = 'MASTER'
elset_start(1) = 1
elset_count(1) = 2
elset_items(1:2) = (/ 1, 3 /)
elset_name(2) = 'SLAVE'
elset_start(2) = 3
elset_count(2) = 1
elset_items(3) = 2
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) = 'ALL'
section_material_name(1) = 'MAT'
section_thickness(1) = 0.1_rk
call database_assign_dofs(ierr)
if (ierr .ne. FEM_SUCCESS) return
call database_allocate_contact_pair(1, ierr)
if (ierr .ne. FEM_SUCCESS) return
contact_pair_slave(1) = 'SLAVE'
contact_pair_master(1) = 'MASTER'
contact_pair_penalty(1) = 1000.0_rk
contact_pair_damping(1) = ZERO
contact_pair_search(1) = 0.1_rk
contact_pair_friction(1) = ZERO
ierr = FEM_SUCCESS
end subroutine setup_contact_shell_multimaster
subroutine check_close(actual, expected, code)
real(rk), intent(in) :: actual
real(rk), intent(in) :: expected
+6
View File
@@ -76,9 +76,12 @@ contains
integer :: elem_dofs(MAX_SHELL_TEST_DOF)
integer :: n_elem_dof
real(rk) :: ke(MAX_SHELL_TEST_DOF,MAX_SHELL_TEST_DOF)
real(rk) :: ke_elastic(MAX_SHELL_TEST_DOF,MAX_SHELL_TEST_DOF)
call setup_s4_j2(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(451)
call element_linear_stiffness(1, elem_dofs, n_elem_dof, ke_elastic, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(450)
call apply_x_extension(EXX)
call element_compute_internal_force(ierr, 0.1_rk)
@@ -92,6 +95,9 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(457)
if (n_elem_dof .ne. 24) call fail(458)
call check_matrix_symmetric(ke, n_elem_dof, 459)
if (ke(1,1) .ge. ke_elastic(1,1)) call fail(461)
if (ke(5,5) .ge. ke_elastic(5,5)) call fail(462)
if (ke(3,3) .le. ZERO) call fail(463)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(460)