Harden explosive input coverage
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
program test_input_explosive_multi_ignition
|
||||
use sph_precision, only: rk
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
||||
use sph_explosive_state, only: explosive_detonation_time, &
|
||||
explosive_ignition_count, explosive_ignition_material_id
|
||||
implicit none
|
||||
|
||||
real(rk) :: forward_times(4)
|
||||
real(rk) :: reversed_times(4)
|
||||
|
||||
call read_times('tests/data/explosive_multi_ignition_forward_041.inp', &
|
||||
forward_times)
|
||||
call read_times('tests/data/explosive_multi_ignition_reversed_041.inp', &
|
||||
reversed_times)
|
||||
call assert_close_array(forward_times, reversed_times, &
|
||||
'multi ignition order changed detonation times')
|
||||
call assert_close(forward_times(1), 0.0_rk, 'first particle arrival mismatch')
|
||||
call assert_close(forward_times(2), 0.10_rk / 6900.0_rk, &
|
||||
'second particle minimum arrival mismatch')
|
||||
call assert_close(forward_times(3), 0.10_rk / 6900.0_rk, &
|
||||
'third particle minimum arrival mismatch')
|
||||
call assert_close(forward_times(4), 0.0_rk, 'fourth particle arrival mismatch')
|
||||
call assert_cross_material()
|
||||
call assert_missing_matching_ignition()
|
||||
call assert_reinitialize_clears_ignitions()
|
||||
|
||||
contains
|
||||
|
||||
subroutine read_times(filename, values)
|
||||
character(len=*), intent(in) :: filename
|
||||
real(rk), intent(out) :: values(4)
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp(filename, ierr)
|
||||
call assert_ok(ierr, 'read multi ignition input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build multi ignition input failed')
|
||||
if (explosive_ignition_count /= 2) call fail('multi ignition count mismatch')
|
||||
if (explosive_ignition_material_id(1) /= explosive_ignition_material_id(2)) then
|
||||
call fail('multi ignition material mismatch')
|
||||
end if
|
||||
values = explosive_detonation_time(1:4)
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
end subroutine read_times
|
||||
|
||||
subroutine assert_cross_material()
|
||||
integer :: ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize cross material failed')
|
||||
call sph_read_inp('tests/data/explosive_multi_ignition_cross_material_041.inp', &
|
||||
ierr)
|
||||
call assert_ok(ierr, 'read cross material ignition failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build cross material ignition failed')
|
||||
call assert_close(explosive_detonation_time(1), 0.0_rk, &
|
||||
'TNT ignition mismatch')
|
||||
call assert_close(explosive_detonation_time(2), 0.10_rk / 6900.0_rk, &
|
||||
'TNT material filter mismatch')
|
||||
call assert_close(explosive_detonation_time(3), 0.10_rk / 7600.0_rk, &
|
||||
'PBX material filter mismatch')
|
||||
call assert_close(explosive_detonation_time(4), 0.0_rk, &
|
||||
'PBX ignition mismatch')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize cross material failed')
|
||||
end subroutine assert_cross_material
|
||||
|
||||
subroutine assert_missing_matching_ignition()
|
||||
integer :: ierr
|
||||
integer :: final_ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize missing ignition failed')
|
||||
call sph_read_inp('tests/data/explosive_missing_matching_ignition_041.inp', &
|
||||
ierr)
|
||||
if (ierr == SPH_SUCCESS) call sph_build_model(ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('missing matching ignition passed')
|
||||
call sph_finalize(final_ierr)
|
||||
call assert_ok(final_ierr, 'finalize missing ignition failed')
|
||||
end subroutine assert_missing_matching_ignition
|
||||
|
||||
subroutine assert_reinitialize_clears_ignitions()
|
||||
integer :: ierr
|
||||
integer :: final_ierr
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize stale ignition case failed')
|
||||
call sph_read_inp('tests/data/explosive_multi_ignition_forward_041.inp', ierr)
|
||||
call assert_ok(ierr, 'read stale ignition seed failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build stale ignition seed failed')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize stale ignition seed failed')
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'reinitialize stale ignition case failed')
|
||||
call sph_read_inp('tests/data/explosive_missing_matching_ignition_041.inp', &
|
||||
ierr)
|
||||
if (ierr == SPH_SUCCESS) call sph_build_model(ierr)
|
||||
if (ierr == SPH_SUCCESS) call fail('stale ignition record was retained')
|
||||
call sph_finalize(final_ierr)
|
||||
call assert_ok(final_ierr, 'finalize stale ignition case failed')
|
||||
end subroutine assert_reinitialize_clears_ignitions
|
||||
|
||||
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 assert_close_array(actual, expected, message)
|
||||
real(rk), intent(in) :: actual(4)
|
||||
real(rk), intent(in) :: expected(4)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (maxval(abs(actual - expected)) > 1.0e-12_rk) call fail(message)
|
||||
end subroutine assert_close_array
|
||||
|
||||
subroutine assert_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual
|
||||
real(rk), intent(in) :: expected
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
if (abs(actual - expected) > 1.0e-12_rk) call fail(message)
|
||||
end subroutine assert_close
|
||||
|
||||
subroutine fail(message)
|
||||
character(len=*), intent(in) :: message
|
||||
|
||||
write(*, '(A)') trim(message)
|
||||
stop 1
|
||||
end subroutine fail
|
||||
|
||||
end program test_input_explosive_multi_ignition
|
||||
Reference in New Issue
Block a user