From 53c005e9ad033676428c606341a789e74022d7cf Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 4 Jul 2026 10:25:04 +0800 Subject: [PATCH] Release SPHLite 0.8.0 --- CMakeLists.txt | 15 + README.md | 2 + docs/06_test_and_verification_plan.md | 43 +++ docs/09_release_history.md | 51 ++- docs/11_benchmark_matrix.md | 42 ++- src/output/sph_restart.f90 | 21 +- tests/data/coupling_mock_disabled_080.inp | 17 + tests/data/coupling_mock_mixed_080.inp | 34 ++ tests/data/coupling_mock_no_active_080.inp | 17 + tests/data/coupling_mock_shell_080.inp | 21 ++ tests/data/coupling_mock_solid_080.inp | 17 + tests/data/coupling_mock_stale_080.inp | 17 + tests/module/test_blast_output.f90 | 6 +- tests/module/test_blast_output_071.f90 | 6 +- tests/module/test_blast_restart_boundary.f90 | 2 +- .../test_blast_restart_boundary_071.f90 | 2 +- tests/module/test_coupling_restart_080.f90 | 24 ++ tests/module/test_coupling_smoke_080.f90 | 344 ++++++++++++++++++ tests/module/test_explosive_restart_041.f90 | 2 +- tests/module/test_restart.f90 | 2 +- tests/module/test_solid_restart_050.f90 | 2 +- .../module/test_solid_restart_050_compat.f90 | 9 + tests/source_size_exceptions.txt | 6 + todo.md | 94 ++--- tools/testing/test_python_debug.py | 5 + 25 files changed, 737 insertions(+), 64 deletions(-) create mode 100644 tests/data/coupling_mock_disabled_080.inp create mode 100644 tests/data/coupling_mock_mixed_080.inp create mode 100644 tests/data/coupling_mock_no_active_080.inp create mode 100644 tests/data/coupling_mock_shell_080.inp create mode 100644 tests/data/coupling_mock_solid_080.inp create mode 100644 tests/data/coupling_mock_stale_080.inp create mode 100644 tests/module/test_coupling_smoke_080.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 808693a..fdd25cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,6 +261,12 @@ set_target_properties(test_coupling_fortran_api_080 PROPERTIES Fortran_MODULE_DI add_test(NAME coupling_fortran_api_080 COMMAND test_coupling_fortran_api_080) set_tests_properties(coupling_fortran_api_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") +add_executable(test_coupling_smoke_080 tests/module/test_coupling_smoke_080.f90) +target_link_libraries(test_coupling_smoke_080 PRIVATE sphlite_core) +set_target_properties(test_coupling_smoke_080 PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME coupling_smoke_080 COMMAND test_coupling_smoke_080) +set_tests_properties(coupling_smoke_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_executable(test_input_gas tests/module/test_input_gas.f90) target_link_libraries(test_input_gas PRIVATE sphlite_core) set_target_properties(test_input_gas PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") @@ -1169,3 +1175,12 @@ add_test( --exceptions "${CMAKE_CURRENT_SOURCE_DIR}/tests/source_size_exceptions.txt" ) set_tests_properties(shell_061_source_size PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_test( + NAME coupling_source_size_080 + COMMAND "${Python3_EXECUTABLE}" + "${CMAKE_CURRENT_SOURCE_DIR}/tools/testing/check_source_size.py" + --root "${CMAKE_CURRENT_SOURCE_DIR}" + --exceptions "${CMAKE_CURRENT_SOURCE_DIR}/tests/source_size_exceptions.txt" +) +set_tests_properties(coupling_source_size_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/README.md b/README.md index 5715c63..708ad0d 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,5 @@ SPHLite 的编译和测试要求应与 FEMLite 保持一致风格: - 0.7.1 仍限定在 SPHLite 内部局部爆炸链路稳定化,不进入 0.8 的 FEM-SPH 接触耦合或连续体耦合;不交付真实工程级水下接触爆炸响应、完整舱段破坏 benchmark、Shell 完整动力学闭环或公开 Blast C ABI/C++/Python 稳定接口。 - 0.8.0 将 `CouplingInterface` 从占位推进为可由外部耦合模块逐步驱动的 SPHLite 侧接触耦合接口,计划覆盖 coupling region 输入、粒子/Facet Proxy 导出、外部力/面载荷/运动边界导入、显式步施加、诊断、restart、C ABI/C++/Python/CLI 和 mock coupling gate。 - 0.8.0 仍不直接依赖 FEMLite,不实现外部 CouplingModule,不交付连续体耦合,不宣称工程级船舶水下接触爆炸破坏 benchmark。 +- 0.8.0 本地发布 gate 已通过:完整 CTest 163/163,0.8.0 coupling 专项 gate 24/24,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、28/28、33/33、14/14,0.7.0 blast 回归 gate 19/19,0.7.1 blast 专项 gate 7/7,source size 相关 gate 8/8,`git diff --check` 通过。 +- 0.8.0 交付的是 SPHLite 侧中立接触耦合接口和 mock coupling smoke;不宣称真实 FEMLite 联合运行、外部 CouplingModule、连续体一体化耦合、生产级接触算法或工程级船舶水下接触爆炸破坏 benchmark。 diff --git a/docs/06_test_and_verification_plan.md b/docs/06_test_and_verification_plan.md index 57eb98a..24ab0a6 100644 --- a/docs/06_test_and_verification_plan.md +++ b/docs/06_test_and_verification_plan.md @@ -399,6 +399,49 @@ git diff --check 0.7.1 不验收真实工程级水下接触爆炸响应,不验收真实 FEM-SPH 接触耦合或连续体耦合,不验收完整舱段破坏 benchmark,不验收复杂撕裂、穿孔、碎片云、焊缝失效库、大规模并行或 GPU 后端。0.7.1 的 Blast 诊断仍限定为 Fortran 内部查询和 CSV 调试边界,不新增公开 C ABI/C++/Python 稳定接口,也不写入新的正式 restart state。 +## 7.10 0.8.0 Release Gate + +0.8.0 在 0.7.1 局部爆炸稳定化版本之上交付 SPHLite 侧中立接触耦合接口。该 gate 验收 coupling region 输入、粒子/Facet Proxy 导出、外部粒子力、facet load、运动边界、显式步响应、diagnostics、`STATE_0_8` restart、C ABI/C++/Python/CLI 接口和 mock coupling smoke。 + +0.8.0 coupling 专项 gate 包含: +- `input_coupling_region_080` +- `input_coupling_errors_080` +- `coupling_region_build_080` +- `coupling_particle_export_080` +- `coupling_facet_export_080` +- `coupling_facet_errors_080` +- `coupling_particle_force_import_080` +- `coupling_facet_load_import_080` +- `coupling_motion_boundary_080` +- `coupling_diagnostics_080` +- `coupling_solver_order_080` +- `coupling_solid_response_080` +- `coupling_shell_response_080` +- `coupling_noop_regression_080` +- `coupling_output_080` +- `coupling_restart_080` +- `coupling_restart_071_compat` +- `coupling_fortran_api_080` +- `coupling_c_api_080` +- `coupling_cpp_api_080` +- `coupling_python_080` +- `coupling_cli_080` +- `coupling_smoke_080` +- `coupling_source_size_080` + +0.8.0 本地 release gate: +```powershell +cmake --build build-codex-unix +ctest --test-dir build-codex-unix -R "^(input_coupling_region_080|input_coupling_errors_080|coupling_region_build_080|coupling_particle_export_080|coupling_facet_export_080|coupling_facet_errors_080|coupling_particle_force_import_080|coupling_facet_load_import_080|coupling_motion_boundary_080|coupling_diagnostics_080|coupling_solver_order_080|coupling_solid_response_080|coupling_shell_response_080|coupling_noop_regression_080|coupling_restart_080|coupling_restart_071_compat|coupling_output_080|coupling_fortran_api_080|coupling_c_api_080|coupling_cpp_api_080|coupling_python_080|coupling_cli_080|coupling_smoke_080|coupling_source_size_080)$" --output-on-failure +ctest --test-dir build-codex-unix --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|coupling_source_size_080)$" --output-on-failure +git diff --check +``` + +2026-07-04 本地结果:完整 CTest 163/163 通过,0.8.0 coupling 专项 gate 24/24 通过,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、28/28、33/33、14/14 通过,0.7.0 blast 回归 gate 19/19 通过,0.7.1 blast 专项 gate 7/7 通过,source size 相关 gate 8/8 通过,`git diff --check` 通过。 + +0.8.0 不验收真实 FEMLite 联合运行,不验收外部 CouplingModule/CoupleLite/CoupledLite/CouplingLite,不验收连续体一部分 FEM 一部分 SPH 的生产级连续体耦合,不验收工程级船舶水下接触爆炸舱段破坏 benchmark,不验收复杂接触搜索、真实接触约束求解、大规模并行或 GPU 后端。 + ## 8. Source Size 门禁 从第一版开始设置 source size 门禁。建议沿用 FEMLite 风格: diff --git a/docs/09_release_history.md b/docs/09_release_history.md index 3ee8a86..aa46c2e 100644 --- a/docs/09_release_history.md +++ b/docs/09_release_history.md @@ -1,10 +1,10 @@ # 09 版本历史与验收记录 -文档状态:0.7.1 发布记录 +文档状态:0.8.0 发布记录 ## 1. 当前状态 -SPHLite 当前发布版本为 0.7.1 局部爆炸稳定化版本。本版本在 0.7.0 小型 Water/Gas/Explosive/Solid/Shell blast smoke 起点之上,新增多 blast region 输入加固、启用/禁用控制、结构载荷叠加诊断、输出/restart 边界测试和 `blast_smoke_071`。0.7.1 不交付真实工程级水下接触爆炸响应、真实 FEM-SPH 联合运行、连续体耦合、完整舱段破坏 benchmark、Shell 完整动力学闭环或公开 Blast C ABI/C++/Python 稳定接口。 +SPHLite 当前发布版本为 0.8.0 中立接触耦合接口起步版本。本版本在 0.7.1 局部爆炸稳定化版本之上,新增 SPHLite 侧 coupling region、粒子/Facet Proxy 导出、外部载荷/运动边界导入、显式步施加、diagnostics、`STATE_0_8` restart、C ABI/C++/Python/CLI 接口和 mock coupling gate。0.8.0 不交付真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合、生产级接触算法或工程级水下接触爆炸舱段破坏 benchmark。 ## 2. 规划版本线 @@ -578,6 +578,53 @@ cmake --build build-codex-unix - 0.7.1 已于 2026-07-04 完成本地发布记录提交,并准备标记 `v0.7.1`。 +### 0.8.0 本地验收记录 + +记录日期:2026-07-04 + +本地构建目录:`build-codex-unix` + +版本定位: +- 0.8.0 是 SPHLite 侧中立接触耦合接口起步版本。 +- 0.8.0 新增并验收 `*SPHLITE COUPLING REGION` 的 0.8 子集、active/disabled region 构建、phase/material/section 过滤和 `TYPE=CONTACT` 启用路径。 +- 0.8.0 支持按 region 导出粒子状态和 Shell Facet Proxy,导入外部粒子力、facet load 和 direct motion boundary。 +- 0.8.0 将 coupling 外部载荷接入显式步,记录当前力、冲量、做功、动量/能量交换、stale/skipped/nonfinite/imported 计数和最大响应诊断。 +- 0.8.0 新增 `STATE_0_8` restart,保存 coupling region、导入缓存、运动边界和累计诊断,并兼容既有 restart 读入时初始化空 coupling 状态。 +- 0.8.0 追加 Fortran API、C ABI、C++ wrapper、Python ctypes 和 CLI inspect 的 coupling 查询、导出、导入和诊断入口。 +- 0.8.0 新增 `coupling_smoke_080`,覆盖 Solid mock contact、Shell mock contact、Solid/Shell 混合、disabled region、no-active response 和 stale/repeated import。 + +验收结果: +- `cmake --build build-codex-unix` 通过。 +- `ctest --test-dir build-codex-unix --output-on-failure` 通过:163/163。 +- 0.8.0 coupling 专项 gate 通过:24/24。 +- Water/Gas/Explosive/Solid/Shell 分类 gate 通过:6/6、19/19、28/28、33/33、14/14。 +- 0.7.0 blast 回归 gate 通过:19/19。 +- 0.7.1 blast 专项 gate 通过:7/7。 +- source size 相关 gate 通过:8/8。 +- `git diff --check` 通过。 +- 代码、构建脚本、测试和工具目录未新增 FEMLite 或 CouplingModule 直接依赖。 +- 输出目录、CSV、VTK、restart 和临时结果未进入待提交清单。 + +不交付范围: +- 0.8.0 不交付真实 FEMLite 联合运行。 +- 0.8.0 不交付外部 CouplingModule、CoupleLite、CoupledLite 或 CouplingLite。 +- 0.8.0 不交付连续体一部分 FEM 一部分 SPH 的生产级连续体耦合。 +- 0.8.0 不交付生产级接触搜索、接触约束、摩擦、接触稳定化或工程接触参数库。 +- 0.8.0 不交付工程级船舶水下接触爆炸舱段破坏 benchmark。 +- 0.8.0 不交付复杂撕裂、穿孔、碎片云、焊缝失效库、大规模并行或 GPU 后端。 + +已知限制: +- Facet Proxy 当前仍是 Shell 粒子级中立代理,不等价于真实外表面重构。 +- Mock coupling smoke 只验证 SPHLite 侧接口链路和受控响应,不代表真实外部耦合模块。 +- Source size 中对 0.8.0 接口层、restart、CLI、Python/C++ wrapper 和 CouplingInterface 主文件登记了说明性例外;后续版本应优先拆分。 + +发布建议: +- 建议将 0.8.0 作为 SPHLite 侧中立接触耦合接口起步版本发布。 +- 0.8.0 发布后,后续主线应优先推进接口拆分、耦合边界稳定性、真实外部耦合模块对接设计和连续体耦合的需求拆分。 + +发布记录: +- 0.8.0 已于 2026-07-04 完成本地发布 gate,并准备标记 `v0.8.0`。 + 后续每个版本应记录: - 完成能力。 diff --git a/docs/11_benchmark_matrix.md b/docs/11_benchmark_matrix.md index bdaf6c4..098a835 100644 --- a/docs/11_benchmark_matrix.md +++ b/docs/11_benchmark_matrix.md @@ -1,10 +1,10 @@ # 11 Benchmark 与验收矩阵 -文档状态:0.7.1 gate 记录 +文档状态:0.8.0 gate 记录 ## 1. 当前状态 -0.7.1 在 0.7.0 局部爆炸 smoke gate 基础上新增多 blast region、结构载荷叠加、诊断稳定性、输出/restart 边界和 `blast_smoke_071` gate,并继续保留工程 benchmark 矩阵作为长期规划。本版本的 Blast 能力只用于小规模链路检查和后续真实压力载荷、耦合边界开发前置验收,不作为工程精度 benchmark。 +0.8.0 在 0.7.1 局部爆炸稳定化 gate 基础上新增 SPHLite 侧中立接触耦合接口 gate,覆盖 coupling region、粒子/Facet Proxy 导出、外部载荷/运动边界导入、显式步响应、diagnostics、restart、接口层和 mock coupling smoke。0.8.0 仍不作为真实 FEMLite 联合运行、连续体耦合或工程级水下接触爆炸 benchmark。 ## 2. 0.1.0 Release Gate @@ -433,6 +433,44 @@ |---|---|---| | 2026-07-04 | `build-codex-unix` | 完整 CTest 139/139 通过,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、16/16、27/27、31/31、13/13 通过,0.7.0 blast 回归 gate 14/14 通过,0.7.1 blast 专项 gate 12/12 通过,source size 相关 gate 7/7 通过,`git diff --check` 通过 | +## 2.15 0.8.0 Release Gate + +0.8.0 默认 gate 在 0.7.1 局部爆炸稳定化版本之上建立 SPHLite 侧中立接触耦合接口。该 gate 只验收小型 mock coupling 链路和接口契约,不验收真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合或工程级船舶水下接触爆炸破坏 benchmark。 + +| 测试名 | 类型 | 验收点 | +|---|---|---| +| `input_coupling_region_080` | Fortran input | coupling region 名称、set、phase/material/section 过滤、enabled、export/import 语义 | +| `input_coupling_errors_080` | Fortran input | 非法 type/export/import/enabled、重复名称、缺失 set 和 continuum 预留错误路径 | +| `coupling_region_build_080` | Fortran database | active/disabled region 构建、内部 id、粒子索引表和隔离性 | +| `coupling_particle_export_080` | Fortran API | 粒子 external/internal id、phase/status、material/section、标量和三维状态导出 | +| `coupling_facet_export_080` | Fortran API | Shell Facet Proxy 数量、id、中心、速度、法向、面积和材料/section 导出 | +| `coupling_facet_errors_080` | Fortran API | 无 facet proxy、非法 facet、零面积/非法法向错误路径 | +| `coupling_particle_force_import_080` | Fortran API | external id/region index 粒子力导入、累加、清零、stale/skipped/nonfinite 计数 | +| `coupling_facet_load_import_080` | Fortran API | facet load 和 facet 粒子力映射、非法 facet、数量不匹配和非有限错误路径 | +| `coupling_motion_boundary_080` | Fortran API | direct velocity/position 运动边界、penalty 预留错误路径和 inactive skip | +| `coupling_diagnostics_080` | Fortran solver/API | 当前力、力矩、冲量、做功、动量/能量交换、最大响应和缓存消费 | +| `coupling_solver_order_080` | Fortran solver | coupling 载荷与显式 Velocity-Verlet 步序、空导入和禁用 region 安全路径 | +| `coupling_solid_response_080` | Fortran solver | Solid 粒子受控方向响应、加速度、速度和诊断 | +| `coupling_shell_response_080` | Fortran solver | Shell 平动响应、director/转动隔离和 facet load 诊断 | +| `coupling_noop_regression_080` | Fortran regression | Water/Gas/Explosive/Solid/Shell 单相无 coupling 污染、disabled region no-op | +| `coupling_output_080` | Fortran output | summary CSV 和 particle CSV coupling 字段 | +| `coupling_restart_080` | Fortran restart | `STATE_0_8` coupling 状态、缓存、运动边界和累计诊断读回 | +| `coupling_restart_071_compat` | Fortran restart | 既有 restart 兼容读入后初始化空 coupling 状态 | +| `coupling_fortran_api_080` | Fortran API | region 查询、导出、导入和 packed diagnostics | +| `coupling_c_api_080` | C ABI | C 层 region/export/import/diagnostics 追加接口 | +| `coupling_cpp_api_080` | C++ wrapper | C++ 薄包装的 coupling 查询、导出、导入和诊断 | +| `coupling_python_080` | Python ctypes | Python debug wrapper coupling 查询、导出、导入和诊断 | +| `coupling_cli_080` | CLI | inspect 输出 coupling region、export/import mode 和 diagnostics | +| `coupling_smoke_080` | Fortran smoke | Solid/Shell/混合 mock contact、disabled/no-active/stale/repeated import 有限性 | +| `coupling_source_size_080` | 工具门禁 | Coupling 0.8 source size、说明性例外和 stale exception 检查 | + +0.8.0 不验收真实 FEMLite 联合运行、外部 CouplingModule、连续体一部分 FEM 一部分 SPH 的生产级连续体耦合、工程级接触算法、工程级船舶水下接触爆炸破坏 benchmark、复杂撕裂/穿孔/碎片云、焊缝失效库、大规模并行或 GPU 后端。 + +本地验收记录: +| 日期 | 构建目录 | 结果 | +|---|---|---| +| 2026-07-04 | `build-codex-unix` | 完整 CTest 163/163 通过,0.8.0 coupling 专项 gate 24/24 通过,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、28/28、33/33、14/14 通过,0.7.0 blast 回归 gate 19/19 通过,0.7.1 blast 专项 gate 7/7 通过,source size 相关 gate 8/8 通过,`git diff --check` 通过 | + ## 3. 基础数值矩阵 | 领域 | 测试或 benchmark | 验收点 | diff --git a/src/output/sph_restart.f90 b/src/output/sph_restart.f90 index 1e85c50..fe10fb2 100644 --- a/src/output/sph_restart.f90 +++ b/src/output/sph_restart.f90 @@ -690,10 +690,10 @@ contains write(SPH_RESTART_UNIT, *) coupling_cumulative_impulse(:), & coupling_momentum_exchange(:) write(SPH_RESTART_UNIT, *) coupling_cumulative_work, coupling_energy_exchange - write(SPH_RESTART_UNIT, *) coupling_stale_load_count, & - coupling_skipped_particle_count, coupling_nonfinite_import_count, & - coupling_imported_force_count - write(SPH_RESTART_UNIT, *) npart + write(SPH_RESTART_UNIT, '(I0,1X,I0,1X,I0,1X,I0)') & + coupling_stale_load_count, coupling_skipped_particle_count, & + coupling_nonfinite_import_count, coupling_imported_force_count + write(SPH_RESTART_UNIT, '(I0)') npart do i = 1, npart write(SPH_RESTART_UNIT, *) coupling_external_force(:,i), & coupling_motion_velocity(:,i), coupling_motion_position(:,i), & @@ -709,6 +709,7 @@ contains integer :: cache_count integer :: local_ierr integer :: imported_force_count + character(len=256) :: counter_line ios = 0 call sph_restart_clear_coupling_state(local_ierr) @@ -763,10 +764,18 @@ contains read(SPH_RESTART_UNIT, *, iostat=ios) coupling_cumulative_work, & coupling_energy_exchange if (ios /= 0) return - read(SPH_RESTART_UNIT, *, iostat=ios) coupling_stale_load_count, & + imported_force_count = 0 + read(SPH_RESTART_UNIT, '(A)', iostat=ios) counter_line + if (ios /= 0) return + read(counter_line, *, iostat=ios) coupling_stale_load_count, & coupling_skipped_particle_count, coupling_nonfinite_import_count, & imported_force_count - if (ios /= 0) return + if (ios /= 0) then + read(counter_line, *, iostat=ios) coupling_stale_load_count, & + coupling_skipped_particle_count, coupling_nonfinite_import_count + if (ios /= 0) return + imported_force_count = 0 + end if read(SPH_RESTART_UNIT, *, iostat=ios) cache_count if (ios /= 0) return if (cache_count /= npart) then diff --git a/tests/data/coupling_mock_disabled_080.inp b/tests/data/coupling_mock_disabled_080.inp new file mode 100644 index 0000000..4559f66 --- /dev/null +++ b/tests/data/coupling_mock_disabled_080.inp @@ -0,0 +1,17 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +*ELSET, ELSET=DISABLED_TARGET +1, 2 +*MATERIAL, NAME=DISABLED_STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, ELSET=DISABLED_TARGET, MATERIAL=DISABLED_STEEL +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=1.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=DISABLED_SMOKE, SET=DISABLED_TARGET, TYPE=CONTACT, EXPORT=BOTH, IMPORT=FORCE, ENABLED=NO, PHASE=SOLID, MATERIAL=DISABLED_STEEL, SECTION=DISABLED_TARGET diff --git a/tests/data/coupling_mock_mixed_080.inp b/tests/data/coupling_mock_mixed_080.inp new file mode 100644 index 0000000..6bec60f --- /dev/null +++ b/tests/data/coupling_mock_mixed_080.inp @@ -0,0 +1,34 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +3, 0.0, 0.1, 0.0 +4, 0.4, 0.0, 0.0 +5, 0.5, 0.0, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +3, 3 +4, 4 +5, 5 +*ELSET, ELSET=SHELL_MIXED +1, 2, 3 +*ELSET, ELSET=SOLID_MIXED +4, 5 +*MATERIAL, NAME=SHELL_MIXED_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*MATERIAL, NAME=SOLID_MIXED_STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_MIXED, MATERIAL=SHELL_MIXED_STEEL, THICKNESS=0.010, POINTS=5, SHEAR_CORRECTION=0.8333333333 +*SOLID SECTION, ELSET=SOLID_MIXED, MATERIAL=SOLID_MIXED_STEEL +*SPHLITE SHELL DIRECTOR, SET=SHELL_MIXED, NX=0.0, NY=0.0, NZ=1.0 +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=2.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=MIXED_SHELL_FACETS, SET=SHELL_MIXED, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_MIXED_STEEL, SECTION=SHELL_MIXED, SURFACE=MIXED_SHELL_SURFACE +*SPHLITE COUPLING REGION, NAME=MIXED_SHELL_MOTION, SET=SHELL_MIXED, TYPE=CONTACT, EXPORT=BOTH, IMPORT=MOTION, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_MIXED_STEEL, SECTION=SHELL_MIXED +*SPHLITE COUPLING REGION, NAME=MIXED_SOLID_CONTACT, SET=SOLID_MIXED, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, ENABLED=YES, PHASE=SOLID, MATERIAL=SOLID_MIXED_STEEL, SECTION=SOLID_MIXED diff --git a/tests/data/coupling_mock_no_active_080.inp b/tests/data/coupling_mock_no_active_080.inp new file mode 100644 index 0000000..f9bfb36 --- /dev/null +++ b/tests/data/coupling_mock_no_active_080.inp @@ -0,0 +1,17 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +*ELSET, ELSET=NO_ACTIVE_TARGET +1, 2 +*MATERIAL, NAME=NO_ACTIVE_STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, ELSET=NO_ACTIVE_TARGET, MATERIAL=NO_ACTIVE_STEEL +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=1.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=NO_ACTIVE_CONTACT, SET=NO_ACTIVE_TARGET, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, ENABLED=YES, PHASE=SOLID, MATERIAL=NO_ACTIVE_STEEL, SECTION=NO_ACTIVE_TARGET diff --git a/tests/data/coupling_mock_shell_080.inp b/tests/data/coupling_mock_shell_080.inp new file mode 100644 index 0000000..4b99596 --- /dev/null +++ b/tests/data/coupling_mock_shell_080.inp @@ -0,0 +1,21 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +3, 0.0, 0.1, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +3, 3 +*ELSET, ELSET=SHELL_TARGET +1, 2, 3 +*MATERIAL, NAME=SHELL_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_TARGET, MATERIAL=SHELL_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SPHLITE SHELL DIRECTOR, SET=SHELL_TARGET, NX=0.0, NY=0.0, NZ=1.0 +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=7.85, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=SHELL_CONTACT_SMOKE, SET=SHELL_TARGET, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_TARGET, SURFACE=SHELL_SMOKE_SURFACE +*SPHLITE COUPLING REGION, NAME=SHELL_MOTION_SMOKE, SET=SHELL_TARGET, TYPE=CONTACT, EXPORT=BOTH, IMPORT=MOTION, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_TARGET diff --git a/tests/data/coupling_mock_solid_080.inp b/tests/data/coupling_mock_solid_080.inp new file mode 100644 index 0000000..62a611b --- /dev/null +++ b/tests/data/coupling_mock_solid_080.inp @@ -0,0 +1,17 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +*ELSET, ELSET=SOLID_TARGET +1, 2 +*MATERIAL, NAME=STEEL_SOLID, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, ELSET=SOLID_TARGET, MATERIAL=STEEL_SOLID +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=1.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=SOLID_CONTACT_SMOKE, SET=SOLID_TARGET, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, ENABLED=YES, PHASE=SOLID, MATERIAL=STEEL_SOLID, SECTION=SOLID_TARGET diff --git a/tests/data/coupling_mock_stale_080.inp b/tests/data/coupling_mock_stale_080.inp new file mode 100644 index 0000000..26555a8 --- /dev/null +++ b/tests/data/coupling_mock_stale_080.inp @@ -0,0 +1,17 @@ +*NODE +1, 0.0, 0.0, 0.0 +2, 0.1, 0.0, 0.0 +*ELEMENT, TYPE=SPH3D +1, 1 +2, 2 +*ELSET, ELSET=STALE_TARGET +1, 2 +*MATERIAL, NAME=STALE_STEEL, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, ELSET=STALE_TARGET, MATERIAL=STALE_STEEL +*SPHLITE PARTICLE CONTROL, H=0.12, MASS=1.0, VOLUME=0.001 +*SPHLITE TIME CONTROL, DT=1.0E-7, TIME=1.0E-7, STEPS=1, SAFETY=0.5 +*SPHLITE COUPLING REGION, NAME=STALE_CONTACT, SET=STALE_TARGET, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, ENABLED=YES, PHASE=SOLID, MATERIAL=STALE_STEEL, SECTION=STALE_TARGET diff --git a/tests/module/test_blast_output.f90 b/tests/module/test_blast_output.f90 index a8b3e08..194bd2e 100644 --- a/tests/module/test_blast_output.f90 +++ b/tests/module/test_blast_output.f90 @@ -78,16 +78,20 @@ contains integer :: failure integer :: reference_neighbors integer :: correction_status + integer :: coupling_motion_flag + integer :: coupling_region_id real(rk) :: pos(3) real(rk) :: vel(3) real(rk) :: scalar_values(4) real(rk) :: explosive_values(6) real(rk) :: stress_values(6) real(rk) :: solid_values(5) + real(rk) :: coupling_force(3) read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, & scalar_values, explosive_values, stress_values, solid_values, & - blast_values, failure, reference_neighbors, correction_status + blast_values, coupling_force, failure, reference_neighbors, & + correction_status, coupling_motion_flag, coupling_region_id end subroutine read_particle_row subroutine check_summary_csv(filename) diff --git a/tests/module/test_blast_output_071.f90 b/tests/module/test_blast_output_071.f90 index b5d4a5b..0d4f059 100644 --- a/tests/module/test_blast_output_071.f90 +++ b/tests/module/test_blast_output_071.f90 @@ -117,16 +117,20 @@ contains integer :: failure integer :: reference_neighbors integer :: correction_status + integer :: coupling_motion_flag + integer :: coupling_region_id real(rk) :: pos(3) real(rk) :: vel(3) real(rk) :: scalar_values(4) real(rk) :: explosive_values(6) real(rk) :: stress_values(6) real(rk) :: solid_values(5) + real(rk) :: coupling_force(3) read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, & scalar_values, explosive_values, stress_values, solid_values, & - blast_values, failure, reference_neighbors, correction_status + blast_values, coupling_force, failure, reference_neighbors, & + correction_status, coupling_motion_flag, coupling_region_id end subroutine read_particle_row subroutine check_summary_csv(filename) diff --git a/tests/module/test_blast_restart_boundary.f90 b/tests/module/test_blast_restart_boundary.f90 index 441a0e3..efa0788 100644 --- a/tests/module/test_blast_restart_boundary.f90 +++ b/tests/module/test_blast_restart_boundary.f90 @@ -58,7 +58,7 @@ contains if (ios /= 0) call fail('Blast restart header read failed') if (trim(tag) /= 'SPHLITE_RESTART') call fail('Blast restart tag mismatch') if (trim(state) == 'STATE_0_7') call fail('Blast restart state was frozen too early') - if (trim(state) /= 'STATE_0_5_1') call fail('Blast restart boundary state mismatch') + if (trim(state) /= 'STATE_0_8') call fail('Blast restart boundary state mismatch') end subroutine assert_restart_header subroutine assert_ok(ierr_value, message) diff --git a/tests/module/test_blast_restart_boundary_071.f90 b/tests/module/test_blast_restart_boundary_071.f90 index d2732ea..79d4593 100644 --- a/tests/module/test_blast_restart_boundary_071.f90 +++ b/tests/module/test_blast_restart_boundary_071.f90 @@ -74,7 +74,7 @@ contains if (trim(state) == 'STATE_0_7' .or. trim(state) == 'STATE_0_7_1') then call fail('0.7.1 Blast restart state was frozen too early') end if - if (trim(state) /= 'STATE_0_5_1') call fail('0.7.1 Blast restart boundary state mismatch') + if (trim(state) /= 'STATE_0_8') call fail('0.7.1 Blast restart boundary state mismatch') end subroutine assert_restart_header subroutine delete_file_if_exists(filename) diff --git a/tests/module/test_coupling_restart_080.f90 b/tests/module/test_coupling_restart_080.f90 index dfffc36..c76da45 100644 --- a/tests/module/test_coupling_restart_080.f90 +++ b/tests/module/test_coupling_restart_080.f90 @@ -17,6 +17,7 @@ program test_coupling_restart_080 integer :: ierr call check_coupling_restart_round_trip() + call check_empty_coupling_restart_round_trip() contains @@ -113,6 +114,29 @@ contains call assert_ok(ierr, 'finalize failed for coupling restart') end subroutine check_coupling_restart_round_trip + subroutine check_empty_coupling_restart_round_trip() + integer :: region_count + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed for empty coupling restart') + call sph_read_inp('tests/data/water_minimal_020.inp', ierr) + call assert_ok(ierr, 'read failed for empty coupling restart') + call sph_build_model(ierr) + call assert_ok(ierr, 'build failed for empty coupling restart') + call sph_write_restart('build-codex-unix/restart_coupling_empty_080.tmp', ierr) + call assert_ok(ierr, 'empty coupling restart write failed') + call sph_read_restart('build-codex-unix/restart_coupling_empty_080.tmp', ierr) + call assert_ok(ierr, 'empty coupling restart read failed') + call sph_coupling_get_region_count(region_count, ierr) + call assert_ok(ierr, 'empty coupling restart region count failed') + if (region_count /= 0) call fail('empty coupling restart region count mismatch') + if (coupling_imported_force_count /= 0) then + call fail('empty coupling restart imported force count mismatch') + end if + call sph_finalize(ierr) + call assert_ok(ierr, 'finalize failed for empty coupling restart') + end subroutine check_empty_coupling_restart_round_trip + subroutine scramble_coupling_state() coupling_external_force = -999.0_rk coupling_motion_flag = -999 diff --git a/tests/module/test_coupling_smoke_080.f90 b/tests/module/test_coupling_smoke_080.f90 new file mode 100644 index 0000000..bc33836 --- /dev/null +++ b/tests/module/test_coupling_smoke_080.f90 @@ -0,0 +1,344 @@ +program test_coupling_smoke_080 + use sph_precision, only: rk, SPH_NDIM + 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, mass, rho, volume, pressure, & + internal_energy, temperature, h, particle_status, SPH_STATUS_INACTIVE + use sph_coupling_interface, only: coupling_stale_load_count, & + coupling_skipped_particle_count, SPH_COUPLING_MOTION_DIRECT, & + sph_coupling_import_force_by_region_index, & + sph_coupling_import_region_facet_load, & + sph_coupling_import_motion_velocity, sph_coupling_clear_imports, & + sph_coupling_get_extended_diagnostics + implicit none + + integer :: ierr + real(rk) :: diag_force(SPH_NDIM) + real(rk) :: diag_moment(SPH_NDIM) + real(rk) :: diag_impulse(SPH_NDIM) + real(rk) :: diag_cumulative_impulse(SPH_NDIM) + real(rk) :: diag_momentum(SPH_NDIM) + real(rk) :: diag_work + real(rk) :: diag_cumulative_work + real(rk) :: diag_energy + real(rk) :: diag_max_force + real(rk) :: diag_max_acceleration + real(rk) :: diag_velocity_error + real(rk) :: diag_position_error + integer :: diag_stale + integer :: diag_skipped + integer :: diag_nonfinite + integer :: diag_imported_force + integer :: diag_step_consumed + + call check_solid_contact_smoke() + call check_shell_contact_smoke() + call check_mixed_contact_smoke() + call check_disabled_region_smoke() + call check_no_active_region_smoke() + call check_stale_and_repeated_import_smoke() + +contains + + subroutine check_solid_contact_smoke() + real(rk) :: force(SPH_NDIM) + + call build_case('tests/data/coupling_mock_solid_080.inp') + force = (/mass(1) * 1.0e8_rk, 0.0_rk, 0.0_rk/) + call sph_coupling_import_force_by_region_index('SOLID_CONTACT_SMOKE', & + 1, force, ierr) + call assert_ok(ierr, 'Solid smoke force import failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'Solid smoke advance failed') + call collect_diagnostics('Solid smoke') + if (v(1,1) <= 0.0_rk .or. a(1,1) <= 0.0_rk) then + call fail('Solid smoke response direction mismatch') + end if + if (diag_force(1) <= 0.0_rk .or. diag_impulse(1) <= 0.0_rk) then + call fail('Solid smoke force or impulse diagnostic missing') + end if + call assert_diag_finite('Solid smoke') + call assert_model_finite('Solid smoke') + call finish_case('Solid smoke') + end subroutine check_solid_contact_smoke + + subroutine check_shell_contact_smoke() + real(rk) :: load(SPH_NDIM) + + call build_case('tests/data/coupling_mock_shell_080.inp') + load = (/0.0_rk, mass(1) * 1.0e8_rk, 0.0_rk/) + call sph_coupling_import_region_facet_load('SHELL_CONTACT_SMOKE', & + 1, load, ierr) + call assert_ok(ierr, 'Shell smoke facet load import failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'Shell smoke advance failed') + call collect_diagnostics('Shell smoke') + if (v(2,1) <= 0.0_rk .or. a(2,1) <= 0.0_rk) then + call fail('Shell smoke translation direction mismatch') + end if + if (diag_force(2) <= 0.0_rk .or. diag_momentum(2) <= 0.0_rk) then + call fail('Shell smoke force or momentum diagnostic missing') + end if + call assert_diag_finite('Shell smoke') + call assert_model_finite('Shell smoke') + call finish_case('Shell smoke') + end subroutine check_shell_contact_smoke + + subroutine check_mixed_contact_smoke() + real(rk) :: solid_force(SPH_NDIM) + real(rk) :: shell_load(SPH_NDIM) + real(rk) :: target_velocity(SPH_NDIM) + + call build_case('tests/data/coupling_mock_mixed_080.inp') + shell_load = (/0.0_rk, mass(1) * 5.0e7_rk, 0.0_rk/) + call sph_coupling_import_region_facet_load('MIXED_SHELL_FACETS', & + 1, shell_load, ierr) + call assert_ok(ierr, 'Mixed shell facet load import failed') + solid_force = (/mass(4) * 8.0e7_rk, 0.0_rk, 0.0_rk/) + call sph_coupling_import_force_by_region_index('MIXED_SOLID_CONTACT', & + 1, solid_force, ierr) + call assert_ok(ierr, 'Mixed solid force import failed') + target_velocity = (/0.0_rk, 0.0_rk, 3.0_rk/) + call sph_coupling_import_motion_velocity('MIXED_SHELL_MOTION', 2, & + SPH_COUPLING_MOTION_DIRECT, target_velocity, ierr) + call assert_ok(ierr, 'Mixed shell motion import failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'Mixed smoke advance failed') + call collect_diagnostics('Mixed smoke') + if (v(2,1) <= 0.0_rk) call fail('Mixed Shell force direction mismatch') + if (v(1,4) <= 0.0_rk) call fail('Mixed Solid force direction mismatch') + call assert_close(v(3,2), target_velocity(3), & + 'Mixed motion velocity target mismatch') + if (diag_force(1) <= 0.0_rk .or. diag_force(2) <= 0.0_rk) then + call fail('Mixed force diagnostics missing') + end if + call assert_diag_finite('Mixed smoke') + call assert_model_finite('Mixed smoke') + call finish_case('Mixed smoke') + end subroutine check_mixed_contact_smoke + + subroutine check_disabled_region_smoke() + real(rk) :: force(SPH_NDIM) + + call build_case('tests/data/coupling_mock_disabled_080.inp') + force = (/1.0e8_rk, 0.0_rk, 0.0_rk/) + call sph_coupling_import_force_by_region_index('DISABLED_SMOKE', & + 1, force, ierr) + if (ierr == SPH_SUCCESS) call fail('disabled smoke import succeeded') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'disabled smoke advance failed') + call collect_diagnostics('disabled smoke') + call assert_zero_diagnostics('disabled smoke') + if (maxval(abs(v)) > 1.0e-12_rk) then + call fail('disabled smoke produced velocity response') + end if + call assert_model_finite('disabled smoke') + call finish_case('disabled smoke') + end subroutine check_disabled_region_smoke + + subroutine check_no_active_region_smoke() + real(rk) :: force(SPH_NDIM) + + call build_case('tests/data/coupling_mock_no_active_080.inp') + particle_status = SPH_STATUS_INACTIVE + force = (/0.0_rk, 1.0e8_rk, 0.0_rk/) + call sph_coupling_import_force_by_region_index('NO_ACTIVE_CONTACT', & + 1, force, ierr) + call assert_ok(ierr, 'no-active smoke import failed') + if (coupling_skipped_particle_count <= 0) then + call fail('no-active smoke skipped count missing') + end if + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'no-active smoke advance failed') + call collect_diagnostics('no-active smoke') + call assert_zero_vector(diag_force, 'no-active smoke force changed') + if (maxval(abs(v)) > 1.0e-12_rk) then + call fail('no-active smoke produced velocity response') + end if + if (diag_skipped <= 0) call fail('no-active diagnostic skipped count missing') + call assert_diag_finite('no-active smoke') + call assert_model_finite('no-active smoke') + call finish_case('no-active smoke') + end subroutine check_no_active_region_smoke + + subroutine check_stale_and_repeated_import_smoke() + real(rk) :: stale_force(SPH_NDIM) + real(rk) :: force_a(SPH_NDIM) + real(rk) :: force_b(SPH_NDIM) + real(rk) :: expected(SPH_NDIM) + + call build_case('tests/data/coupling_mock_stale_080.inp') + stale_force = (/1.0e8_rk, 0.0_rk, 0.0_rk/) + call sph_coupling_import_force_by_region_index('STALE_CONTACT', & + 1, stale_force, ierr) + call assert_ok(ierr, 'stale smoke initial force import failed') + call sph_coupling_clear_imports(ierr) + call assert_ok(ierr, 'stale smoke clear failed') + if (coupling_stale_load_count /= 1) then + call fail('stale smoke did not count cleared load') + end if + force_a = (/0.0_rk, mass(1) * 4.0e7_rk, 0.0_rk/) + force_b = (/0.0_rk, mass(1) * 2.0e7_rk, 0.0_rk/) + expected = force_a + force_b + call sph_coupling_import_force_by_region_index('STALE_CONTACT', & + 1, force_a, ierr) + call assert_ok(ierr, 'stale smoke repeated import A failed') + call sph_coupling_import_force_by_region_index('STALE_CONTACT', & + 1, force_b, ierr) + call assert_ok(ierr, 'stale smoke repeated import B failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'stale smoke advance failed') + call collect_diagnostics('stale smoke') + call assert_close(diag_force(2), expected(2), & + 'stale smoke repeated force diagnostic mismatch') + if (v(2,1) <= 0.0_rk) call fail('stale smoke response direction mismatch') + if (diag_stale /= 1) call fail('stale smoke diagnostic count mismatch') + call assert_diag_finite('stale smoke') + call assert_model_finite('stale smoke') + call finish_case('stale smoke') + end subroutine check_stale_and_repeated_import_smoke + + subroutine build_case(filename) + character(len=*), intent(in) :: filename + + call sph_initialize(ierr) + call assert_ok(ierr, 'initialize failed') + call sph_read_inp(filename, ierr) + call assert_ok(ierr, trim(filename) // ' read failed') + call sph_build_model(ierr) + call assert_ok(ierr, trim(filename) // ' build failed') + end subroutine build_case + + subroutine finish_case(label) + character(len=*), intent(in) :: label + + call sph_finalize(ierr) + call assert_ok(ierr, trim(label) // ' finalize failed') + end subroutine finish_case + + subroutine collect_diagnostics(label) + character(len=*), intent(in) :: label + + call sph_coupling_get_extended_diagnostics(diag_force, diag_moment, & + diag_impulse, diag_cumulative_impulse, diag_work, & + diag_cumulative_work, diag_momentum, diag_energy, diag_max_force, & + diag_max_acceleration, diag_velocity_error, diag_position_error, & + diag_stale, diag_skipped, diag_nonfinite, diag_imported_force, & + diag_step_consumed, ierr) + call assert_ok(ierr, trim(label) // ' diagnostics failed') + end subroutine collect_diagnostics + + subroutine assert_model_finite(label) + character(len=*), intent(in) :: label + integer :: i + + do i = 1, npart + call assert_vector_finite(x(:,i), trim(label) // ' position is not finite') + call assert_vector_finite(v(:,i), trim(label) // ' velocity is not finite') + call assert_vector_finite(a(:,i), trim(label) // ' acceleration is not finite') + if (.not. scalar_is_finite(mass(i))) call fail(trim(label) // ' mass is not finite') + if (.not. scalar_is_finite(rho(i))) call fail(trim(label) // ' density is not finite') + if (.not. scalar_is_finite(volume(i))) call fail(trim(label) // ' volume is not finite') + if (.not. scalar_is_finite(pressure(i))) call fail(trim(label) // ' pressure is not finite') + if (.not. scalar_is_finite(internal_energy(i))) then + call fail(trim(label) // ' internal energy is not finite') + end if + if (.not. scalar_is_finite(temperature(i))) then + call fail(trim(label) // ' temperature is not finite') + end if + if (.not. scalar_is_finite(h(i))) call fail(trim(label) // ' h is not finite') + end do + end subroutine assert_model_finite + + subroutine assert_diag_finite(label) + character(len=*), intent(in) :: label + + call assert_vector_finite(diag_force, trim(label) // ' force diagnostic is not finite') + call assert_vector_finite(diag_moment, trim(label) // ' moment diagnostic is not finite') + call assert_vector_finite(diag_impulse, trim(label) // ' impulse diagnostic is not finite') + call assert_vector_finite(diag_cumulative_impulse, & + trim(label) // ' cumulative impulse diagnostic is not finite') + call assert_vector_finite(diag_momentum, trim(label) // ' momentum diagnostic is not finite') + if (.not. scalar_is_finite(diag_work)) call fail(trim(label) // ' work is not finite') + if (.not. scalar_is_finite(diag_cumulative_work)) then + call fail(trim(label) // ' cumulative work is not finite') + end if + if (.not. scalar_is_finite(diag_energy)) then + call fail(trim(label) // ' energy exchange is not finite') + end if + if (.not. scalar_is_finite(diag_max_force)) call fail(trim(label) // ' max force is not finite') + if (.not. scalar_is_finite(diag_max_acceleration)) then + call fail(trim(label) // ' max acceleration is not finite') + end if + if (.not. scalar_is_finite(diag_velocity_error)) then + call fail(trim(label) // ' velocity error is not finite') + end if + if (.not. scalar_is_finite(diag_position_error)) then + call fail(trim(label) // ' position error is not finite') + end if + end subroutine assert_diag_finite + + subroutine assert_zero_diagnostics(label) + character(len=*), intent(in) :: label + + call assert_zero_vector(diag_force, trim(label) // ' force diagnostic changed') + call assert_zero_vector(diag_impulse, trim(label) // ' impulse diagnostic changed') + call assert_zero_vector(diag_momentum, trim(label) // ' momentum diagnostic changed') + if (diag_max_force /= 0.0_rk .or. diag_max_acceleration /= 0.0_rk) then + call fail(trim(label) // ' max response diagnostic changed') + end if + if (diag_stale /= 0 .or. diag_skipped /= 0 .or. diag_nonfinite /= 0) then + call fail(trim(label) // ' counters changed') + end if + call assert_diag_finite(label) + end subroutine assert_zero_diagnostics + + subroutine assert_vector_finite(values, message) + real(rk), intent(in) :: values(SPH_NDIM) + character(len=*), intent(in) :: message + integer :: i + + do i = 1, SPH_NDIM + if (.not. scalar_is_finite(values(i))) call fail(message) + end do + end subroutine assert_vector_finite + + subroutine assert_zero_vector(values, message) + real(rk), intent(in) :: values(SPH_NDIM) + character(len=*), intent(in) :: message + + if (maxval(abs(values)) > 1.0e-12_rk) call fail(message) + end subroutine assert_zero_vector + + 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) > max(1.0e-10_rk, abs(expected) * 1.0e-8_rk)) then + call fail(message) + end if + end subroutine assert_close + + logical function scalar_is_finite(value) + real(rk), intent(in) :: value + + scalar_is_finite = (value == value) .and. abs(value) < huge(value) + end function scalar_is_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_coupling_smoke_080 diff --git a/tests/module/test_explosive_restart_041.f90 b/tests/module/test_explosive_restart_041.f90 index 3432f34..2e8903d 100644 --- a/tests/module/test_explosive_restart_041.f90 +++ b/tests/module/test_explosive_restart_041.f90 @@ -67,7 +67,7 @@ contains close(91) if (ios /= 0) call fail('restart header read failed') if (trim(tag) /= 'SPHLITE_RESTART') call fail('restart tag mismatch') - if (trim(state) /= 'STATE_0_5_1') call fail('restart state version mismatch') + if (trim(state) /= 'STATE_0_8') call fail('restart state version mismatch') end subroutine assert_restart_header subroutine assert_ok(ierr_value, message) diff --git a/tests/module/test_restart.f90 b/tests/module/test_restart.f90 index adfed35..76265ad 100644 --- a/tests/module/test_restart.f90 +++ b/tests/module/test_restart.f90 @@ -168,7 +168,7 @@ contains call fail('restart version mismatch') end if if (patch /= SPH_VERSION_PATCH) call fail('restart patch mismatch') - if (trim(state_version) /= 'STATE_0_5_1') call fail('restart state version mismatch') + if (trim(state_version) /= 'STATE_0_8') call fail('restart state version mismatch') read(74, *, iostat=ios) file_time, file_step, count if (ios /= 0) call fail('restart time state read failed') if (abs(file_time - expected_time) > 1.0e-12_rk) call fail('restart time write mismatch') diff --git a/tests/module/test_solid_restart_050.f90 b/tests/module/test_solid_restart_050.f90 index 3b08629..4083927 100644 --- a/tests/module/test_solid_restart_050.f90 +++ b/tests/module/test_solid_restart_050.f90 @@ -55,7 +55,7 @@ contains call sph_write_restart('build-codex-unix/restart_solid_050.tmp', ierr) call assert_ok(ierr, 'Solid restart write failed') call assert_restart_state_version('build-codex-unix/restart_solid_050.tmp', & - 'STATE_0_5_1') + 'STATE_0_8') call scramble_solid_state() call sph_read_restart('build-codex-unix/restart_solid_050.tmp', ierr) call assert_ok(ierr, 'Solid restart read failed') diff --git a/tests/module/test_solid_restart_050_compat.f90 b/tests/module/test_solid_restart_050_compat.f90 index 075384b..3fea9a3 100644 --- a/tests/module/test_solid_restart_050_compat.f90 +++ b/tests/module/test_solid_restart_050_compat.f90 @@ -102,6 +102,7 @@ contains integer :: solid_start integer :: relative_line integer :: solid_051_lines + integer :: coupling_start line_count = 0 open(unit=97, file=trim(source_filename), status='old', action='read', & @@ -115,6 +116,14 @@ contains lines(line_count) = line end do close(unit=97) + coupling_start = 0 + do i = 1, line_count + if (trim(lines(i)) == 'SPHLITE_COUPLING_STATE') then + coupling_start = i + exit + end if + end do + if (coupling_start > 0) line_count = coupling_start - 1 solid_051_lines = 1 + 6 * solid_material_count + 8 + 9 * npart solid_start = line_count - solid_051_lines + 1 if (solid_start <= 1) call fail('Solid 0.5.0 compat solid block not found') diff --git a/tests/source_size_exceptions.txt b/tests/source_size_exceptions.txt index a925662..06f5468 100644 --- a/tests/source_size_exceptions.txt +++ b/tests/source_size_exceptions.txt @@ -4,8 +4,14 @@ # path/to/file.f90:procedure_name src/database/sph_database.f90 src/gas/sph_gas.f90 # Gas material/EOS dispatch owner; source handling split to sph_gas_source.f90. +include/sphlite.hpp # C++ wrapper owner for 0.8.0 coupling API; split after ABI stabilizes. +Python/sphlite_debug.py # Python ctypes debug wrapper owner for 0.8.0 coupling API. +src/app/sph_main.c # CLI inspect/report owner; coupling inspect split planned after 0.8.0. +src/coupling_interface/sph_coupling_interface.f90 # Coupling 0.8 interface owner; split after release gate. src/input/sph_input_reader.f90 src/interface/sph_api.f90 +src/interface/sph_c_api.c # C ABI shim owner for 0.8.0 coupling API. +src/output/sph_restart.f90 # Restart format owner extended for STATE_0_8. src/shell/sph_shell.f90 # Shell 0.6.1 input/state/kinematics owner; geometry/kinematics split planned after baseline. src/solid/sph_solid.f90 # Solid input/material table owner; dynamics/API/restart are split separately. src/output/sph_restart.f90:sph_restart_read diff --git a/todo.md b/todo.md index d8824cf..8763d91 100644 --- a/todo.md +++ b/todo.md @@ -301,50 +301,50 @@ ## 阶段 G:Mock Coupling Smoke、门禁、文档和发布准备 -- [ ] 设计 Solid mock contact coupling smoke 样例。 -- [ ] 设计 Shell mock contact coupling smoke 样例。 -- [ ] 设计 Solid/Shell 混合 coupling smoke 样例。 -- [ ] 设计 disabled coupling region smoke 样例。 -- [ ] 设计 no-active coupling region smoke 样例。 -- [ ] 设计 stale load 或重复导入 smoke 样例。 -- [ ] 新增 Solid mock contact coupling 输入文件。 -- [ ] 新增 Shell mock contact coupling 输入文件。 -- [ ] 新增 Solid/Shell 混合 coupling 输入文件。 -- [ ] 新增 disabled coupling region 输入文件。 -- [ ] 新增 no-active coupling region 输入文件。 -- [ ] 新增 stale load 或重复导入输入文件。 -- [ ] 验证 smoke 中所有粒子状态保持有限。 -- [ ] 验证 smoke 中 coupling 外部力方向受控。 -- [ ] 验证 smoke 中 coupling 运动边界方向受控。 -- [ ] 验证 smoke 中 Solid 响应方向受控。 -- [ ] 验证 smoke 中 Shell 平动响应方向受控。 -- [ ] 验证 smoke 中冲量和做功诊断有限。 -- [ ] 验证 smoke 中动量和能量交换诊断有限。 -- [ ] 验证 disabled region 不产生 coupling 响应。 -- [ ] 验证 no-active region 不产生 coupling 响应。 -- [ ] 验证 stale load 诊断按预期变化。 -- [ ] 新增 `coupling_smoke_080` 测试。 -- [ ] 新增 `coupling_source_size_080` 测试。 -- [ ] 将阶段 G 新测试接入 CTest。 -- [ ] 运行 0.8.0 coupling 专项 gate。 -- [ ] 运行 Water 回归 gate。 -- [ ] 运行 Gas 回归 gate。 -- [ ] 运行 Explosive 回归 gate。 -- [ ] 运行 Solid 回归 gate。 -- [ ] 运行 Shell 回归 gate。 -- [ ] 运行 0.7.0 blast 回归 gate。 -- [ ] 运行 0.7.1 blast 专项 gate。 -- [ ] 运行完整 CTest。 -- [ ] 运行 source size 相关 gate。 -- [ ] 运行 `git diff --check`。 -- [ ] 检查代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖。 -- [ ] 检查输出目录、CSV、VTK、restart 和临时结果未被提交。 -- [ ] 更新 README 的 0.8.0 当前状态和不交付范围。 -- [ ] 更新 `docs/06_test_and_verification_plan.md` 的 0.8.0 release gate。 -- [ ] 更新 `docs/09_release_history.md` 的 0.8.0 本地验收记录。 -- [ ] 更新 `docs/11_benchmark_matrix.md` 的 0.8.0 gate 矩阵。 -- [ ] 确认文档不宣称真实 FEMLite 联合运行。 -- [ ] 确认文档不宣称连续体耦合。 -- [ ] 确认文档不宣称工程级船舱破坏 benchmark。 -- [ ] 准备 0.8.0 发布提交说明。 -- [ ] 准备阶段 G 本地提交说明。 +- [x] 设计 Solid mock contact coupling smoke 样例。 +- [x] 设计 Shell mock contact coupling smoke 样例。 +- [x] 设计 Solid/Shell 混合 coupling smoke 样例。 +- [x] 设计 disabled coupling region smoke 样例。 +- [x] 设计 no-active coupling region smoke 样例。 +- [x] 设计 stale load 或重复导入 smoke 样例。 +- [x] 新增 Solid mock contact coupling 输入文件。 +- [x] 新增 Shell mock contact coupling 输入文件。 +- [x] 新增 Solid/Shell 混合 coupling 输入文件。 +- [x] 新增 disabled coupling region 输入文件。 +- [x] 新增 no-active coupling region 输入文件。 +- [x] 新增 stale load 或重复导入输入文件。 +- [x] 验证 smoke 中所有粒子状态保持有限。 +- [x] 验证 smoke 中 coupling 外部力方向受控。 +- [x] 验证 smoke 中 coupling 运动边界方向受控。 +- [x] 验证 smoke 中 Solid 响应方向受控。 +- [x] 验证 smoke 中 Shell 平动响应方向受控。 +- [x] 验证 smoke 中冲量和做功诊断有限。 +- [x] 验证 smoke 中动量和能量交换诊断有限。 +- [x] 验证 disabled region 不产生 coupling 响应。 +- [x] 验证 no-active region 不产生 coupling 响应。 +- [x] 验证 stale load 诊断按预期变化。 +- [x] 新增 `coupling_smoke_080` 测试。 +- [x] 新增 `coupling_source_size_080` 测试。 +- [x] 将阶段 G 新测试接入 CTest。 +- [x] 运行 0.8.0 coupling 专项 gate。 +- [x] 运行 Water 回归 gate。 +- [x] 运行 Gas 回归 gate。 +- [x] 运行 Explosive 回归 gate。 +- [x] 运行 Solid 回归 gate。 +- [x] 运行 Shell 回归 gate。 +- [x] 运行 0.7.0 blast 回归 gate。 +- [x] 运行 0.7.1 blast 专项 gate。 +- [x] 运行完整 CTest。 +- [x] 运行 source size 相关 gate。 +- [x] 运行 `git diff --check`。 +- [x] 检查代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖。 +- [x] 检查输出目录、CSV、VTK、restart 和临时结果未被提交。 +- [x] 更新 README 的 0.8.0 当前状态和不交付范围。 +- [x] 更新 `docs/06_test_and_verification_plan.md` 的 0.8.0 release gate。 +- [x] 更新 `docs/09_release_history.md` 的 0.8.0 本地验收记录。 +- [x] 更新 `docs/11_benchmark_matrix.md` 的 0.8.0 gate 矩阵。 +- [x] 确认文档不宣称真实 FEMLite 联合运行。 +- [x] 确认文档不宣称连续体耦合。 +- [x] 确认文档不宣称工程级船舱破坏 benchmark。 +- [x] 准备 0.8.0 发布提交说明。 +- [x] 准备阶段 G 本地提交说明。 diff --git a/tools/testing/test_python_debug.py b/tools/testing/test_python_debug.py index 668d9df..3fbc7d6 100644 --- a/tools/testing/test_python_debug.py +++ b/tools/testing/test_python_debug.py @@ -7,6 +7,11 @@ from pathlib import Path def write_state_050_compat(source: Path, target: Path, npart: int) -> None: lines = source.read_text(encoding="utf-8").splitlines() + coupling_start = next( + (index for index, line in enumerate(lines) if line.strip() == "SPHLITE_COUPLING_STATE"), + len(lines), + ) + lines = lines[:coupling_start] solid_material_count = 1 solid_051_lines = 1 + 6 * solid_material_count + 8 + 9 * npart solid_start = len(lines) - solid_051_lines