Add basic rigid plane contact support
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
program test_contact
|
||||
use fem_precision
|
||||
use fem_error
|
||||
use fem_database
|
||||
use fem_contact
|
||||
use fem_api
|
||||
implicit none
|
||||
|
||||
real(rk), parameter :: TOL = 1.0e-10_rk
|
||||
|
||||
call check_plane_force()
|
||||
call check_target_node_only()
|
||||
call check_explicit_contact_step()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_plane_force()
|
||||
integer :: ierr
|
||||
integer :: dof1
|
||||
integer :: dof2
|
||||
|
||||
call setup_basic_nodes(2, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(1)
|
||||
call database_allocate_contact(1, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(2)
|
||||
|
||||
contact_target(1) = 'ALL'
|
||||
contact_normal(:,1) = (/ ZERO, ZERO, ONE /)
|
||||
contact_offset(1) = ZERO
|
||||
contact_penalty(1) = 100.0_rk
|
||||
contact_damping(1) = 10.0_rk
|
||||
|
||||
dof1 = dof_id(3,1)
|
||||
dof2 = dof_id(3,2)
|
||||
u(dof1) = -0.02_rk
|
||||
v(dof1) = -0.10_rk
|
||||
u(dof2) = 0.02_rk
|
||||
|
||||
call contact_apply_plane_forces(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(3)
|
||||
call check_close(fcontact(dof1), 3.0_rk, 4)
|
||||
call check_close(fcontact(dof2), ZERO, 5)
|
||||
|
||||
call database_finalize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(6)
|
||||
end subroutine check_plane_force
|
||||
|
||||
subroutine check_target_node_only()
|
||||
integer :: ierr
|
||||
integer :: dof1
|
||||
integer :: dof2
|
||||
|
||||
call setup_basic_nodes(2, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(10)
|
||||
call database_allocate_contact(1, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(11)
|
||||
|
||||
contact_target(1) = '2'
|
||||
contact_normal(:,1) = (/ ZERO, ZERO, 2.0_rk /)
|
||||
contact_offset(1) = ZERO
|
||||
contact_penalty(1) = 100.0_rk
|
||||
contact_damping(1) = ZERO
|
||||
|
||||
dof1 = dof_id(3,1)
|
||||
dof2 = dof_id(3,2)
|
||||
u(dof1) = -0.02_rk
|
||||
u(dof2) = -0.02_rk
|
||||
|
||||
call contact_apply_plane_forces(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(12)
|
||||
call check_close(fcontact(dof1), ZERO, 13)
|
||||
call check_close(fcontact(dof2), 2.0_rk, 14)
|
||||
|
||||
call database_finalize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(15)
|
||||
end subroutine check_target_node_only
|
||||
|
||||
subroutine check_explicit_contact_step()
|
||||
integer :: ierr
|
||||
integer :: dof
|
||||
|
||||
call fem_initialize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(20)
|
||||
|
||||
call setup_basic_nodes(1, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(21)
|
||||
mass_diag = ONE
|
||||
call database_allocate_contact(1, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(22)
|
||||
|
||||
contact_target(1) = 'ALL'
|
||||
contact_normal(:,1) = (/ ZERO, ZERO, ONE /)
|
||||
contact_offset(1) = ZERO
|
||||
contact_penalty(1) = 10.0_rk
|
||||
contact_damping(1) = ZERO
|
||||
|
||||
dof = dof_id(3,1)
|
||||
u(dof) = -0.10_rk
|
||||
|
||||
call fem_advance_explicit(0.10_rk, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(23)
|
||||
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_finalize(ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) call fail(27)
|
||||
end subroutine check_explicit_contact_step
|
||||
|
||||
subroutine setup_basic_nodes(num_nodes, ierr)
|
||||
integer, intent(in) :: num_nodes
|
||||
integer, intent(out) :: ierr
|
||||
integer :: node
|
||||
integer :: idir
|
||||
integer :: counter
|
||||
|
||||
call database_allocate_basic(num_nodes, 0, 3 * num_nodes, ierr)
|
||||
if (ierr .ne. FEM_SUCCESS) return
|
||||
|
||||
counter = 0
|
||||
do node = 1, num_nodes
|
||||
node_id_ext(node) = node
|
||||
coord0(:,node) = ZERO
|
||||
coord(:,node) = ZERO
|
||||
do idir = 1, NDIM
|
||||
counter = counter + 1
|
||||
dof_id(idir,node) = counter
|
||||
end do
|
||||
end do
|
||||
|
||||
ierr = FEM_SUCCESS
|
||||
end subroutine setup_basic_nodes
|
||||
|
||||
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))) call fail(code)
|
||||
end subroutine check_close
|
||||
|
||||
subroutine fail(code)
|
||||
integer, intent(in) :: code
|
||||
|
||||
write(*,*) 'test_contact failed:', code
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_contact
|
||||
Reference in New Issue
Block a user