Enhance contact clipping search and output

This commit is contained in:
shenw committed 2026-06-23 20:11:55 +08:00
1 parent 8710688540
commit dd13b44890
15 files changed
+1243 -128

No files matched your search

+161 -1
View File
@@ -17,6 +17,8 @@ program test_contact
call check_surface_pair_tangent()
call check_surface_pair_friction()
call check_surface_pair_multimaster()
call check_pair_clipped()
call check_pair_grid()
contains
@@ -84,6 +86,11 @@ contains
subroutine check_explicit_contact_step()
integer :: ierr
integer :: dof
integer :: active_count
real(rk) :: work_step
real(rk) :: work_total
real(rk) :: max_penetration
real(rk) :: force_norm
call fem_initialize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(20)
@@ -108,9 +115,16 @@ contains
call check_close(a(dof), ONE, 24)
call check_close(v(dof), 0.10_rk, 25)
call check_close(u(dof), -0.095_rk, 26)
call fem_get_contact_summary(active_count, work_step, work_total, &
max_penetration, force_norm, ierr)
if (ierr .ne. FEM_SUCCESS) call fail(27)
if (active_count .ne. 1) call fail(28)
call check_close(max_penetration, 0.10_rk, 29)
call check_close(force_norm, ONE, 30)
call check_close(work_step, 0.05_rk, 31)
call fem_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(27)
if (ierr .ne. FEM_SUCCESS) call fail(32)
end subroutine check_explicit_contact_step
subroutine check_surface_pair_force()
@@ -245,6 +259,74 @@ contains
if (ierr .ne. FEM_SUCCESS) call fail(65)
end subroutine check_surface_pair_multimaster
subroutine check_pair_clipped()
integer :: ierr
integer :: node
integer :: dof
call setup_contact_shell_pair(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(70)
do node = 5, 8
coord0(1,node) = coord0(1,node) + 0.5_rk
end do
coord = coord0
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(71)
do node = 5, 8
dof = dof_id(3,node)
call check_close(fcontact(dof), 1.25_rk, 72)
end do
do node = 1, 4
dof = dof_id(3,node)
call check_close(fcontact(dof), -1.25_rk, 73)
end do
if (contact_active_count .ne. 1) call fail(74)
if (contact_pair_active(1) .ne. 1) call fail(75)
call check_close(contact_max_penetration, 0.01_rk, 76)
call check_close(contact_pair_max_penetration(1), 0.01_rk, 77)
call check_close(contact_force_norm, 5.0_rk, 78)
call check_close(contact_pair_force_norm(1), 5.0_rk, 79)
call check_close(contact_work_step, 0.025_rk, 80)
call check_close(contact_pair_work(1), 0.025_rk, 81)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(82)
end subroutine check_pair_clipped
subroutine check_pair_grid()
integer :: ierr
integer :: node
integer :: dof
call setup_contact_grid_pair(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(90)
call contact_apply_plane_forces(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(91)
do node = 73, 76
dof = dof_id(3,node)
call check_close(fcontact(dof), 2.5_rk, 92)
end do
do node = 1, 4
dof = dof_id(3,node)
call check_close(fcontact(dof), -2.5_rk, 93)
end do
do node = 5, 72
dof = dof_id(3,node)
call check_close(fcontact(dof), ZERO, 94)
end do
if (contact_active_count .ne. 1) call fail(95)
call check_close(contact_force_norm, 10.0_rk, 96)
call database_finalize(ierr)
if (ierr .ne. FEM_SUCCESS) call fail(97)
end subroutine check_pair_grid
subroutine setup_basic_nodes(num_nodes, ierr)
integer, intent(in) :: num_nodes
integer, intent(out) :: ierr
@@ -399,6 +481,84 @@ contains
ierr = FEM_SUCCESS
end subroutine setup_contact_shell_multimaster
subroutine setup_contact_grid_pair(ierr)
integer, intent(out) :: ierr
integer :: master
integer :: node_base
integer :: xshift
call database_allocate_model(76, 19, 0, 2, 0, 19, 1, 0, 1, &
0, 0, 0, 0, 0, ierr)
if (ierr .ne. FEM_SUCCESS) return
do master = 1, 18
node_base = 4 * (master - 1)
xshift = 10 * (master - 1)
node_id_ext(node_base+1:node_base+4) = &
(/ node_base + 1, node_base + 2, node_base + 3, node_base + 4 /)
coord0(:,node_base+1) = (/ real(xshift, rk), ZERO, ZERO /)
coord0(:,node_base+2) = (/ real(xshift, rk) + ONE, ZERO, ZERO /)
coord0(:,node_base+3) = (/ real(xshift, rk) + ONE, ONE, ZERO /)
coord0(:,node_base+4) = (/ real(xshift, rk), ONE, ZERO /)
elem_id_ext(master) = master
elem_type(master) = 'S4'
elem_nnode(master) = 4
elem_conn(:,master) = 0
elem_conn(1:4,master) = &
(/ node_base + 1, node_base + 2, node_base + 3, node_base + 4 /)
elem_mat(master) = 1
elem_sec(master) = 1
end do
node_id_ext(73:76) = (/ 73, 74, 75, 76 /)
coord0(:,73) = (/ ZERO, ZERO, -0.01_rk /)
coord0(:,74) = (/ ONE, ZERO, -0.01_rk /)
coord0(:,75) = (/ ONE, ONE, -0.01_rk /)
coord0(:,76) = (/ ZERO, ONE, -0.01_rk /)
coord = coord0
elem_id_ext(19) = 19
elem_type(19) = 'S4'
elem_nnode(19) = 4
elem_conn(:,19) = 0
elem_conn(1:4,19) = (/ 73, 74, 75, 76 /)
elem_mat(19) = 1
elem_sec(19) = 1
elset_name(1) = 'MASTER'
elset_start(1) = 1
elset_count(1) = 18
do master = 1, 18
elset_items(master) = master
end do
elset_name(2) = 'SLAVE'
elset_start(2) = 19
elset_count(2) = 1
elset_items(19) = 19
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_grid_pair
subroutine check_close(actual, expected, code)
real(rk), intent(in) :: actual
real(rk), intent(in) :: expected
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.