108 lines
3.9 KiB
Fortran
108 lines
3.9 KiB
Fortran
program test_coupling_stale_epoch_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: SPH_COUPLING_DISTRIBUTION_AREA
|
|
use sph_coupling_interface, only: coupling_contact_flag, coupling_external_force, &
|
|
sph_coupling_apply_contact_state, sph_coupling_apply_facet_pressures, &
|
|
sph_coupling_clear_imports, sph_coupling_get_contact_diagnostics
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed for stale epoch')
|
|
call sph_read_inp('tests/data/coupling_load_mode_081.inp', ierr)
|
|
call assert_ok(ierr, 'read failed for stale epoch')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build failed for stale epoch')
|
|
|
|
call check_contact_stale_clear()
|
|
call check_pressure_stale_clear()
|
|
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed for stale epoch')
|
|
|
|
contains
|
|
|
|
subroutine check_contact_stale_clear()
|
|
integer :: ids(1)
|
|
real(rk) :: normals(SPH_NDIM,1)
|
|
real(rk) :: gaps(1)
|
|
real(rk) :: penetrations(1)
|
|
real(rk) :: contact_pressures(1)
|
|
integer :: active_count
|
|
integer :: skipped_count
|
|
integer :: stale_count
|
|
integer :: repeated_count
|
|
integer :: nonfinite_count
|
|
integer :: bad_area_count
|
|
integer :: invalid_weight_count
|
|
real(rk) :: max_penetration
|
|
|
|
ids(1) = 1
|
|
normals(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /)
|
|
gaps(1) = 0.0_rk
|
|
penetrations(1) = 1.0e-3_rk
|
|
contact_pressures(1) = 5.0_rk
|
|
call sph_coupling_apply_contact_state(1, 1, ids, normals, gaps, &
|
|
penetrations, contact_pressures, 301, ierr)
|
|
call assert_ok(ierr, 'contact import failed for stale epoch')
|
|
call sph_coupling_clear_imports(ierr)
|
|
call assert_ok(ierr, 'clear imports failed after contact state')
|
|
if (maxval(coupling_contact_flag) /= 0) then
|
|
call fail('contact cache was not cleared')
|
|
end if
|
|
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
|
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
|
bad_area_count, invalid_weight_count, ierr)
|
|
call assert_ok(ierr, 'contact stale diagnostics failed')
|
|
if (active_count /= 0) call fail('active contact count was not cleared')
|
|
if (stale_count <= 0) call fail('contact stale count missing')
|
|
end subroutine check_contact_stale_clear
|
|
|
|
subroutine check_pressure_stale_clear()
|
|
integer :: ids(1)
|
|
real(rk) :: pressures(1)
|
|
integer :: active_count
|
|
integer :: skipped_count
|
|
integer :: stale_count
|
|
integer :: repeated_count
|
|
integer :: nonfinite_count
|
|
integer :: bad_area_count
|
|
integer :: invalid_weight_count
|
|
real(rk) :: max_penetration
|
|
|
|
ids(1) = 1
|
|
pressures(1) = 10.0_rk
|
|
call sph_coupling_apply_facet_pressures(1, 1, ids, pressures, &
|
|
SPH_COUPLING_DISTRIBUTION_AREA, 302, ierr)
|
|
call assert_ok(ierr, 'pressure import failed for stale epoch')
|
|
call sph_coupling_clear_imports(ierr)
|
|
call assert_ok(ierr, 'clear imports failed after pressure')
|
|
if (maxval(abs(coupling_external_force)) > 0.0_rk) then
|
|
call fail('pressure force cache was not cleared')
|
|
end if
|
|
call sph_coupling_get_contact_diagnostics(active_count, skipped_count, &
|
|
max_penetration, stale_count, repeated_count, nonfinite_count, &
|
|
bad_area_count, invalid_weight_count, ierr)
|
|
call assert_ok(ierr, 'pressure stale diagnostics failed')
|
|
if (stale_count < 2) call fail('pressure stale count missing')
|
|
end subroutine check_pressure_stale_clear
|
|
|
|
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_stale_epoch_081
|