72 lines
3.0 KiB
Fortran
72 lines
3.0 KiB
Fortran
program test_coupling_contact_state_081
|
|
use sph_precision, only: rk, SPH_NDIM
|
|
use sph_error, only: SPH_SUCCESS
|
|
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
|
use sph_database, only: npart
|
|
use sph_coupling_interface, only: sph_coupling_clear_imports, &
|
|
coupling_contact_flag, coupling_contact_normal, coupling_contact_gap, &
|
|
coupling_contact_penetration, coupling_contact_pressure
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for contact state cache')
|
|
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for contact state cache')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for contact state cache')
|
|
|
|
if (npart /= 4) call fail('contact cache particle count mismatch')
|
|
call assert_contact_cache_zero('build initialized contact cache')
|
|
|
|
coupling_contact_flag(1) = 1
|
|
coupling_contact_normal(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
|
coupling_contact_gap(1) = 1.0e-4_rk
|
|
coupling_contact_penetration(1) = 2.0e-4_rk
|
|
coupling_contact_pressure(1) = 3.0_rk
|
|
call sph_coupling_clear_imports(ierr)
|
|
call assert_ok(ierr, 'clear imports failed for contact cache')
|
|
call assert_contact_cache_zero('clear imports did not reset contact cache')
|
|
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for contact state cache')
|
|
|
|
contains
|
|
|
|
subroutine assert_contact_cache_zero(message)
|
|
character(len=*), intent(in) :: message
|
|
|
|
if (.not. allocated(coupling_contact_flag)) call fail('contact flag cache not allocated')
|
|
if (.not. allocated(coupling_contact_normal)) call fail('contact normal cache not allocated')
|
|
if (.not. allocated(coupling_contact_gap)) call fail('contact gap cache not allocated')
|
|
if (.not. allocated(coupling_contact_penetration)) call fail('contact penetration cache not allocated')
|
|
if (.not. allocated(coupling_contact_pressure)) call fail('contact pressure cache not allocated')
|
|
if (size(coupling_contact_flag) /= npart) call fail('contact flag cache size mismatch')
|
|
if (size(coupling_contact_normal,1) /= SPH_NDIM .or. &
|
|
size(coupling_contact_normal,2) /= npart) then
|
|
call fail('contact normal cache size mismatch')
|
|
end if
|
|
if (maxval(abs(coupling_contact_flag)) /= 0) call fail(message)
|
|
if (maxval(abs(coupling_contact_normal)) > 0.0_rk) call fail(message)
|
|
if (maxval(abs(coupling_contact_gap)) > 0.0_rk) call fail(message)
|
|
if (maxval(abs(coupling_contact_penetration)) > 0.0_rk) call fail(message)
|
|
if (maxval(abs(coupling_contact_pressure)) > 0.0_rk) call fail(message)
|
|
end subroutine assert_contact_cache_zero
|
|
|
|
subroutine assert_ok(ierr_value, message)
|
|
integer, intent(in) :: ierr_value
|
|
character(len=*), intent(in) :: message
|
|
|
|
if (ierr_value /= SPH_SUCCESS) call fail(message)
|
|
end subroutine assert_ok
|
|
|
|
subroutine fail(message)
|
|
character(len=*), intent(in) :: message
|
|
|
|
write(*, '(A)') trim(message)
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_coupling_contact_state_081
|