Add 0.7.1 blast load diagnostics
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
program test_blast_load_superposition
|
||||
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_blast, only: blast_candidate_pair_count
|
||||
use sph_blast_load, only: blast_solid_external_force, &
|
||||
blast_shell_external_force, blast_load_target_count, &
|
||||
blast_load_pair_count, blast_load_total_force, blast_solid_total_force, &
|
||||
blast_shell_total_force, blast_load_impulse, blast_load_work, &
|
||||
blast_load_energy_input, blast_load_max_particle_force, &
|
||||
blast_load_zero_weight_count, blast_load_nonfinite_count
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
real(rk) :: cache_force(3)
|
||||
real(rk) :: region_force(3)
|
||||
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed')
|
||||
call sph_read_inp('tests/data/blast_solid_superposition_071.inp', ierr)
|
||||
call assert_ok(ierr, 'read superposition input failed')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build superposition input failed')
|
||||
|
||||
if (blast_load_target_count(1) /= 2) call fail('primary target count mismatch')
|
||||
if (blast_load_target_count(2) /= 2) call fail('secondary target count mismatch')
|
||||
if (blast_load_pair_count(1) /= blast_candidate_pair_count(1)) then
|
||||
call fail('primary pair count mismatch')
|
||||
end if
|
||||
if (blast_load_pair_count(2) /= blast_candidate_pair_count(2)) then
|
||||
call fail('secondary pair count mismatch')
|
||||
end if
|
||||
call assert_vector_close(blast_solid_total_force(:,2), &
|
||||
0.5_rk * blast_solid_total_force(:,1), 'secondary force scale mismatch')
|
||||
cache_force = sph_sum_force(blast_solid_external_force)
|
||||
region_force = blast_solid_total_force(:,1) + blast_solid_total_force(:,2)
|
||||
call assert_vector_close(cache_force, region_force, &
|
||||
'superposed Solid cache force mismatch')
|
||||
call assert_vector_close(blast_load_total_force(:,1), &
|
||||
blast_solid_total_force(:,1), 'primary total force mismatch')
|
||||
call assert_vector_close(blast_load_total_force(:,2), &
|
||||
blast_solid_total_force(:,2), 'secondary total force mismatch')
|
||||
if (maxval(abs(blast_shell_external_force)) > 0.0_rk) then
|
||||
call fail('superposition polluted Shell force cache')
|
||||
end if
|
||||
if (maxval(abs(blast_shell_total_force)) > 0.0_rk) then
|
||||
call fail('superposition polluted Shell force summary')
|
||||
end if
|
||||
if (blast_load_zero_weight_count(1) /= 0 .or. &
|
||||
blast_load_zero_weight_count(2) /= 0) then
|
||||
call fail('superposition zero-weight diagnostic mismatch')
|
||||
end if
|
||||
if (blast_load_nonfinite_count(1) /= 0 .or. &
|
||||
blast_load_nonfinite_count(2) /= 0) then
|
||||
call fail('superposition nonfinite diagnostic mismatch')
|
||||
end if
|
||||
if (blast_load_max_particle_force(1) <= 0.0_rk .or. &
|
||||
blast_load_max_particle_force(2) <= 0.0_rk) then
|
||||
call fail('superposition max force missing')
|
||||
end if
|
||||
if (maxval(abs(blast_load_impulse(:,1))) <= 0.0_rk .or. &
|
||||
maxval(abs(blast_load_impulse(:,2))) <= 0.0_rk) then
|
||||
call fail('superposition impulse missing')
|
||||
end if
|
||||
if (blast_load_work(1) /= blast_load_work(1) .or. &
|
||||
blast_load_work(2) /= blast_load_work(2)) then
|
||||
call fail('superposition work not finite')
|
||||
end if
|
||||
if (blast_load_energy_input(1) /= blast_load_energy_input(1) .or. &
|
||||
blast_load_energy_input(2) /= blast_load_energy_input(2)) then
|
||||
call fail('superposition energy not finite')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
|
||||
contains
|
||||
|
||||
function sph_sum_force(values) result(total)
|
||||
real(rk), intent(in) :: values(:,:)
|
||||
real(rk) :: total(3)
|
||||
integer :: i
|
||||
|
||||
total = 0.0_rk
|
||||
do i = 1, size(values, 2)
|
||||
total = total + values(:,i)
|
||||
end do
|
||||
end function sph_sum_force
|
||||
|
||||
subroutine assert_vector_close(actual, expected, message)
|
||||
real(rk), intent(in) :: actual(3)
|
||||
real(rk), intent(in) :: expected(3)
|
||||
character(len=*), intent(in) :: message
|
||||
integer :: i
|
||||
|
||||
do i = 1, 3
|
||||
if (abs(actual(i) - expected(i)) > &
|
||||
max(1.0e-8_rk, abs(expected(i)) * 1.0e-10_rk)) then
|
||||
call fail(message)
|
||||
end if
|
||||
end do
|
||||
end subroutine assert_vector_close
|
||||
|
||||
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_load_superposition
|
||||
Reference in New Issue
Block a user