Add 0.7.1 blast snapshot diagnostics
This commit is contained in:
@@ -216,6 +216,18 @@ set_target_properties(test_blast_target_filter PROPERTIES Fortran_MODULE_DIRECTO
|
||||
add_test(NAME blast_target_filter COMMAND test_blast_target_filter)
|
||||
set_tests_properties(blast_target_filter PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_executable(test_blast_multiregion_snapshot tests/module/test_blast_multiregion_snapshot.f90)
|
||||
target_link_libraries(test_blast_multiregion_snapshot PRIVATE sphlite_core)
|
||||
set_target_properties(test_blast_multiregion_snapshot PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}")
|
||||
add_test(NAME blast_multiregion_snapshot COMMAND test_blast_multiregion_snapshot)
|
||||
set_tests_properties(blast_multiregion_snapshot PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_executable(test_blast_multiregion_target_filter tests/module/test_blast_multiregion_target_filter.f90)
|
||||
target_link_libraries(test_blast_multiregion_target_filter PRIVATE sphlite_core)
|
||||
set_target_properties(test_blast_multiregion_target_filter PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}")
|
||||
add_test(NAME blast_multiregion_target_filter COMMAND test_blast_multiregion_target_filter)
|
||||
set_tests_properties(blast_multiregion_target_filter PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_executable(test_blast_load_accumulator tests/module/test_blast_load_accumulator.f90)
|
||||
target_link_libraries(test_blast_load_accumulator PRIVATE sphlite_core)
|
||||
set_target_properties(test_blast_load_accumulator PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}")
|
||||
|
||||
@@ -233,8 +233,11 @@ contains
|
||||
subroutine sph_blast_accumulate_region(region)
|
||||
integer, intent(in) :: region
|
||||
integer :: i
|
||||
logical :: active_in_region
|
||||
|
||||
do i = 1, npart
|
||||
active_in_region = sph_blast_is_active(i) .and. &
|
||||
sph_blast_in_region(region, i)
|
||||
if (sph_blast_phase_matches(blast_source_phase(region), &
|
||||
particle_phase(i))) then
|
||||
if (sph_blast_source_accepts(region, i)) then
|
||||
@@ -243,6 +246,9 @@ contains
|
||||
blast_skipped_source_count(region) = &
|
||||
blast_skipped_source_count(region) + 1
|
||||
end if
|
||||
else if (active_in_region) then
|
||||
blast_skipped_source_count(region) = &
|
||||
blast_skipped_source_count(region) + 1
|
||||
end if
|
||||
if (sph_blast_phase_matches(blast_target_phase(region), &
|
||||
particle_phase(i))) then
|
||||
@@ -252,6 +258,10 @@ contains
|
||||
blast_skipped_target_count(region) = &
|
||||
blast_skipped_target_count(region) + 1
|
||||
end if
|
||||
else if (active_in_region .and. &
|
||||
sph_blast_particle_in_target_set(region, i)) then
|
||||
blast_skipped_target_count(region) = &
|
||||
blast_skipped_target_count(region) + 1
|
||||
end if
|
||||
call sph_blast_accumulate_environment(region, i)
|
||||
end do
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
program test_blast_multiregion_snapshot
|
||||
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_blast, only: blast_source_count, blast_target_count, &
|
||||
blast_candidate_pair_count, blast_skipped_source_count, &
|
||||
blast_skipped_target_count, blast_gas_count, blast_water_count, &
|
||||
blast_explosive_count, blast_source_mass, blast_source_energy, &
|
||||
blast_source_pressure_mean, blast_gas_volume, &
|
||||
blast_explosive_progress_mean, blast_water_pressure_min, &
|
||||
blast_water_pressure_max
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
real(rk) :: initial_progress
|
||||
|
||||
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')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build multiregion Blast input failed')
|
||||
|
||||
call assert_region_snapshot(1, 1, 2, 2)
|
||||
call assert_region_snapshot(2, 1, 2, 2)
|
||||
if (blast_source_count(3) /= 0 .or. blast_target_count(3) /= 0 .or. &
|
||||
blast_candidate_pair_count(3) /= 0) then
|
||||
call fail('disabled region snapshot was not empty')
|
||||
end if
|
||||
if (blast_skipped_source_count(1) <= 0) then
|
||||
call fail('source phase mismatch skip count missing')
|
||||
end if
|
||||
if (blast_skipped_target_count(1) /= 0) then
|
||||
call fail('Solid target region reported unexpected target skip')
|
||||
end if
|
||||
if (blast_skipped_target_count(2) /= 0) then
|
||||
call fail('Shell target region reported unexpected target skip')
|
||||
end if
|
||||
initial_progress = blast_explosive_progress_mean(1)
|
||||
call sph_advance_explicit(1.0e-7_rk, ierr)
|
||||
call assert_ok(ierr, 'advance multiregion Blast input failed')
|
||||
if (blast_explosive_progress_mean(1) + 1.0e-12_rk < initial_progress) then
|
||||
call fail('Blast multiregion progress regressed')
|
||||
end if
|
||||
if (blast_explosive_progress_mean(1) < 0.99_rk .or. &
|
||||
blast_explosive_progress_mean(2) < 0.99_rk) then
|
||||
call fail('Blast multiregion snapshot was not refreshed after advance')
|
||||
end if
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed')
|
||||
|
||||
contains
|
||||
|
||||
subroutine assert_region_snapshot(region, expected_sources, expected_targets, &
|
||||
expected_pairs)
|
||||
integer, intent(in) :: region
|
||||
integer, intent(in) :: expected_sources
|
||||
integer, intent(in) :: expected_targets
|
||||
integer, intent(in) :: expected_pairs
|
||||
|
||||
if (blast_source_count(region) /= expected_sources) then
|
||||
call fail('Blast multiregion source count mismatch')
|
||||
end if
|
||||
if (blast_target_count(region) /= expected_targets) then
|
||||
call fail('Blast multiregion target count mismatch')
|
||||
end if
|
||||
if (blast_candidate_pair_count(region) /= expected_pairs) then
|
||||
call fail('Blast multiregion pair count mismatch')
|
||||
end if
|
||||
if (blast_water_count(region) /= 2) then
|
||||
call fail('Blast multiregion Water count mismatch')
|
||||
end if
|
||||
if (blast_gas_count(region) /= 1) then
|
||||
call fail('Blast multiregion Gas count mismatch')
|
||||
end if
|
||||
if (blast_explosive_count(region) /= 1) then
|
||||
call fail('Blast multiregion Explosive count mismatch')
|
||||
end if
|
||||
call assert_close(blast_source_mass(region), 0.02_rk, &
|
||||
'Blast multiregion source mass mismatch')
|
||||
if (blast_source_energy(region) <= 0.0_rk) then
|
||||
call fail('Blast multiregion source energy missing')
|
||||
end if
|
||||
if (blast_source_pressure_mean(region) <= 0.0_rk) then
|
||||
call fail('Blast multiregion source pressure missing')
|
||||
end if
|
||||
call assert_close(blast_gas_volume(region), 1.25e-5_rk, &
|
||||
'Blast multiregion Gas volume mismatch')
|
||||
call assert_close(blast_water_pressure_min(region), 0.0_rk, &
|
||||
'Blast multiregion Water pressure min mismatch')
|
||||
call assert_close(blast_water_pressure_max(region), 0.0_rk, &
|
||||
'Blast multiregion Water pressure max mismatch')
|
||||
end subroutine assert_region_snapshot
|
||||
|
||||
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_blast_multiregion_snapshot
|
||||
@@ -0,0 +1,75 @@
|
||||
program test_blast_multiregion_target_filter
|
||||
use sph_error, only: SPH_SUCCESS
|
||||
use sph_api, only: sph_initialize, sph_finalize, sph_read_inp, sph_build_model
|
||||
use sph_blast, only: sph_blast_refresh_snapshot, blast_target_set_name, &
|
||||
blast_source_count, blast_target_count, blast_candidate_pair_count, &
|
||||
blast_skipped_source_count, blast_skipped_target_count
|
||||
use sph_database, only: particle_status, SPH_STATUS_FAILED
|
||||
implicit none
|
||||
|
||||
integer :: ierr
|
||||
|
||||
call check_phase_and_set_filters()
|
||||
call check_failed_solid_and_shell_targets()
|
||||
|
||||
contains
|
||||
|
||||
subroutine check_phase_and_set_filters()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for multiregion target filters')
|
||||
call sph_read_inp('tests/data/blast_multiregion_071.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for multiregion target filters')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for multiregion target filters')
|
||||
|
||||
blast_target_set_name(2) = 'STRUCTURE_TARGET'
|
||||
call sph_blast_refresh_snapshot(ierr)
|
||||
call assert_ok(ierr, 'refresh failed for multiregion target filters')
|
||||
if (blast_source_count(2) /= 1) call fail('Shell region source changed')
|
||||
if (blast_target_count(2) /= 2) call fail('Shell phase target filter mismatch')
|
||||
if (blast_skipped_target_count(2) < 2) then
|
||||
call fail('Shell phase mismatch target skip missing')
|
||||
end if
|
||||
if (blast_candidate_pair_count(2) /= 2) call fail('Shell phase pair mismatch')
|
||||
if (blast_skipped_source_count(2) <= 0) call fail('source skip diagnostic missing')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for multiregion target filters')
|
||||
end subroutine check_phase_and_set_filters
|
||||
|
||||
subroutine check_failed_solid_and_shell_targets()
|
||||
call sph_initialize(ierr)
|
||||
call assert_ok(ierr, 'initialize failed for failed target filters')
|
||||
call sph_read_inp('tests/data/blast_multiregion_071.inp', ierr)
|
||||
call assert_ok(ierr, 'read failed for failed target filters')
|
||||
call sph_build_model(ierr)
|
||||
call assert_ok(ierr, 'build failed for failed target filters')
|
||||
|
||||
particle_status(5) = SPH_STATUS_FAILED
|
||||
particle_status(7) = SPH_STATUS_FAILED
|
||||
call sph_blast_refresh_snapshot(ierr)
|
||||
call assert_ok(ierr, 'refresh failed for failed target filters')
|
||||
if (blast_target_count(1) /= 1) call fail('failed Solid target was not skipped')
|
||||
if (blast_target_count(2) /= 1) call fail('failed Shell target was not skipped')
|
||||
if (blast_skipped_target_count(1) < 1) call fail('failed Solid skip missing')
|
||||
if (blast_skipped_target_count(2) < 1) call fail('failed Shell skip missing')
|
||||
if (blast_candidate_pair_count(1) /= 1) call fail('failed Solid pair mismatch')
|
||||
if (blast_candidate_pair_count(2) /= 1) call fail('failed Shell pair mismatch')
|
||||
call sph_finalize(ierr)
|
||||
call assert_ok(ierr, 'finalize failed for failed target filters')
|
||||
end subroutine check_failed_solid_and_shell_targets
|
||||
|
||||
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_multiregion_target_filter
|
||||
@@ -59,31 +59,31 @@
|
||||
|
||||
## 阶段 C:源项快照、目标筛选和多区域诊断
|
||||
|
||||
- [ ] 复核现有 blast source snapshot 数据结构。
|
||||
- [ ] 确认 source snapshot 按 region 独立刷新。
|
||||
- [ ] 统计每个 region 内 active Water 源粒子数量。
|
||||
- [ ] 统计每个 region 内 active Gas 源粒子数量。
|
||||
- [ ] 统计每个 region 内 active Explosive 源粒子数量。
|
||||
- [ ] 统计每个 region 内源粒子总质量。
|
||||
- [ ] 统计每个 region 内源粒子总能量。
|
||||
- [ ] 统计每个 region 内 Water 压力范围。
|
||||
- [ ] 统计每个 region 内 Gas 总体积。
|
||||
- [ ] 统计每个 region 内 Explosive 平均反应进度。
|
||||
- [ ] 对 region 外源粒子执行跳过计数。
|
||||
- [ ] 对非 active 源粒子执行跳过计数。
|
||||
- [ ] 对不匹配 source phase 的粒子执行跳过计数。
|
||||
- [ ] 确认无源粒子时返回安全默认诊断。
|
||||
- [ ] 复核现有 blast target 筛选规则。
|
||||
- [ ] 确认 target 筛选按 region 独立执行。
|
||||
- [ ] 按 target set 筛选结构粒子。
|
||||
- [ ] 按 target phase 筛选 Solid 和 Shell 粒子。
|
||||
- [ ] 跳过 failed Solid 目标并记录计数。
|
||||
- [ ] 跳过 failed Shell 目标并记录计数。
|
||||
- [ ] 确认无目标粒子时返回安全默认诊断。
|
||||
- [ ] 新增 `blast_multiregion_snapshot` 测试。
|
||||
- [ ] 新增 `blast_multiregion_target_filter` 测试。
|
||||
- [ ] 将源项和目标筛选测试接入 CTest。
|
||||
- [ ] 准备阶段 C 本地提交说明。
|
||||
- [x] 复核现有 blast source snapshot 数据结构。
|
||||
- [x] 确认 source snapshot 按 region 独立刷新。
|
||||
- [x] 统计每个 region 内 active Water 源粒子数量。
|
||||
- [x] 统计每个 region 内 active Gas 源粒子数量。
|
||||
- [x] 统计每个 region 内 active Explosive 源粒子数量。
|
||||
- [x] 统计每个 region 内源粒子总质量。
|
||||
- [x] 统计每个 region 内源粒子总能量。
|
||||
- [x] 统计每个 region 内 Water 压力范围。
|
||||
- [x] 统计每个 region 内 Gas 总体积。
|
||||
- [x] 统计每个 region 内 Explosive 平均反应进度。
|
||||
- [x] 对 region 外源粒子执行跳过计数。
|
||||
- [x] 对非 active 源粒子执行跳过计数。
|
||||
- [x] 对不匹配 source phase 的粒子执行跳过计数。
|
||||
- [x] 确认无源粒子时返回安全默认诊断。
|
||||
- [x] 复核现有 blast target 筛选规则。
|
||||
- [x] 确认 target 筛选按 region 独立执行。
|
||||
- [x] 按 target set 筛选结构粒子。
|
||||
- [x] 按 target phase 筛选 Solid 和 Shell 粒子。
|
||||
- [x] 跳过 failed Solid 目标并记录计数。
|
||||
- [x] 跳过 failed Shell 目标并记录计数。
|
||||
- [x] 确认无目标粒子时返回安全默认诊断。
|
||||
- [x] 新增 `blast_multiregion_snapshot` 测试。
|
||||
- [x] 新增 `blast_multiregion_target_filter` 测试。
|
||||
- [x] 将源项和目标筛选测试接入 CTest。
|
||||
- [x] 准备阶段 C 本地提交说明。
|
||||
|
||||
## 阶段 D:结构载荷缓存、叠加和守恒诊断
|
||||
|
||||
|
||||
Reference in New Issue
Block a user