From c5cfbf075297fd3dd0eb763f2cf88f32fbde2396 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 3 Jul 2026 23:52:46 +0800 Subject: [PATCH] Complete blast smoke release gate --- CMakeLists.txt | 6 ++ README.md | 3 +- docs/06_test_and_verification_plan.md | 33 ++++++ docs/09_release_history.md | 46 ++++++++ docs/11_benchmark_matrix.md | 29 ++++++ tests/module/test_blast_smoke.f90 | 145 ++++++++++++++++++++++++++ todo.md | 68 ++++++------ 7 files changed, 295 insertions(+), 35 deletions(-) create mode 100644 tests/module/test_blast_smoke.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index b2fb72d..2d3038b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,12 @@ set_target_properties(test_blast_restart_boundary PROPERTIES Fortran_MODULE_DIRE add_test(NAME blast_restart_boundary COMMAND test_blast_restart_boundary) set_tests_properties(blast_restart_boundary PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_blast_smoke tests/module/test_blast_smoke.f90) +target_link_libraries(test_blast_smoke PRIVATE sphlite_core) +set_target_properties(test_blast_smoke PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME blast_smoke COMMAND test_blast_smoke) +set_tests_properties(blast_smoke PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_executable(test_input_solid_material tests/module/test_input_solid_material.f90) target_link_libraries(test_input_solid_material PRIVATE sphlite_core) set_target_properties(test_input_solid_material PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") diff --git a/README.md b/README.md index 5a6ae09..ce6efeb 100644 --- a/README.md +++ b/README.md @@ -94,5 +94,6 @@ SPHLite 的编译和测试要求应与 FEMLite 保持一致风格: - 0.5.1 本地 gate 已通过:完整 CTest 99/99,0.5.0 Solid 回归 gate 17/17,0.5.1 Solid 专项 gate 16/16,`source_size`/`solid_source_size`/`solid_051_source_size` 3/3,`git diff --check` 通过。 - 0.6.0 本地 gate 已通过:完整 CTest 103/103,Shell 输入/状态基线专项 gate 4/4,`source_size` 1/1,`git diff --check` 通过。 - 0.6.1 本地 gate 已通过:完整 CTest 113/113,Shell 运动学专项 gate 13/13,`source_size`/`shell_061_source_size` 2/2,`git diff --check` 通过。 -- 0.7.0 计划新增小型 Water/Gas/Explosive/Solid/Shell 局部爆炸 smoke、结构外载荷缓存、载荷诊断和默认回归 gate;该版本只用于链路验收,不作为工程精度 benchmark。 +- 0.7.0 新增小型 Water/Gas/Explosive/Solid/Shell 局部爆炸 smoke、结构外载荷缓存、载荷诊断和默认回归 gate;该版本只用于链路验收,不作为工程精度 benchmark。 - 0.7.0 局部爆炸诊断先提供 Fortran API 和 CSV 调试输出,不新增公开 C ABI/C++/Python 稳定接口,也不写入正式 `STATE_0_7` restart。 +- 0.7.0 本地 gate 已通过:完整 CTest 127/127,局部爆炸专项 gate 14/14,source size 相关 gate 7/7,`git diff --check` 通过。 diff --git a/docs/06_test_and_verification_plan.md b/docs/06_test_and_verification_plan.md index 40bca76..7f5922a 100644 --- a/docs/06_test_and_verification_plan.md +++ b/docs/06_test_and_verification_plan.md @@ -329,6 +329,39 @@ git diff --check 0.6.1 不验收完整 `Shell` 动力学闭环,不验收 Shell 材料点更新、内力、内力矩、稳定时间步、显式推进生产路径、restart、公开 C ABI/C++/Python/CLI 诊断字段、真实水-气-结构工程爆炸响应、真实 FEM-SPH 联合运行或工程级船舱破坏 benchmark。 +## 7.8 0.7.0 Release Gate + +0.7.0 在 0.6.1 Shell 运动学基线之上新增水-气-结构局部爆炸 smoke 起点。该 gate 只验收小型 Water/Gas/Explosive/Solid/Shell 链路、局部爆炸输入控制、源/目标筛选、结构外载荷缓存、显式推进接入、诊断输出和 restart 边界,不验收真实工程级水下接触爆炸响应。 + +0.7.0 局部爆炸专项 gate 包含: +- `input_blast_region` +- `input_blast_errors` +- `blast_source_snapshot` +- `blast_target_filter` +- `blast_load_accumulator` +- `blast_load_conservation` +- `blast_solver_order` +- `blast_solid_response` +- `blast_shell_response` +- `blast_noop_regression` +- `blast_summary` +- `blast_output` +- `blast_restart_boundary` +- `blast_smoke` + +0.7.0 本地 release gate: +```powershell +cmake --build build-codex-unix --parallel +ctest --test-dir build-codex-unix --output-on-failure +ctest --test-dir build-codex-unix -R "^(input_blast_region|input_blast_errors|blast_source_snapshot|blast_target_filter|blast_load_accumulator|blast_load_conservation|blast_solver_order|blast_solid_response|blast_shell_response|blast_noop_regression|blast_summary|blast_output|blast_restart_boundary|blast_smoke)$" --output-on-failure +ctest --test-dir build-codex-unix -R "^(source_size|explosive_source_size|explosive_041_source_size|gas_source_size_cleanup|solid_source_size|solid_051_source_size|shell_061_source_size)$" --output-on-failure +git diff --check +``` + +2026-07-03 本地结果:完整 CTest 127/127 通过,0.7.0 局部爆炸专项 gate 14/14 通过,source size 相关 gate 7/7 通过,`git diff --check` 通过。 + +0.7.0 不验收真实工程级水下接触爆炸响应,不验收真实 FEM-SPH 接触耦合或连续体耦合,不验收完整舱段破坏 benchmark,不验收复杂撕裂、穿孔、碎片云、焊缝失效库、大规模并行或 GPU 后端。0.7.0 的局部爆炸诊断先提供 Fortran API 和 CSV 调试输出,不新增公开 C ABI/C++/Python 稳定接口,也不写入正式 `STATE_0_7` restart。 + ## 8. Source Size 门禁 从第一版开始设置 source size 门禁。建议沿用 FEMLite 风格: diff --git a/docs/09_release_history.md b/docs/09_release_history.md index 01e28af..6018df4 100644 --- a/docs/09_release_history.md +++ b/docs/09_release_history.md @@ -484,6 +484,52 @@ cmake --build build-codex-unix - 0.6.1 已于 2026-07-03 完成本地发布记录提交,并准备标记 `v0.6.1`。 +### 0.7.0 本地验收记录 + +记录日期:2026-07-03 + +本地构建目录:`build-codex-unix` + +版本定位: + +- 0.7.0 是水-气-结构局部爆炸 smoke 起点版本。 +- 0.7.0 在 0.6.1 Shell 运动学基线之上,新增 `*SPHLITE BLAST REGION` 输入控制、源/目标筛选、局部源项快照和结构外载荷缓存。 +- 0.7.0 将局部爆炸外载荷接入显式推进中的 Solid/Shell 平动响应路径,并保留 Shell 内力和内力矩闭环的受控占位边界。 +- 0.7.0 新增 Blast summary Fortran 查询、summary CSV 调试字段、粒子 CSV 结构外载荷字段和 restart 边界测试。 +- 0.7.0 的局部爆炸诊断不进入公开 C ABI/C++/Python 稳定接口,也不写入正式 `STATE_0_7` restart。 + +验收结果: + +- `cmake --build build-codex-unix --parallel` 通过。 +- `ctest --test-dir build-codex-unix --output-on-failure` 通过:127/127。 +- 0.7.0 局部爆炸专项 gate 通过:14/14。 +- source size 相关 gate 通过:7/7。 +- `git diff --check` 通过。 +- 代码、构建脚本、测试和工具目录中未新增 FEMLite 直接依赖。 + +不交付范围: + +- 0.7.0 不交付真实工程级水下接触爆炸响应。 +- 0.7.0 不交付真实 FEM-SPH 接触耦合或连续体耦合。 +- 0.7.0 不交付完整舱段破坏 benchmark。 +- 0.7.0 不交付复杂撕裂、穿孔、碎片云、焊缝失效库、大规模并行或 GPU 后端。 +- 0.7.0 不宣称 Shell 完整动力学闭环;Shell 外载荷当前仅进入受控平动响应路径。 + +已知限制: + +- 局部爆炸载荷为 smoke 级调试投影,不是工程级近场爆炸载荷算法。 +- restart 仍保持既有 `STATE_0_5_1` 状态边界,Blast 控制和诊断在 0.7.0 不作为正式 restart state 保存。 +- C ABI、C++ wrapper、Python ctypes 和 CLI 暂不公开 Blast 调试查询函数。 + +发布建议: + +- 建议将 0.7.0 作为局部爆炸 smoke 起点版本发布。 +- 0.7.0 发布后,后续主线应优先完善真实压力载荷投影、Shell 动力学闭环、restart 状态和稳定公开接口边界。 + +发布记录: + +- 0.7.0 已于 2026-07-03 完成本地发布记录提交,并准备标记 `v0.7.0`。 + 后续每个版本应记录: - 完成能力。 diff --git a/docs/11_benchmark_matrix.md b/docs/11_benchmark_matrix.md index 0095474..a3e36f9 100644 --- a/docs/11_benchmark_matrix.md +++ b/docs/11_benchmark_matrix.md @@ -377,6 +377,35 @@ |---|---|---| | 2026-07-03 | `build-codex-unix` | 完整 CTest 113/113 通过,0.6.0 Shell 输入/状态基线 gate 4/4 通过,0.6.1 Shell 运动学 gate 13/13 通过,`source_size`/`shell_061_source_size` 2/2 通过,`git diff --check` 通过 | +## 2.13 0.7.0 Release Gate + +0.7.0 默认 gate 在 0.6.1 Shell 运动学基线之上新增水-气-结构局部爆炸 smoke 链路。该 gate 只覆盖小型 Water/Gas/Explosive/Solid/Shell 输入、载荷缓存、显式推进接入、诊断输出和 restart 边界,不验收工程级水下接触爆炸 benchmark。 + +| 测试名 | 类型 | 验收点 | +|---|---|---| +| `input_blast_region` | Fortran input | `*SPHLITE BLAST REGION` 名称、中心、半径、源/目标 phase、target set、scale、time window 和 mode 解析 | +| `input_blast_errors` | Fortran input | 非法半径、非法 scale、非法 time window、非法 phase 和缺失 target set 错误路径 | +| `blast_source_snapshot` | Fortran module | 源区 Water/Gas/Explosive 计数、质量、能量、压力和反应进度快照 | +| `blast_target_filter` | Fortran module | 目标 set、半径、phase、active/failed 状态筛选和跳过计数 | +| `blast_load_accumulator` | Fortran module | Solid/Shell 结构外载荷缓存、隔离和 no-source 默认值 | +| `blast_load_conservation` | Fortran module | 总力、Solid/Shell 分力、冲量、动量、做功和能量诊断一致性 | +| `blast_solver_order` | Fortran solver | Water/Gas 压力、Explosive 更新、Gas 源项和载荷投影调用顺序 | +| `blast_solid_response` | Fortran solver | Solid 外载荷进入显式加速度和多步速度累积 | +| `blast_shell_response` | Fortran solver | Shell 平动外载荷、moment 占位和 director 隔离 | +| `blast_noop_regression` | Fortran solver | 载荷禁用、时间窗结束清零、failed Solid/Shell 目标跳过 | +| `blast_summary` | Fortran API | Blast summary counts/values 查询和非法 region 错误路径 | +| `blast_output` | Fortran output | summary CSV blast 指标和粒子 CSV 外载荷字段 | +| `blast_restart_boundary` | Fortran restart | 0.7.0 不写 `STATE_0_7`,Blast 控制和诊断不作为正式 restart state | +| `blast_smoke` | Fortran smoke | Solid、Shell、Solid/Shell 局部爆炸单步/多步 smoke,检查方向、进度、冲量、能量和有限性 | + +0.7.0 不验收真实工程级水下接触爆炸响应、真实 FEM-SPH 接触耦合或连续体耦合、完整舱段破坏 benchmark、复杂撕裂/穿孔/碎片云、焊缝失效库、大规模并行或 GPU 后端。0.7.0 的局部爆炸诊断先提供 Fortran API 和 CSV 调试输出,不公开 C ABI/C++/Python 稳定接口。 + +本地验收记录: + +| 日期 | 构建目录 | 结果 | +|---|---|---| +| 2026-07-03 | `build-codex-unix` | 完整 CTest 127/127 通过,0.7.0 局部爆炸专项 gate 14/14 通过,source size 相关 gate 7/7 通过,`git diff --check` 通过 | + ## 3. 基础数值矩阵 | 领域 | 测试或 benchmark | 验收点 | diff --git a/tests/module/test_blast_smoke.f90 b/tests/module/test_blast_smoke.f90 new file mode 100644 index 0000000..2c0d2f6 --- /dev/null +++ b/tests/module/test_blast_smoke.f90 @@ -0,0 +1,145 @@ +program test_blast_smoke + 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: npart, x, v, a, rho, pressure, internal_energy, & + temperature, h + use sph_blast, only: blast_gas_volume, blast_explosive_progress_mean + use sph_blast_load, only: blast_solid_total_force, blast_shell_total_force, & + blast_load_impulse, blast_load_energy_input, & + blast_load_max_acceleration, blast_load_nonfinite_count + implicit none + + integer :: ierr + + call check_solid_single_step_smoke() + call check_shell_single_step_smoke() + call check_mixed_multi_step_smoke() + +contains + + subroutine check_solid_single_step_smoke() + call setup_model('tests/data/blast_water_gas_explosive_solid_070.inp') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'Solid Blast smoke step failed') + if (blast_gas_volume(1) <= 0.0_rk) call fail('Solid smoke Gas volume missing') + if (blast_explosive_progress_mean(1) <= 0.0_rk) then + call fail('Solid smoke Explosive progress missing') + end if + if (blast_solid_total_force(1,1) <= 0.0_rk) then + call fail('Solid smoke load direction mismatch') + end if + if (blast_load_impulse(1,1) <= 0.0_rk) call fail('Solid smoke impulse missing') + call assert_energy_finite() + call assert_state_finite() + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize Solid Blast smoke failed') + end subroutine check_solid_single_step_smoke + + subroutine check_shell_single_step_smoke() + call setup_model('tests/data/blast_water_gas_explosive_shell_070.inp') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'Shell Blast smoke step failed') + if (blast_shell_total_force(1,1) <= 0.0_rk) then + call fail('Shell smoke load direction mismatch') + end if + if (v(1,5) <= 0.0_rk) call fail('Shell smoke velocity missing') + if (blast_load_max_acceleration(1) <= 0.0_rk) then + call fail('Shell smoke acceleration diagnostic missing') + end if + call assert_energy_finite() + call assert_state_finite() + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize Shell Blast smoke failed') + end subroutine check_shell_single_step_smoke + + subroutine check_mixed_multi_step_smoke() + real(rk) :: progress_first + + call setup_model('tests/data/blast_water_gas_explosive_solid_shell_070.inp') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'mixed Blast first step failed') + progress_first = blast_explosive_progress_mean(1) + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'mixed Blast second step failed') + if (blast_explosive_progress_mean(1) + 1.0e-12_rk < progress_first) then + call fail('mixed smoke Explosive progress regressed') + end if + if (blast_solid_total_force(1,1) <= 0.0_rk) then + call fail('mixed smoke Solid force missing') + end if + if (blast_shell_total_force(1,1) <= 0.0_rk) then + call fail('mixed smoke Shell force missing') + end if + if (blast_load_nonfinite_count(1) /= 0) call fail('mixed smoke nonfinite load') + call assert_energy_finite() + call assert_state_finite() + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize mixed Blast smoke failed') + end subroutine check_mixed_multi_step_smoke + + subroutine setup_model(filename) + character(len=*), intent(in) :: filename + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for Blast smoke') + call sph_read_inp(filename, ierr) + call assert_ok(ierr, 'read failed for Blast smoke') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for Blast smoke') + end subroutine setup_model + + subroutine assert_state_finite() + integer :: i + + do i = 1, npart + call assert_vector_finite(x(:,i), 'Blast smoke position not finite') + call assert_vector_finite(v(:,i), 'Blast smoke velocity not finite') + call assert_vector_finite(a(:,i), 'Blast smoke acceleration not finite') + call assert_scalar_finite(rho(i), 'Blast smoke density not finite') + call assert_scalar_finite(pressure(i), 'Blast smoke pressure not finite') + call assert_scalar_finite(internal_energy(i), 'Blast smoke energy not finite') + call assert_scalar_finite(temperature(i), 'Blast smoke temperature not finite') + call assert_scalar_finite(h(i), 'Blast smoke smoothing length not finite') + end do + end subroutine assert_state_finite + + subroutine assert_energy_finite() + call assert_scalar_finite(blast_load_energy_input(1), & + 'Blast smoke load energy not finite') + end subroutine assert_energy_finite + + subroutine assert_vector_finite(values, message) + real(rk), intent(in) :: values(3) + character(len=*), intent(in) :: message + integer :: i + + do i = 1, 3 + call assert_scalar_finite(values(i), message) + end do + end subroutine assert_vector_finite + + subroutine assert_scalar_finite(value, message) + real(rk), intent(in) :: value + character(len=*), intent(in) :: message + + if (value /= value) call fail(message) + if (abs(value) > huge(value) * 0.5_rk) call fail(message) + end subroutine assert_scalar_finite + + 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_smoke diff --git a/todo.md b/todo.md index 4c02ec4..627182f 100644 --- a/todo.md +++ b/todo.md @@ -209,37 +209,37 @@ ## 阶段 G:局部爆炸 smoke、回归 gate 和文档发布准备 -- [ ] 设计 0.7.0 局部爆炸 smoke 的最小物理链路。 -- [ ] 设计 Water/Gas/Explosive/Solid smoke 验收指标。 -- [ ] 设计 Water/Gas/Explosive/Shell smoke 验收指标。 -- [ ] 设计 Water/Gas/Explosive/Solid/Shell smoke 验收指标。 -- [ ] 实现单步局部爆炸 smoke 测试。 -- [ ] 实现多步局部爆炸 smoke 测试。 -- [ ] 检查 smoke 中 Gas 体积或压力统计方向。 -- [ ] 检查 smoke 中 Explosive 反应进度单调性。 -- [ ] 检查 smoke 中 Solid/Shell 载荷方向。 -- [ ] 检查 smoke 中载荷冲量非负或受控。 -- [ ] 检查 smoke 中能量诊断有限性。 -- [ ] 检查 smoke 中所有粒子状态有限性。 -- [ ] 运行 Water 回归 gate。 -- [ ] 运行 Gas 回归 gate。 -- [ ] 运行 Explosive 回归 gate。 -- [ ] 运行 Solid 回归 gate。 -- [ ] 运行 Shell 0.6.1 回归 gate。 -- [ ] 运行 CouplingInterface 回归 gate。 -- [ ] 运行 output 回归 gate。 -- [ ] 运行 restart 回归 gate。 -- [ ] 运行完整 CTest。 -- [ ] 运行 0.7.0 局部爆炸专项 gate。 -- [ ] 运行 source size 相关 gate。 -- [ ] 运行 `git diff --check`。 -- [ ] 更新 README 中 0.7.0 当前状态和不交付范围。 -- [ ] 更新 `docs/06_test_and_verification_plan.md` 的 0.7.0 release gate。 -- [ ] 更新 `docs/09_release_history.md` 的 0.7.0 本地验收记录。 -- [ ] 更新 `docs/11_benchmark_matrix.md` 的 0.7.0 gate 矩阵。 -- [ ] 确认文档不宣称工程级水下接触爆炸响应。 -- [ ] 确认文档不宣称真实 FEM-SPH 联合运行。 -- [ ] 确认文档不宣称完整舱段破坏 benchmark。 -- [ ] 确认输出目录、CSV、VTK、restart 和临时结果未提交。 -- [ ] 确认代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖。 -- [ ] 准备 0.7.0 发布提交说明。 +- [x] 设计 0.7.0 局部爆炸 smoke 的最小物理链路。 +- [x] 设计 Water/Gas/Explosive/Solid smoke 验收指标。 +- [x] 设计 Water/Gas/Explosive/Shell smoke 验收指标。 +- [x] 设计 Water/Gas/Explosive/Solid/Shell smoke 验收指标。 +- [x] 实现单步局部爆炸 smoke 测试。 +- [x] 实现多步局部爆炸 smoke 测试。 +- [x] 检查 smoke 中 Gas 体积或压力统计方向。 +- [x] 检查 smoke 中 Explosive 反应进度单调性。 +- [x] 检查 smoke 中 Solid/Shell 载荷方向。 +- [x] 检查 smoke 中载荷冲量非负或受控。 +- [x] 检查 smoke 中能量诊断有限性。 +- [x] 检查 smoke 中所有粒子状态有限性。 +- [x] 运行 Water 回归 gate。 +- [x] 运行 Gas 回归 gate。 +- [x] 运行 Explosive 回归 gate。 +- [x] 运行 Solid 回归 gate。 +- [x] 运行 Shell 0.6.1 回归 gate。 +- [x] 运行 CouplingInterface 回归 gate。 +- [x] 运行 output 回归 gate。 +- [x] 运行 restart 回归 gate。 +- [x] 运行完整 CTest。 +- [x] 运行 0.7.0 局部爆炸专项 gate。 +- [x] 运行 source size 相关 gate。 +- [x] 运行 `git diff --check`。 +- [x] 更新 README 中 0.7.0 当前状态和不交付范围。 +- [x] 更新 `docs/06_test_and_verification_plan.md` 的 0.7.0 release gate。 +- [x] 更新 `docs/09_release_history.md` 的 0.7.0 本地验收记录。 +- [x] 更新 `docs/11_benchmark_matrix.md` 的 0.7.0 gate 矩阵。 +- [x] 确认文档不宣称工程级水下接触爆炸响应。 +- [x] 确认文档不宣称真实 FEM-SPH 联合运行。 +- [x] 确认文档不宣称完整舱段破坏 benchmark。 +- [x] 确认输出目录、CSV、VTK、restart 和临时结果未提交。 +- [x] 确认代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖。 +- [x] 准备 0.7.0 发布提交说明。