65 lines
2.3 KiB
Fortran
65 lines
2.3 KiB
Fortran
program test_explosive_detonation_time
|
|
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, sph_get_input_warning_count
|
|
use sph_explosive_state, only: explosive_detonation_time, &
|
|
explosive_ignition_status
|
|
use sph_explosive, only: sph_explosive_get_detonation_time_range
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
integer :: warnings
|
|
real(rk) :: expected
|
|
real(rk) :: time_min
|
|
real(rk) :: time_max
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed')
|
|
call sph_read_inp('tests/data/explosive_minimal_040.inp', ierr)
|
|
call assert_ok(ierr, 'read explosive input failed')
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build explosive model failed')
|
|
call sph_get_input_warning_count(warnings, ierr)
|
|
call assert_ok(ierr, 'warning count failed')
|
|
if (warnings /= 1) call fail('unexpected explosive warning count')
|
|
if (.not. allocated(explosive_detonation_time)) call fail('detonation time not allocated')
|
|
if (explosive_ignition_status(1) /= 1) call fail('ignition status not set')
|
|
expected = 0.1_rk / 6900.0_rk
|
|
if (abs(explosive_detonation_time(1)) > 1.0e-15_rk) then
|
|
call fail('origin detonation time mismatch')
|
|
end if
|
|
if (abs(explosive_detonation_time(2) - expected) > 1.0e-12_rk) then
|
|
call fail('x detonation time mismatch')
|
|
end if
|
|
if (abs(explosive_detonation_time(3) - expected) > 1.0e-12_rk) then
|
|
call fail('y detonation time mismatch')
|
|
end if
|
|
if (abs(explosive_detonation_time(4) - expected) > 1.0e-12_rk) then
|
|
call fail('z detonation time mismatch')
|
|
end if
|
|
call sph_explosive_get_detonation_time_range(time_min, time_max, ierr)
|
|
call assert_ok(ierr, 'detonation time range failed')
|
|
if (abs(time_min) > 1.0e-15_rk) call fail('detonation min mismatch')
|
|
if (abs(time_max - expected) > 1.0e-12_rk) call fail('detonation max mismatch')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed')
|
|
|
|
contains
|
|
|
|
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_explosive_detonation_time
|