program test_blast_load_accumulator 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_load, only: blast_solid_external_force, & blast_shell_external_force, blast_shell_external_moment, & blast_load_target_count, blast_load_pair_count, & blast_load_total_force, blast_solid_total_force, & blast_shell_total_force, blast_load_max_particle_force, & blast_load_nonfinite_count implicit none integer :: ierr call check_solid_load_cache() call check_shell_load_cache() call check_no_source_cache() contains subroutine check_solid_load_cache() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for Solid Blast load') call sph_read_inp('tests/data/blast_water_gas_explosive_solid_070.inp', ierr) call assert_ok(ierr, 'read failed for Solid Blast load') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for Solid Blast load') call assert_allocated() if (blast_load_target_count(1) /= 2) call fail('Solid Blast target count mismatch') if (blast_load_pair_count(1) /= 2) call fail('Solid Blast pair count mismatch') if (blast_load_nonfinite_count(1) /= 0) call fail('Solid Blast nonfinite load') if (blast_load_max_particle_force(1) <= 0.0_rk) call fail('Solid Blast max force missing') if (maxval(abs(blast_solid_external_force(:,5:6))) <= 0.0_rk) then call fail('Solid Blast force cache missing') end if if (maxval(abs(blast_solid_external_force(:,1:4))) > 0.0_rk) then call fail('Solid Blast force polluted non-Solid particles') end if if (maxval(abs(blast_shell_external_force)) > 0.0_rk) then call fail('Solid Blast polluted Shell force cache') end if if (blast_solid_total_force(1,1) <= 0.0_rk) call fail('Solid total force missing') if (maxval(abs(blast_shell_total_force(:,1))) > 0.0_rk) then call fail('Solid Blast shell total should be zero') end if call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for Solid Blast load') end subroutine check_solid_load_cache subroutine check_shell_load_cache() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for Shell Blast load') call sph_read_inp('tests/data/blast_water_gas_explosive_shell_070.inp', ierr) call assert_ok(ierr, 'read failed for Shell Blast load') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for Shell Blast load') call assert_allocated() if (blast_load_target_count(1) /= 2) call fail('Shell Blast target count mismatch') if (blast_load_pair_count(1) /= 2) call fail('Shell Blast pair count mismatch') if (maxval(abs(blast_shell_external_force(:,5:6))) <= 0.0_rk) then call fail('Shell Blast force cache missing') end if if (maxval(abs(blast_solid_external_force)) > 0.0_rk) then call fail('Shell Blast polluted Solid force cache') end if if (maxval(abs(blast_shell_external_moment)) > 0.0_rk) then call fail('Shell Blast moment placeholder should remain zero') end if if (blast_shell_total_force(1,1) <= 0.0_rk) call fail('Shell total force missing') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for Shell Blast load') end subroutine check_shell_load_cache subroutine check_no_source_cache() call sph_initialize(ierr) call assert_ok(ierr, 'initialize failed for no-source Blast load') call sph_read_inp('tests/data/blast_solid_only_load_070.inp', ierr) call assert_ok(ierr, 'read failed for no-source Blast load') call sph_build_model(ierr) call assert_ok(ierr, 'build failed for no-source Blast load') call assert_allocated() if (blast_load_target_count(1) /= 0) call fail('no-source target load mismatch') if (blast_load_pair_count(1) /= 0) call fail('no-source pair load mismatch') if (maxval(abs(blast_load_total_force(:,1))) > 0.0_rk) then call fail('no-source total force should be zero') end if if (blast_load_max_particle_force(1) > 0.0_rk) call fail('no-source max force') call sph_finalize(ierr) call assert_ok(ierr, 'finalize failed for no-source Blast load') end subroutine check_no_source_cache subroutine assert_allocated() if (.not. allocated(blast_solid_external_force)) call fail('Solid load cache missing') if (.not. allocated(blast_shell_external_force)) call fail('Shell load cache missing') if (.not. allocated(blast_shell_external_moment)) call fail('Shell moment cache missing') end subroutine assert_allocated 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_accumulator