Files
SPHLite/tests/module/test_blast_noop_regression.f90
T
2026-07-03 23:25:36 +08:00

115 lines
4.8 KiB
Fortran

program test_blast_noop_regression
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_advance_explicit
use sph_database, only: particle_status, v, SPH_STATUS_FAILED
use sph_blast_load, only: blast_solid_external_force, &
blast_shell_external_force, blast_load_target_count, &
blast_load_total_force, sph_blast_load_compute_at, &
sph_blast_load_set_enabled
implicit none
integer :: ierr
call check_disabled_path()
call check_time_window_clear()
call check_failed_solid_target()
call check_failed_shell_target()
contains
subroutine check_disabled_path()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for disabled Blast load')
call sph_read_inp('tests/data/blast_water_gas_explosive_solid_070.inp', ierr)
call assert_ok(ierr, 'read failed for disabled Blast load')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for disabled Blast load')
call sph_blast_load_set_enabled(.false.)
call sph_advance_explicit(1.0e-8_rk, ierr)
call assert_ok(ierr, 'advance failed for disabled Blast load')
if (blast_load_target_count(1) /= 0) call fail('disabled Blast load applied')
if (maxval(abs(blast_load_total_force(:,1))) > 0.0_rk) then
call fail('disabled Blast load force not cleared')
end if
if (abs(v(1,5)) > 1.0e-18_rk) call fail('disabled Blast moved Solid target')
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for disabled Blast load')
end subroutine check_disabled_path
subroutine check_time_window_clear()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for Blast time window')
call sph_read_inp('tests/data/blast_water_gas_explosive_solid_070.inp', ierr)
call assert_ok(ierr, 'read failed for Blast time window')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for Blast time window')
call sph_blast_load_compute_at(3.0e-7_rk, ierr)
call assert_ok(ierr, 'Blast time-window recompute failed')
if (blast_load_target_count(1) /= 0) call fail('Blast time window did not clear')
if (maxval(abs(blast_solid_external_force)) > 0.0_rk) then
call fail('Blast time-window force cache not cleared')
end if
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for Blast time window')
end subroutine check_time_window_clear
subroutine check_failed_solid_target()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for failed Solid target')
call sph_read_inp('tests/data/blast_water_gas_explosive_solid_070.inp', ierr)
call assert_ok(ierr, 'read failed for failed Solid target')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for failed Solid target')
particle_status(5) = SPH_STATUS_FAILED
call sph_blast_load_compute_at(0.0_rk, ierr)
call assert_ok(ierr, 'failed Solid target recompute failed')
if (blast_load_target_count(1) /= 1) call fail('failed Solid target not skipped')
if (maxval(abs(blast_solid_external_force(:,5))) > 0.0_rk) then
call fail('failed Solid target received load')
end if
if (blast_solid_external_force(1,6) <= 0.0_rk) then
call fail('active Solid target lost load')
end if
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for failed Solid target')
end subroutine check_failed_solid_target
subroutine check_failed_shell_target()
call sph_initialize(ierr)
call assert_ok(ierr, 'initialize failed for failed Shell target')
call sph_read_inp('tests/data/blast_water_gas_explosive_shell_070.inp', ierr)
call assert_ok(ierr, 'read failed for failed Shell target')
call sph_build_model(ierr)
call assert_ok(ierr, 'build failed for failed Shell target')
particle_status(5) = SPH_STATUS_FAILED
call sph_blast_load_compute_at(0.0_rk, ierr)
call assert_ok(ierr, 'failed Shell target recompute failed')
if (blast_load_target_count(1) /= 1) call fail('failed Shell target not skipped')
if (maxval(abs(blast_shell_external_force(:,5))) > 0.0_rk) then
call fail('failed Shell target received load')
end if
if (blast_shell_external_force(1,6) <= 0.0_rk) then
call fail('active Shell target lost load')
end if
call sph_finalize(ierr)
call assert_ok(ierr, 'finalize failed for failed Shell target')
end subroutine check_failed_shell_target
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_blast_noop_regression