96 lines
3.6 KiB
Fortran
96 lines
3.6 KiB
Fortran
program test_input_blast_multiregion
|
|
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_blast, only: blast_region_count, blast_region_name, &
|
|
blast_target_set_name, blast_source_phase, blast_target_phase, &
|
|
blast_region_enabled, blast_radius, blast_load_scale, blast_time_window, &
|
|
SPH_BLAST_PHASE_GAS, SPH_BLAST_PHASE_SOLID, SPH_BLAST_PHASE_SHELL, &
|
|
SPH_BLAST_PHASE_STRUCTURE
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
integer :: warnings
|
|
|
|
call sph_initialize(ierr)
|
|
call assert_ok(ierr, 'initialize failed')
|
|
call sph_read_inp('tests/data/blast_multiregion_071.inp', ierr)
|
|
call assert_ok(ierr, 'read multiregion Blast input failed')
|
|
if (blast_region_count /= 3) call fail('Blast multiregion count mismatch')
|
|
|
|
call assert_region(1, 'SOLID_REGION', 'SOLID_TARGET', SPH_BLAST_PHASE_SOLID, &
|
|
.true., 1.0_rk, 2.0e-7_rk)
|
|
call assert_region(2, 'SHELL_REGION', 'SHELL_TARGET', SPH_BLAST_PHASE_SHELL, &
|
|
.true., 0.50_rk, 1.0e-7_rk)
|
|
call assert_region(3, 'DISABLED_REGION', 'STRUCTURE_TARGET', &
|
|
SPH_BLAST_PHASE_STRUCTURE, .false., 1.0_rk, 2.0e-7_rk)
|
|
|
|
call sph_build_model(ierr)
|
|
call assert_ok(ierr, 'build multiregion Blast input failed')
|
|
call sph_get_input_warning_count(warnings, ierr)
|
|
call assert_ok(ierr, 'Blast warning count failed')
|
|
if (warnings <= 0) call fail('disabled Blast region warning missing')
|
|
call sph_finalize(ierr)
|
|
call assert_ok(ierr, 'finalize failed')
|
|
|
|
contains
|
|
|
|
subroutine assert_region(region, expected_name, expected_set, &
|
|
expected_target_phase, expected_enabled, expected_scale, &
|
|
expected_time_window)
|
|
integer, intent(in) :: region
|
|
character(len=*), intent(in) :: expected_name
|
|
character(len=*), intent(in) :: expected_set
|
|
integer, intent(in) :: expected_target_phase
|
|
logical, intent(in) :: expected_enabled
|
|
real(rk), intent(in) :: expected_scale
|
|
real(rk), intent(in) :: expected_time_window
|
|
|
|
if (trim(blast_region_name(region)) /= trim(expected_name)) then
|
|
call fail('Blast region name mismatch')
|
|
end if
|
|
if (trim(blast_target_set_name(region)) /= trim(expected_set)) then
|
|
call fail('Blast region target set mismatch')
|
|
end if
|
|
if (blast_source_phase(region) /= SPH_BLAST_PHASE_GAS) then
|
|
call fail('Blast region source phase mismatch')
|
|
end if
|
|
if (blast_target_phase(region) /= expected_target_phase) then
|
|
call fail('Blast region target phase mismatch')
|
|
end if
|
|
if (blast_region_enabled(region) .neqv. expected_enabled) then
|
|
call fail('Blast region enabled flag mismatch')
|
|
end if
|
|
call assert_close(blast_radius(region), 0.50_rk, &
|
|
'Blast region radius mismatch')
|
|
call assert_close(blast_load_scale(region), expected_scale, &
|
|
'Blast region scale mismatch')
|
|
call assert_close(blast_time_window(region), expected_time_window, &
|
|
'Blast region time window mismatch')
|
|
end subroutine assert_region
|
|
|
|
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(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_blast_multiregion
|