diff --git a/CMakeLists.txt b/CMakeLists.txt index 46bf8bd..4a1b3ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -394,6 +394,12 @@ set_target_properties(test_coupling_smoke_080 PROPERTIES Fortran_MODULE_DIRECTOR 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_coupling_smoke_081 tests/module/test_coupling_smoke_081.f90) +target_link_libraries(test_coupling_smoke_081 PRIVATE sphlite_core) +set_target_properties(test_coupling_smoke_081 PROPERTIES Fortran_MODULE_DIRECTORY "${SPHLITE_MODULE_DIR}") +add_test(NAME coupling_smoke_081 COMMAND test_coupling_smoke_081) +set_tests_properties(coupling_smoke_081 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}") @@ -1347,3 +1353,12 @@ add_test( --exceptions "${CMAKE_CURRENT_SOURCE_DIR}/tests/source_size_exceptions.txt" ) set_tests_properties(coupling_source_size_080 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + +add_test( + NAME coupling_source_size_081 + 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_081 PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/README.md b/README.md index a38b9a9..92e30d3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ SPHLite 是一个面向船舶水下接触爆炸的轻量级 SPH 多物理仿真软件。项目目标是支持水、爆炸产物气体、实体结构粒子、板壳结构粒子、破裂损伤,以及通过外部耦合模块与 FEMLite 进行接触和连续体耦合。 -当前开发版本:0.8.1。该版本定位为 SPHLite 侧中立接触耦合接口稳定化版,在 0.8.0 已发布接口基础上推进 facet pressure/traction/resultant 导入、受控载荷分配、接触状态诊断、输出、restart、接口和 mock coupling gate。不交付真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合、生产级接触算法或工程级水下接触爆炸破坏 benchmark。 +当前开发版本:0.8.1。该版本定位为 SPHLite 侧中立接触耦合接口稳定化版,在 0.8.0 已发布接口基础上追加 facet pressure/traction/resultant 导入、受控载荷分配、接触状态诊断、输出、restart、接口和 mock coupling gate。本地发布准备 gate 已通过;不交付真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合、生产级接触算法或工程级水下接触爆炸破坏 benchmark。 代码仓库地址: @@ -104,5 +104,7 @@ SPHLite 的编译和测试要求应与 FEMLite 保持一致风格: - 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。 -- 0.8.1 将在 0.8.0 数据契约上追加 pressure、traction、facet resultant、载荷分配、接触状态、载荷守恒诊断和 0.8.1 mock coupling gate。 +- 0.8.1 在 0.8.0 数据契约上追加 pressure、traction、facet resultant、载荷分配、接触状态、载荷守恒诊断、输出/restart 字段、Fortran/C/C++/Python/CLI 接口加固和 0.8.1 mock coupling gate。 +- 0.8.1 本地发布准备 gate 已通过:完整 CTest 189/189,0.8.1 coupling 专项 gate 26/26,0.8.0 coupling 回归 gate 24/24,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、29/29、33/33、14/14,0.7.0 blast 回归 gate 15/15,0.7.1 blast 专项 gate 11/11,source size 相关 gate 9/9,`git diff --check` 通过。 +- 0.8.1 检查确认代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖,输出目录、CSV、VTK、restart 和临时结果未进入待提交清单。 - 0.8.1 仍不直接依赖 FEMLite,不实现外部 CouplingModule,不交付连续体耦合,不宣称工程级船舶水下接触爆炸破坏 benchmark。 diff --git a/docs/06_test_and_verification_plan.md b/docs/06_test_and_verification_plan.md index 24ab0a6..bb1a1d8 100644 --- a/docs/06_test_and_verification_plan.md +++ b/docs/06_test_and_verification_plan.md @@ -442,6 +442,53 @@ git diff --check 0.8.0 不验收真实 FEMLite 联合运行,不验收外部 CouplingModule/CoupleLite/CoupledLite/CouplingLite,不验收连续体一部分 FEM 一部分 SPH 的生产级连续体耦合,不验收工程级船舶水下接触爆炸舱段破坏 benchmark,不验收复杂接触搜索、真实接触约束求解、大规模并行或 GPU 后端。 +## 7.11 0.8.1 Release Gate + +0.8.1 默认 gate 在 0.8.0 中立接触耦合接口基础上做稳定化。该 gate 只验收 SPHLite 侧小型、可重复 mock coupling 链路、载荷分配、接触诊断、输出、restart 和接口契约,不验收真实 FEMLite 联合运行、外部 CouplingModule/CoupleLite/CoupledLite/CouplingLite、连续体耦合或工程级船舶水下接触爆炸破坏 benchmark。 + +0.8.1 coupling 专项测试: + +- `input_coupling_load_mode_081` +- `input_coupling_load_errors_081` +- `coupling_contact_state_081` +- `coupling_facet_pressure_081` +- `coupling_facet_traction_081` +- `coupling_facet_resultant_081` +- `coupling_distribution_uniform_081` +- `coupling_distribution_area_081` +- `coupling_distribution_mass_081` +- `coupling_load_balance_081` +- `coupling_contact_diagnostics_081` +- `coupling_solver_order_081` +- `coupling_stale_epoch_081` +- `coupling_solid_surface_pressure_081` +- `coupling_shell_pressure_081` +- `coupling_mixed_pressure_motion_081` +- `coupling_output_081` +- `coupling_restart_081` +- `coupling_restart_080_compat` +- `coupling_fortran_api_081` +- `coupling_c_api_081` +- `coupling_cpp_api_081` +- `coupling_python_081` +- `coupling_cli_081` +- `coupling_smoke_081` +- `coupling_source_size_081` + +0.8.1 本地 release gate: + +```powershell +cmake --build build-codex-unix --parallel +ctest --test-dir build-codex-unix -R "^(input_coupling_load_mode_081|input_coupling_load_errors_081|coupling_contact_state_081|coupling_facet_pressure_081|coupling_facet_traction_081|coupling_facet_resultant_081|coupling_distribution_uniform_081|coupling_distribution_area_081|coupling_distribution_mass_081|coupling_load_balance_081|coupling_contact_diagnostics_081|coupling_solver_order_081|coupling_stale_epoch_081|coupling_solid_surface_pressure_081|coupling_shell_pressure_081|coupling_mixed_pressure_motion_081|coupling_output_081|coupling_restart_081|coupling_restart_080_compat|coupling_fortran_api_081|coupling_c_api_081|coupling_cpp_api_081|coupling_python_081|coupling_cli_081|coupling_smoke_081|coupling_source_size_081)$" --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|coupling_source_size_081)$" --output-on-failure +git diff --check +``` + +2026-07-04 本地结果:完整 CTest 189/189 通过,0.8.1 coupling 专项 gate 26/26 通过,0.8.0 coupling 回归 gate 24/24 通过,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、29/29、33/33、14/14 通过,0.7.0 blast 回归 gate 15/15 通过,0.7.1 blast 专项 gate 11/11 通过,source size 相关 gate 9/9 通过,`git diff --check` 通过。代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖,输出目录、CSV、VTK、restart 和临时结果未进入待提交清单。 + +0.8.1 不验收真实 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 aa46c2e..b3239c9 100644 --- a/docs/09_release_history.md +++ b/docs/09_release_history.md @@ -1,10 +1,10 @@ # 09 版本历史与验收记录 -文档状态:0.8.0 发布记录 +文档状态:0.8.1 本地验收记录 ## 1. 当前状态 -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。 +SPHLite 当前发布版本为 0.8.0 中立接触耦合接口起步版本;当前本地验收版本为 0.8.1 接触耦合接口稳定化版本。0.8.1 在 0.8.0 基础上追加 facet pressure/traction/resultant 导入、受控载荷分配、接触状态诊断、输出、restart、接口和 mock coupling gate。0.8.1 不交付真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合、生产级接触算法或工程级水下接触爆炸舱段破坏 benchmark。 ## 2. 规划版本线 @@ -625,6 +625,51 @@ cmake --build build-codex-unix 发布记录: - 0.8.0 已于 2026-07-04 完成本地发布 gate,并准备标记 `v0.8.0`。 +### 0.8.1 本地验收记录 + +记录日期:2026-07-04 + +本地构建目录:`build-codex-unix` + +版本定位: +- 0.8.1 是 SPHLite 侧中立接触耦合接口稳定化版本。 +- 0.8.1 在 0.8.0 coupling region、粒子/Facet Proxy 导出、外部载荷/运动边界导入和 diagnostics 基础上,新增 `LOAD_MODE=PRESSURE`、`LOAD_MODE=TRACTION`、facet resultant、`DISTRIBUTION=UNIFORM/AREA/MASS` 和 `CONTACT_STATE=IMPORT` 的稳定化测试。 +- 0.8.1 新增 contact flag、normal、gap、penetration、contact pressure 缓存,以及 active/skipped contact、stale/repeated/nonfinite/bad area/invalid weight、最大 pressure/traction/penetration 和载荷守恒诊断。 +- 0.8.1 将新增 contact 和载荷守恒字段写入 summary CSV、粒子 CSV 和 `STATE_0_8_1` restart,并兼容读入 `STATE_0_8` coupling restart 后初始化 0.8.1 新增状态。 +- 0.8.1 追加 Fortran API、C ABI、C++ wrapper、Python ctypes 和 CLI inspect 的 pressure、traction、contact state、load balance 和 contact diagnostics 入口。 +- 0.8.1 新增 `coupling_smoke_081`,覆盖 Solid 等效 surface pressure、Shell pressure、traction、pressure-motion 混合和 stale epoch mock coupling 样例。 + +验收结果: +- `cmake --build build-codex-unix --parallel` 通过。 +- `ctest --test-dir build-codex-unix --output-on-failure` 通过:189/189。 +- 0.8.1 coupling 专项 gate 通过:26/26。 +- 0.8.0 coupling 回归 gate 通过:24/24。 +- Water/Gas/Explosive/Solid/Shell 分类 gate 通过:6/6、19/19、29/29、33/33、14/14。 +- 0.7.0 blast 回归 gate 通过:15/15。 +- 0.7.1 blast 专项 gate 通过:11/11。 +- source size 相关 gate 通过:9/9。 +- `git diff --check` 通过。 +- 代码、构建脚本、测试和工具目录未新增 FEMLite 直接依赖。 +- 输出目录、CSV、VTK、restart 和临时结果未进入待提交清单。 + +不交付范围: +- 0.8.1 不交付真实 FEMLite 联合运行。 +- 0.8.1 不交付外部 CouplingModule、CoupleLite、CoupledLite 或 CouplingLite。 +- 0.8.1 不交付连续体一部分 FEM 一部分 SPH 的生产级连续体耦合。 +- 0.8.1 不交付生产级接触搜索、接触约束、摩擦、接触稳定化或工程接触参数库。 +- 0.8.1 不交付工程级船舶水下接触爆炸舱段破坏 benchmark。 +- 0.8.1 不交付复杂撕裂、穿孔、碎片云、焊缝失效库、大规模并行或 GPU 后端。 + +已知限制: +- Solid surface pressure smoke 当前使用等效粒子力验证 Solid 受压方向响应,不表示 0.8.1 已实现 Solid 实体表面 facet pressure 重构。 +- Shell Facet Proxy 当前仍是 Shell 粒子级中立代理,不等价于真实外表面重构。 +- Mock coupling smoke 只验证 SPHLite 侧接口链路和受控响应,不代表真实外部耦合模块。 +- Source size 中对 0.8.1 相关接口层、restart、输出、测试和 CouplingInterface 主文件继续通过 source size gate 约束;后续版本应继续拆分 owner 文件。 + +发布建议: +- 0.8.1 可以作为 SPHLite 侧中立接触耦合接口稳定化版本进入发布准备。 +- 0.8.1 发布后,后续主线可进入 0.8.2 接口清理/错误路径加固,或进入 0.9.0 连续体耦合需求拆分,但不应在 0.8.1 内宣称真实 FEMLite 联合运行。 + 后续每个版本应记录: - 完成能力。 diff --git a/docs/11_benchmark_matrix.md b/docs/11_benchmark_matrix.md index 098a835..8fb7ec3 100644 --- a/docs/11_benchmark_matrix.md +++ b/docs/11_benchmark_matrix.md @@ -1,10 +1,10 @@ # 11 Benchmark 与验收矩阵 -文档状态:0.8.0 gate 记录 +文档状态:0.8.1 gate 记录 ## 1. 当前状态 -0.8.0 在 0.7.1 局部爆炸稳定化 gate 基础上新增 SPHLite 侧中立接触耦合接口 gate,覆盖 coupling region、粒子/Facet Proxy 导出、外部载荷/运动边界导入、显式步响应、diagnostics、restart、接口层和 mock coupling smoke。0.8.0 仍不作为真实 FEMLite 联合运行、连续体耦合或工程级水下接触爆炸 benchmark。 +0.8.1 在 0.8.0 SPHLite 侧中立接触耦合接口 gate 基础上加固 facet pressure/traction/resultant、受控载荷分配、contact state、载荷守恒诊断、输出、restart、接口层和 mock coupling smoke。0.8.1 仍不作为真实 FEMLite 联合运行、连续体耦合或工程级水下接触爆炸 benchmark。 ## 2. 0.1.0 Release Gate @@ -471,6 +471,46 @@ |---|---|---| | 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` 通过 | +## 2.16 0.8.1 Release Gate + +0.8.1 默认 gate 在 0.8.0 中立接触耦合接口之上稳定载荷模式、分配策略、接触诊断和接口层。该 gate 只验收 SPHLite 侧小型 mock coupling 链路和接口契约,不验收真实 FEMLite 联合运行、外部 CouplingModule、连续体耦合或工程级船舶水下接触爆炸破坏 benchmark。 + +| 测试名 | 类型 | 验收点 | +|---|---|---| +| `input_coupling_load_mode_081` | Fortran input | `LOAD_MODE`、`DISTRIBUTION`、`CONTACT_STATE` 输入解析和兼容默认值 | +| `input_coupling_load_errors_081` | Fortran input | 非法 load mode、distribution、contact state 和 pressure/traction 缺少 facet proxy 错误 | +| `coupling_contact_state_081` | Fortran API | contact flag、normal、gap、penetration 和 contact pressure 缓存分配/清零 | +| `coupling_facet_pressure_081` | Fortran API | pressure 到 facet 合力和粒子力的方向、面积权重与最大 pressure 诊断 | +| `coupling_facet_traction_081` | Fortran API | traction 到粒子力的映射、质量权重和最大 traction 诊断 | +| `coupling_facet_resultant_081` | Fortran API | facet resultant 直接导入和分配 | +| `coupling_distribution_uniform_081` | Fortran API | uniform 分配策略 | +| `coupling_distribution_area_081` | Fortran API | area 分配策略和面积诊断 | +| `coupling_distribution_mass_081` | Fortran API | mass 分配策略和非法权重诊断 | +| `coupling_load_balance_081` | Fortran diagnostics | 输入/分配总力、力矩和误差有限性 | +| `coupling_contact_diagnostics_081` | Fortran diagnostics | active/skipped contact、最大 penetration、nonfinite 诊断 | +| `coupling_solver_order_081` | Fortran solver | pressure/traction/resultant 与 blast/coupling 外载荷显式步序 | +| `coupling_stale_epoch_081` | Fortran diagnostics | stale epoch 清理、重复导入和缓存清空 | +| `coupling_solid_surface_pressure_081` | Fortran smoke | Solid 等效 surface pressure 粒子力响应方向 | +| `coupling_shell_pressure_081` | Fortran smoke | Shell facet pressure 平动响应方向 | +| `coupling_mixed_pressure_motion_081` | Fortran smoke | pressure 与 direct motion boundary 混合优先级 | +| `coupling_output_081` | Fortran output | summary CSV 和 particle CSV 0.8.1 contact/载荷字段 | +| `coupling_restart_081` | Fortran restart | `STATE_0_8_1` 写入、读回和继续显式步 | +| `coupling_restart_080_compat` | Fortran restart | `STATE_0_8` 兼容读入后初始化 0.8.1 新增状态 | +| `coupling_fortran_api_081` | Fortran API | pressure、traction、resultant、contact state、load balance 和 diagnostics 入口 | +| `coupling_c_api_081` | C ABI | C 层 pressure/traction/contact diagnostics 入口和错误路径 | +| `coupling_cpp_api_081` | C++ wrapper | C++ 薄包装 pressure、traction 和 diagnostics | +| `coupling_python_081` | Python ctypes | Python debug wrapper 0.8.1 coupling 字段 | +| `coupling_cli_081` | CLI | inspect 输出 load mode、distribution 和 contact diagnostics | +| `coupling_smoke_081` | Fortran smoke | Solid 等效受压、Shell pressure、traction、pressure-motion 和 stale epoch mock 样例 | +| `coupling_source_size_081` | 工具门禁 | 0.8.1 source size 和 stale exception 检查 | + +0.8.1 不验收真实 FEMLite 联合运行、外部 CouplingModule、连续体一部分 FEM 一部分 SPH 的生产级连续体耦合、工程级接触算法、工程级船舶水下接触爆炸破坏 benchmark、复杂撕裂/穿孔/碎片云、焊缝失效库、大规模并行或 GPU 后端。 + +本地验收记录: +| 日期 | 构建目录 | 结果 | +|---|---|---| +| 2026-07-04 | `build-codex-unix` | 完整 CTest 189/189 通过,0.8.1 coupling 专项 gate 26/26 通过,0.8.0 coupling 回归 gate 24/24 通过,Water/Gas/Explosive/Solid/Shell 分类 gate 6/6、19/19、29/29、33/33、14/14 通过,0.7.0 blast 回归 gate 15/15 通过,0.7.1 blast 专项 gate 11/11 通过,source size 相关 gate 9/9 通过,`git diff --check` 通过 | + ## 3. 基础数值矩阵 | 领域 | 测试或 benchmark | 验收点 | diff --git a/src/database/sph_database.f90 b/src/database/sph_database.f90 index 4b0a875..130e9d4 100644 --- a/src/database/sph_database.f90 +++ b/src/database/sph_database.f90 @@ -855,27 +855,54 @@ contains return end if coupling_region_count = coupling_region_count + 1 - coupling_region_name(coupling_region_count) = name - coupling_region_set_name(coupling_region_count) = set_name - coupling_region_surface_name(coupling_region_count) = surface_name - coupling_region_material_name(coupling_region_count) = material_filter_name - coupling_region_section_name(coupling_region_count) = section_filter_name - coupling_region_type(coupling_region_count) = region_type - coupling_region_export_mode(coupling_region_count) = export_mode - coupling_region_import_mode(coupling_region_count) = import_mode - coupling_region_load_mode(coupling_region_count) = load_mode - coupling_region_distribution_mode(coupling_region_count) = distribution_mode - coupling_region_contact_state_mode(coupling_region_count) = contact_state_mode - coupling_region_enabled(coupling_region_count) = 0 - if (enabled) coupling_region_enabled(coupling_region_count) = 1 - coupling_region_phase_filter(coupling_region_count) = phase_filter - coupling_region_material_filter(coupling_region_count) = mat_index - coupling_region_section_filter(coupling_region_count) = sec_index - coupling_region_internal_id(coupling_region_count) = coupling_region_count - coupling_region_particle_count(coupling_region_count) = 0 - coupling_region_particles(:,coupling_region_count) = 0 + call sph_db_store_coupling_region(coupling_region_count, name, set_name, & + region_type, export_mode, import_mode, load_mode, distribution_mode, & + contact_state_mode, enabled, surface_name, phase_filter, & + material_filter_name, section_filter_name, mat_index, sec_index) end subroutine sph_db_add_coupling_region + subroutine sph_db_store_coupling_region(region, name, set_name, region_type, & + export_mode, import_mode, load_mode, distribution_mode, contact_state_mode, & + enabled, surface_name, phase_filter, material_filter_name, & + section_filter_name, mat_index, sec_index) + integer, intent(in) :: region + character(len=*), intent(in) :: name + character(len=*), intent(in) :: set_name + integer, intent(in) :: region_type + integer, intent(in) :: export_mode + integer, intent(in) :: import_mode + integer, intent(in) :: load_mode + integer, intent(in) :: distribution_mode + integer, intent(in) :: contact_state_mode + logical, intent(in) :: enabled + character(len=*), intent(in) :: surface_name + integer, intent(in) :: phase_filter + character(len=*), intent(in) :: material_filter_name + character(len=*), intent(in) :: section_filter_name + integer, intent(in) :: mat_index + integer, intent(in) :: sec_index + + coupling_region_name(region) = name + coupling_region_set_name(region) = set_name + coupling_region_surface_name(region) = surface_name + coupling_region_material_name(region) = material_filter_name + coupling_region_section_name(region) = section_filter_name + coupling_region_type(region) = region_type + coupling_region_export_mode(region) = export_mode + coupling_region_import_mode(region) = import_mode + coupling_region_load_mode(region) = load_mode + coupling_region_distribution_mode(region) = distribution_mode + coupling_region_contact_state_mode(region) = contact_state_mode + coupling_region_enabled(region) = 0 + if (enabled) coupling_region_enabled(region) = 1 + coupling_region_phase_filter(region) = phase_filter + coupling_region_material_filter(region) = mat_index + coupling_region_section_filter(region) = sec_index + coupling_region_internal_id(region) = region + coupling_region_particle_count(region) = 0 + coupling_region_particles(:,region) = 0 + end subroutine sph_db_store_coupling_region + subroutine sph_db_build_coupling_regions(ierr) integer, intent(out) :: ierr integer :: region diff --git a/src/input/sph_input_reader.f90 b/src/input/sph_input_reader.f90 index 3e99b53..a2780c0 100644 --- a/src/input/sph_input_reader.f90 +++ b/src/input/sph_input_reader.f90 @@ -1127,9 +1127,6 @@ contains character(len=SPH_INPUT_FIELD_LEN) :: section_name character(len=SPH_INPUT_FIELD_LEN) :: export_name character(len=SPH_INPUT_FIELD_LEN) :: import_name - character(len=SPH_INPUT_FIELD_LEN) :: load_mode_name - character(len=SPH_INPUT_FIELD_LEN) :: distribution_name - character(len=SPH_INPUT_FIELD_LEN) :: contact_state_name character(len=SPH_INPUT_FIELD_LEN) :: enabled_name integer :: region_type integer :: export_mode @@ -1188,32 +1185,9 @@ contains if (ierr /= SPH_SUCCESS) return end if - if (import_mode == SPH_COUPLING_IMPORT_FACET_LOAD) then - load_mode = SPH_COUPLING_LOAD_FACET_FORCE - else - load_mode = SPH_COUPLING_LOAD_PARTICLE_FORCE - end if - call sph_input_get_option(line, 'LOAD_MODE', load_mode_name) - if (len_trim(load_mode_name) > 0) then - call sph_input_parse_coupling_load_mode(load_mode_name, load_mode, ierr) - if (ierr /= SPH_SUCCESS) return - end if - - distribution_mode = SPH_COUPLING_DISTRIBUTION_UNIFORM - call sph_input_get_option(line, 'DISTRIBUTION', distribution_name) - if (len_trim(distribution_name) > 0) then - call sph_input_parse_coupling_distribution(distribution_name, & - distribution_mode, ierr) - if (ierr /= SPH_SUCCESS) return - end if - - contact_state_mode = SPH_COUPLING_CONTACT_STATE_NONE - call sph_input_get_option(line, 'CONTACT_STATE', contact_state_name) - if (len_trim(contact_state_name) > 0) then - call sph_input_parse_coupling_contact_state(contact_state_name, & - contact_state_mode, ierr) - if (ierr /= SPH_SUCCESS) return - end if + call sph_input_parse_coupling_modes(line, import_mode, load_mode, & + distribution_mode, contact_state_mode, ierr) + if (ierr /= SPH_SUCCESS) return enabled = .true. call sph_input_get_option(line, 'ENABLED', enabled_name) @@ -1263,6 +1237,46 @@ contains material_name, section_name, ierr) end subroutine sph_input_parse_coupling_region + subroutine sph_input_parse_coupling_modes(line, import_mode, load_mode, & + distribution_mode, contact_state_mode, ierr) + character(len=*), intent(in) :: line + integer, intent(in) :: import_mode + integer, intent(out) :: load_mode + integer, intent(out) :: distribution_mode + integer, intent(out) :: contact_state_mode + integer, intent(out) :: ierr + character(len=SPH_INPUT_FIELD_LEN) :: load_mode_name + character(len=SPH_INPUT_FIELD_LEN) :: distribution_name + character(len=SPH_INPUT_FIELD_LEN) :: contact_state_name + + ierr = SPH_SUCCESS + if (import_mode == SPH_COUPLING_IMPORT_FACET_LOAD) then + load_mode = SPH_COUPLING_LOAD_FACET_FORCE + else + load_mode = SPH_COUPLING_LOAD_PARTICLE_FORCE + end if + call sph_input_get_option(line, 'LOAD_MODE', load_mode_name) + if (len_trim(load_mode_name) > 0) then + call sph_input_parse_coupling_load_mode(load_mode_name, load_mode, ierr) + if (ierr /= SPH_SUCCESS) return + end if + + distribution_mode = SPH_COUPLING_DISTRIBUTION_UNIFORM + call sph_input_get_option(line, 'DISTRIBUTION', distribution_name) + if (len_trim(distribution_name) > 0) then + call sph_input_parse_coupling_distribution(distribution_name, & + distribution_mode, ierr) + if (ierr /= SPH_SUCCESS) return + end if + + contact_state_mode = SPH_COUPLING_CONTACT_STATE_NONE + call sph_input_get_option(line, 'CONTACT_STATE', contact_state_name) + if (len_trim(contact_state_name) > 0) then + call sph_input_parse_coupling_contact_state(contact_state_name, & + contact_state_mode, ierr) + end if + end subroutine sph_input_parse_coupling_modes + subroutine sph_input_parse_coupling_export(text, mode, ierr) character(len=*), intent(in) :: text integer, intent(out) :: mode diff --git a/tests/data/coupling_mock_pressure_motion_081.inp b/tests/data/coupling_mock_pressure_motion_081.inp new file mode 100644 index 0000000..b3b8b02 --- /dev/null +++ b/tests/data/coupling_mock_pressure_motion_081.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_MIXED_TARGET +1, 2, 3 +*MATERIAL, NAME=SHELL_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_MIXED_TARGET, MATERIAL=SHELL_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SPHLITE SHELL DIRECTOR, SET=SHELL_MIXED_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=PRESSURE_MOTION_PRESSURE, SET=SHELL_MIXED_TARGET, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, LOAD_MODE=PRESSURE, DISTRIBUTION=AREA, CONTACT_STATE=IMPORT, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_MIXED_TARGET, SURFACE=SHELL_MIXED_PRESSURE_SURFACE +*SPHLITE COUPLING REGION, NAME=PRESSURE_MOTION_BOUNDARY, SET=SHELL_MIXED_TARGET, TYPE=CONTACT, EXPORT=BOTH, IMPORT=MOTION, LOAD_MODE=PARTICLE_FORCE, DISTRIBUTION=UNIFORM, CONTACT_STATE=OFF, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_MIXED_TARGET, SURFACE=SHELL_MIXED_MOTION_SURFACE diff --git a/tests/data/coupling_mock_shell_pressure_081.inp b/tests/data/coupling_mock_shell_pressure_081.inp new file mode 100644 index 0000000..d487e85 --- /dev/null +++ b/tests/data/coupling_mock_shell_pressure_081.inp @@ -0,0 +1,20 @@ +*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_PRESSURE_TARGET +1, 2, 3 +*MATERIAL, NAME=SHELL_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_PRESSURE_TARGET, MATERIAL=SHELL_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SPHLITE SHELL DIRECTOR, SET=SHELL_PRESSURE_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_PRESSURE_MOCK, SET=SHELL_PRESSURE_TARGET, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, LOAD_MODE=PRESSURE, DISTRIBUTION=AREA, CONTACT_STATE=IMPORT, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_PRESSURE_TARGET, SURFACE=SHELL_PRESSURE_MOCK_SURFACE diff --git a/tests/data/coupling_mock_solid_surface_pressure_081.inp b/tests/data/coupling_mock_solid_surface_pressure_081.inp new file mode 100644 index 0000000..18a79a4 --- /dev/null +++ b/tests/data/coupling_mock_solid_surface_pressure_081.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_PRESSURE_TARGET +1, 2 +*MATERIAL, NAME=STEEL_SOLID, TYPE=SOLID +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SOLID SECTION, ELSET=SOLID_PRESSURE_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_SURFACE_PRESSURE_MOCK, SET=SOLID_PRESSURE_TARGET, TYPE=CONTACT, EXPORT=PARTICLE, IMPORT=FORCE, LOAD_MODE=PARTICLE_FORCE, DISTRIBUTION=UNIFORM, CONTACT_STATE=OFF, ENABLED=YES, PHASE=SOLID, MATERIAL=STEEL_SOLID, SECTION=SOLID_PRESSURE_TARGET diff --git a/tests/data/coupling_mock_stale_epoch_081.inp b/tests/data/coupling_mock_stale_epoch_081.inp new file mode 100644 index 0000000..4393d14 --- /dev/null +++ b/tests/data/coupling_mock_stale_epoch_081.inp @@ -0,0 +1,20 @@ +*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_STALE_TARGET +1, 2, 3 +*MATERIAL, NAME=SHELL_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_STALE_TARGET, MATERIAL=SHELL_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SPHLITE SHELL DIRECTOR, SET=SHELL_STALE_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=STALE_PRESSURE_MOCK, SET=SHELL_STALE_TARGET, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, LOAD_MODE=PRESSURE, DISTRIBUTION=AREA, CONTACT_STATE=IMPORT, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_STALE_TARGET, SURFACE=SHELL_STALE_MOCK_SURFACE diff --git a/tests/data/coupling_mock_traction_081.inp b/tests/data/coupling_mock_traction_081.inp new file mode 100644 index 0000000..d0f50b1 --- /dev/null +++ b/tests/data/coupling_mock_traction_081.inp @@ -0,0 +1,20 @@ +*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_TRACTION_TARGET +1, 2, 3 +*MATERIAL, NAME=SHELL_STEEL, TYPE=SHELL +*DENSITY +7850.0 +*ELASTIC +210.0E9, 0.30 +*SHELL SECTION, ELSET=SHELL_TRACTION_TARGET, MATERIAL=SHELL_STEEL, THICKNESS=0.010, POINTS=3, SHEAR_CORRECTION=0.8333333333 +*SPHLITE SHELL DIRECTOR, SET=SHELL_TRACTION_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_TRACTION_MOCK, SET=SHELL_TRACTION_TARGET, TYPE=CONTACT, EXPORT=FACET, IMPORT=FACET_LOAD, LOAD_MODE=TRACTION, DISTRIBUTION=MASS, CONTACT_STATE=OFF, ENABLED=YES, PHASE=SHELL, MATERIAL=SHELL_STEEL, SECTION=SHELL_TRACTION_TARGET, SURFACE=SHELL_TRACTION_MOCK_SURFACE diff --git a/tests/module/test_blast_output.f90 b/tests/module/test_blast_output.f90 index 194bd2e..08e1200 100644 --- a/tests/module/test_blast_output.f90 +++ b/tests/module/test_blast_output.f90 @@ -78,6 +78,7 @@ contains integer :: failure integer :: reference_neighbors integer :: correction_status + integer :: coupling_contact_flag integer :: coupling_motion_flag integer :: coupling_region_id real(rk) :: pos(3) @@ -87,10 +88,12 @@ contains real(rk) :: stress_values(6) real(rk) :: solid_values(5) real(rk) :: coupling_force(3) + real(rk) :: coupling_contact_values(2) read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, & scalar_values, explosive_values, stress_values, solid_values, & - blast_values, coupling_force, failure, reference_neighbors, & + blast_values, coupling_force, coupling_contact_values, & + coupling_contact_flag, failure, reference_neighbors, & correction_status, coupling_motion_flag, coupling_region_id end subroutine read_particle_row diff --git a/tests/module/test_blast_output_071.f90 b/tests/module/test_blast_output_071.f90 index 0d4f059..e7f4de5 100644 --- a/tests/module/test_blast_output_071.f90 +++ b/tests/module/test_blast_output_071.f90 @@ -117,6 +117,7 @@ contains integer :: failure integer :: reference_neighbors integer :: correction_status + integer :: coupling_contact_flag integer :: coupling_motion_flag integer :: coupling_region_id real(rk) :: pos(3) @@ -126,10 +127,12 @@ contains real(rk) :: stress_values(6) real(rk) :: solid_values(5) real(rk) :: coupling_force(3) + real(rk) :: coupling_contact_values(2) read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, & scalar_values, explosive_values, stress_values, solid_values, & - blast_values, coupling_force, failure, reference_neighbors, & + blast_values, coupling_force, coupling_contact_values, & + coupling_contact_flag, failure, reference_neighbors, & correction_status, coupling_motion_flag, coupling_region_id end subroutine read_particle_row diff --git a/tests/module/test_blast_restart_boundary.f90 b/tests/module/test_blast_restart_boundary.f90 index efa0788..120855f 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_8') call fail('Blast restart boundary state mismatch') + if (trim(state) /= 'STATE_0_8_1') 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 79d4593..67d6ea4 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_8') call fail('0.7.1 Blast restart boundary state mismatch') + if (trim(state) /= 'STATE_0_8_1') 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_smoke_081.f90 b/tests/module/test_coupling_smoke_081.f90 new file mode 100644 index 0000000..a121761 --- /dev/null +++ b/tests/module/test_coupling_smoke_081.f90 @@ -0,0 +1,311 @@ +program test_coupling_smoke_081 + 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, SPH_COUPLING_DISTRIBUTION_AREA, & + SPH_COUPLING_DISTRIBUTION_MASS + use sph_coupling_interface, only: SPH_COUPLING_MOTION_DIRECT, & + SPH_COUPLING_MOTION_VELOCITY, coupling_max_pressure, & + coupling_max_traction, sph_coupling_apply_particle_forces, & + sph_coupling_apply_facet_pressures, & + sph_coupling_apply_facet_tractions, sph_coupling_apply_contact_state, & + sph_coupling_apply_motion_boundary, sph_coupling_clear_imports, & + sph_coupling_get_load_balance, sph_coupling_get_contact_diagnostics + implicit none + + integer :: ierr + + call check_solid_surface_pressure() + call check_shell_pressure() + call check_shell_traction() + call check_pressure_motion() + call check_stale_epoch() + +contains + + subroutine check_solid_surface_pressure() + integer :: ids(1) + real(rk) :: forces(SPH_NDIM,1) + real(rk) :: pressure_value + real(rk) :: proxy_area + + call build_case('tests/data/coupling_mock_solid_surface_pressure_081.inp') + ids(1) = 1 + pressure_value = 2.0e5_rk + proxy_area = 1.0e-3_rk + forces(:,1) = (/ 0.0_rk, 0.0_rk, pressure_value * proxy_area /) + call sph_coupling_apply_particle_forces(1, 1, ids, forces, ierr) + call assert_ok(ierr, 'solid pressure mock import failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'solid pressure mock advance failed') + if (v(3,1) <= 0.0_rk) call fail('solid pressure direction mismatch') + call assert_model_finite('solid pressure mock') + call finish_case('solid pressure mock') + end subroutine check_solid_surface_pressure + + subroutine check_shell_pressure() + integer :: ids(3) + integer :: contact_ids(2) + real(rk) :: pressures(3) + real(rk) :: normals(SPH_NDIM,2) + real(rk) :: gaps(2) + real(rk) :: penetrations(2) + real(rk) :: contact_pressures(2) + + call build_case('tests/data/coupling_mock_shell_pressure_081.inp') + ids = (/ 1, 2, 3 /) + pressures = (/ 60.0_rk, 40.0_rk, 20.0_rk /) + call sph_coupling_apply_facet_pressures(1, 3, ids, pressures, & + SPH_COUPLING_DISTRIBUTION_AREA, 811, ierr) + call assert_ok(ierr, 'shell pressure mock import failed') + contact_ids = (/ 1, 2 /) + normals(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /) + normals(:,2) = (/ 0.0_rk, 0.0_rk, 1.0_rk /) + gaps = (/ 1.0e-4_rk, 2.0e-4_rk /) + penetrations = (/ 1.0e-3_rk, 2.0e-3_rk /) + contact_pressures = (/ 6.0_rk, 4.0_rk /) + call sph_coupling_apply_contact_state(1, 2, contact_ids, normals, & + gaps, penetrations, contact_pressures, 811, ierr) + call assert_ok(ierr, 'shell pressure contact import failed') + call assert_load_balance_finite('shell pressure mock') + call assert_contact_count(2, 0, 'shell pressure mock') + if (coupling_max_pressure < 60.0_rk) call fail('max pressure missing') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'shell pressure mock advance failed') + if (v(3,1) <= 0.0_rk .or. v(3,2) <= 0.0_rk) then + call fail('shell pressure direction mismatch') + end if + call assert_model_finite('shell pressure mock') + call finish_case('shell pressure mock') + end subroutine check_shell_pressure + + subroutine check_shell_traction() + integer :: ids(2) + real(rk) :: tractions(SPH_NDIM,2) + + call build_case('tests/data/coupling_mock_traction_081.inp') + ids = (/ 1, 2 /) + tractions(:,1) = (/ 0.0_rk, 120.0_rk, 0.0_rk /) + tractions(:,2) = (/ 0.0_rk, 80.0_rk, 0.0_rk /) + call sph_coupling_apply_facet_tractions(1, 2, ids, tractions, & + SPH_COUPLING_DISTRIBUTION_MASS, 821, ierr) + call assert_ok(ierr, 'traction mock import failed') + call assert_load_balance_finite('traction mock') + if (coupling_max_traction < 120.0_rk) call fail('max traction missing') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'traction mock advance failed') + if (v(2,1) <= 0.0_rk .or. v(2,2) <= 0.0_rk) then + call fail('traction direction mismatch') + end if + call assert_model_finite('traction mock') + call finish_case('traction mock') + end subroutine check_shell_traction + + subroutine check_pressure_motion() + integer :: ids(2) + real(rk) :: pressures(2) + real(rk) :: target_velocity(SPH_NDIM) + + call build_case('tests/data/coupling_mock_pressure_motion_081.inp') + ids = (/ 1, 2 /) + pressures = (/ 50.0_rk, 50.0_rk /) + call sph_coupling_apply_facet_pressures(1, 2, ids, pressures, & + SPH_COUPLING_DISTRIBUTION_AREA, 831, ierr) + call assert_ok(ierr, 'pressure-motion pressure import failed') + target_velocity = (/ 1.25_rk, 0.0_rk, 0.0_rk /) + call sph_coupling_apply_motion_boundary(2, 1, & + SPH_COUPLING_MOTION_VELOCITY, SPH_COUPLING_MOTION_DIRECT, & + target_velocity, ierr) + call assert_ok(ierr, 'pressure-motion boundary import failed') + call sph_advance_explicit(1.0e-7_rk, ierr) + call assert_ok(ierr, 'pressure-motion advance failed') + call assert_vector_close(v(:,1), target_velocity, & + 'motion boundary target mismatch') + if (v(3,2) <= 0.0_rk) call fail('pressure-motion free particle mismatch') + call assert_model_finite('pressure-motion mock') + call finish_case('pressure-motion mock') + end subroutine check_pressure_motion + + subroutine check_stale_epoch() + integer :: ids(1) + real(rk) :: normals(SPH_NDIM,1) + real(rk) :: gaps(1) + real(rk) :: penetrations(1) + real(rk) :: contact_pressures(1) + real(rk) :: pressures(1) + integer :: stale_after_contact + integer :: stale_after_pressure + + call build_case('tests/data/coupling_mock_stale_epoch_081.inp') + ids(1) = 1 + normals(:,1) = (/ 0.0_rk, 0.0_rk, 1.0_rk /) + gaps(1) = 1.0e-4_rk + penetrations(1) = 1.0e-3_rk + contact_pressures(1) = 5.0_rk + call sph_coupling_apply_contact_state(1, 1, ids, normals, gaps, & + penetrations, contact_pressures, 841, ierr) + call assert_ok(ierr, 'stale contact import failed') + call sph_coupling_clear_imports(ierr) + call assert_ok(ierr, 'stale contact clear failed') + call read_stale_count(stale_after_contact, 'stale contact') + if (stale_after_contact <= 0) call fail('stale contact was not counted') + pressures(1) = 30.0_rk + call sph_coupling_apply_facet_pressures(1, 1, ids, pressures, & + SPH_COUPLING_DISTRIBUTION_AREA, 842, ierr) + call assert_ok(ierr, 'stale pressure import failed') + call sph_coupling_clear_imports(ierr) + call assert_ok(ierr, 'stale pressure clear failed') + call read_stale_count(stale_after_pressure, 'stale pressure') + if (stale_after_pressure <= stale_after_contact) then + call fail('stale pressure did not change diagnostics') + end if + call assert_model_finite('stale epoch mock') + call finish_case('stale epoch mock') + end subroutine check_stale_epoch + + 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 assert_load_balance_finite(label) + character(len=*), intent(in) :: label + real(rk) :: input_force(SPH_NDIM) + real(rk) :: distributed_force(SPH_NDIM) + real(rk) :: input_moment(SPH_NDIM) + real(rk) :: distributed_moment(SPH_NDIM) + real(rk) :: force_error + real(rk) :: moment_error + + call sph_coupling_get_load_balance(input_force, distributed_force, & + force_error, input_moment, distributed_moment, moment_error, ierr) + call assert_ok(ierr, trim(label) // ' load balance failed') + call assert_vector_finite(input_force, trim(label) // ' input force bad') + call assert_vector_finite(distributed_force, trim(label) // ' force bad') + call assert_vector_finite(input_moment, trim(label) // ' input moment bad') + call assert_vector_finite(distributed_moment, trim(label) // ' moment bad') + if (.not. scalar_is_finite(force_error)) call fail(trim(label) // ' force error bad') + if (.not. scalar_is_finite(moment_error)) call fail(trim(label) // ' moment error bad') + end subroutine assert_load_balance_finite + + subroutine assert_contact_count(expected_active, expected_skipped, label) + integer, intent(in) :: expected_active + integer, intent(in) :: expected_skipped + character(len=*), intent(in) :: label + integer :: active_count + integer :: skipped_count + integer :: stale_count + integer :: repeated_count + integer :: nonfinite_count + integer :: bad_area_count + integer :: invalid_weight_count + real(rk) :: max_penetration + + call sph_coupling_get_contact_diagnostics(active_count, skipped_count, & + max_penetration, stale_count, repeated_count, nonfinite_count, & + bad_area_count, invalid_weight_count, ierr) + call assert_ok(ierr, trim(label) // ' contact diagnostics failed') + if (active_count /= expected_active) call fail(trim(label) // ' active count bad') + if (skipped_count /= expected_skipped) call fail(trim(label) // ' skipped count bad') + if (.not. scalar_is_finite(max_penetration)) then + call fail(trim(label) // ' max penetration bad') + end if + end subroutine assert_contact_count + + subroutine read_stale_count(stale_count, label) + integer, intent(out) :: stale_count + character(len=*), intent(in) :: label + integer :: active_count + integer :: skipped_count + integer :: repeated_count + integer :: nonfinite_count + integer :: bad_area_count + integer :: invalid_weight_count + real(rk) :: max_penetration + + call sph_coupling_get_contact_diagnostics(active_count, skipped_count, & + max_penetration, stale_count, repeated_count, nonfinite_count, & + bad_area_count, invalid_weight_count, ierr) + call assert_ok(ierr, trim(label) // ' stale diagnostics failed') + if (.not. scalar_is_finite(max_penetration)) then + call fail(trim(label) // ' stale penetration bad') + end if + end subroutine read_stale_count + + 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 bad') + call assert_vector_finite(v(:,i), trim(label) // ' velocity bad') + call assert_vector_finite(a(:,i), trim(label) // ' acceleration bad') + if (.not. scalar_is_finite(mass(i))) call fail(trim(label) // ' mass bad') + if (.not. scalar_is_finite(rho(i))) call fail(trim(label) // ' density bad') + if (.not. scalar_is_finite(volume(i))) call fail(trim(label) // ' volume bad') + if (.not. scalar_is_finite(pressure(i))) call fail(trim(label) // ' pressure bad') + if (.not. scalar_is_finite(internal_energy(i))) call fail(trim(label) // ' energy bad') + if (.not. scalar_is_finite(temperature(i))) call fail(trim(label) // ' temp bad') + if (.not. scalar_is_finite(h(i))) call fail(trim(label) // ' h bad') + end do + end subroutine assert_model_finite + + subroutine assert_vector_close(actual, expected, message) + real(rk), intent(in) :: actual(SPH_NDIM) + real(rk), intent(in) :: expected(SPH_NDIM) + character(len=*), intent(in) :: message + integer :: i + + do i = 1, SPH_NDIM + if (abs(actual(i) - expected(i)) > max(1.0e-10_rk, abs(expected(i)) * 1.0e-8_rk)) then + call fail(message) + end if + end do + end subroutine assert_vector_close + + 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 + + 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_081 diff --git a/tests/module/test_explosive_restart_041.f90 b/tests/module/test_explosive_restart_041.f90 index 2e8903d..23b9798 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_8') call fail('restart state version mismatch') + if (trim(state) /= 'STATE_0_8_1') call fail('restart state version mismatch') end subroutine assert_restart_header subroutine assert_ok(ierr_value, message) diff --git a/tests/module/test_output.f90 b/tests/module/test_output.f90 index 5337d24..8842e84 100644 --- a/tests/module/test_output.f90 +++ b/tests/module/test_output.f90 @@ -125,6 +125,7 @@ contains 'blast_shell_fx,blast_shell_fy,blast_shell_fz,' // & 'blast_shell_mx,blast_shell_my,blast_shell_mz,' // & 'coupling_force_x,coupling_force_y,coupling_force_z,' // & + 'coupling_gap,coupling_penetration,coupling_contact_flag,' // & 'solid_failure_status,solid_reference_neighbor_count,' // & 'solid_correction_status,coupling_motion_flag,coupling_region_id') then call fail('particle CSV header mismatch') diff --git a/tests/module/test_restart.f90 b/tests/module/test_restart.f90 index 76265ad..0b94865 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_8') call fail('restart state version mismatch') + if (trim(state_version) /= 'STATE_0_8_1') 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_output.f90 b/tests/module/test_solid_output.f90 index 908e869..b68923f 100644 --- a/tests/module/test_solid_output.f90 +++ b/tests/module/test_solid_output.f90 @@ -83,8 +83,11 @@ contains real(rk) :: acceleration_norm real(rk) :: blast_force_values(9) real(rk) :: coupling_force_values(3) + real(rk) :: coupling_gap + real(rk) :: coupling_penetration integer :: reference_neighbors integer :: correction_status + integer :: contact_flag integer :: motion_flag integer :: region_id @@ -104,6 +107,7 @@ contains 'blast_shell_fx,blast_shell_fy,blast_shell_fz,' // & 'blast_shell_mx,blast_shell_my,blast_shell_mz,' // & 'coupling_force_x,coupling_force_y,coupling_force_z,' // & + 'coupling_gap,coupling_penetration,coupling_contact_flag,' // & 'solid_failure_status,solid_reference_neighbor_count,' // & 'solid_correction_status,coupling_motion_flag,coupling_region_id') then call fail('Solid particle CSV header mismatch') @@ -111,8 +115,8 @@ contains read(unit, *, iostat=ios) id, phase, status, mat, sec, pos, vel, & scalar_values, explosive_values, stress_values, plastic, damage, & softening, strain_rate_eq, acceleration_norm, blast_force_values, & - coupling_force_values, failure, reference_neighbors, correction_status, & - motion_flag, region_id + coupling_force_values, coupling_gap, coupling_penetration, contact_flag, & + failure, reference_neighbors, correction_status, motion_flag, region_id close(unit=unit) if (ios /= 0) call fail('Solid particle CSV row read failed') if (id /= 1) call fail('Solid particle CSV id mismatch') @@ -143,6 +147,10 @@ contains if (maxval(abs(coupling_force_values)) > 1.0e-12_rk) then call fail('Solid particle CSV coupling load pollution') end if + if (abs(coupling_gap) > 1.0e-12_rk .or. & + abs(coupling_penetration) > 1.0e-12_rk .or. contact_flag /= 0) then + call fail('Solid particle CSV coupling contact defaults mismatch') + end if if (failure /= solid_failure_status(1)) call fail('Solid particle CSV failure mismatch') if (reference_neighbors /= solid_reference_neighbor_count(1)) then call fail('Solid particle CSV reference neighbor mismatch') diff --git a/tests/module/test_solid_restart_050.f90 b/tests/module/test_solid_restart_050.f90 index 4083927..ce538f2 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_8') + 'STATE_0_8_1') 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/todo.md b/todo.md index 0d98922..47ad68a 100644 --- a/todo.md +++ b/todo.md @@ -210,48 +210,48 @@ ## 阶段 F:Mock Coupling Smoke、门禁、文档和发布准备 -- [ ] 设计 Solid surface pressure mock coupling smoke 样例。 -- [ ] 设计 Shell pressure mock coupling smoke 样例。 -- [ ] 设计 traction mock coupling smoke 样例。 -- [ ] 设计 pressure-motion 混合 mock coupling smoke 样例。 -- [ ] 设计 stale epoch mock coupling smoke 样例。 -- [ ] 新增 Solid surface pressure 输入文件。 -- [ ] 新增 Shell pressure 输入文件。 -- [ ] 新增 traction 输入文件。 -- [ ] 新增 pressure-motion 混合输入文件。 -- [ ] 新增 stale epoch 输入文件。 -- [ ] 验证 smoke 中所有粒子状态保持有限。 -- [ ] 验证 smoke 中 pressure 方向受控。 -- [ ] 验证 smoke 中 traction 方向受控。 -- [ ] 验证 smoke 中 motion boundary 方向受控。 -- [ ] 验证 smoke 中 Solid 响应方向受控。 -- [ ] 验证 smoke 中 Shell 平动响应方向受控。 -- [ ] 验证 smoke 中总力误差和力矩误差有限。 -- [ ] 验证 smoke 中 contact diagnostics 有限。 -- [ ] 验证 stale epoch 诊断按预期变化。 -- [ ] 新增 `coupling_smoke_081` 测试。 -- [ ] 新增 `coupling_source_size_081` 测试。 -- [ ] 将阶段 F 新测试接入 CTest。 -- [ ] 运行 0.8.1 coupling 专项 gate。 -- [ ] 运行 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.1 当前状态和不交付范围。 -- [ ] 更新 `docs/06_test_and_verification_plan.md` 的 0.8.1 release gate。 -- [ ] 更新 `docs/09_release_history.md` 的 0.8.1 本地验收记录。 -- [ ] 更新 `docs/11_benchmark_matrix.md` 的 0.8.1 gate 矩阵。 -- [ ] 确认文档不宣称真实 FEMLite 联合运行。 -- [ ] 确认文档不宣称连续体耦合。 -- [ ] 确认文档不宣称工程级船舶水下接触爆炸破坏 benchmark。 -- [ ] 准备 0.8.1 发布提交说明。 -- [ ] 准备阶段 F 本地提交说明。 +- [x] 设计 Solid surface pressure mock coupling smoke 样例。 +- [x] 设计 Shell pressure mock coupling smoke 样例。 +- [x] 设计 traction mock coupling smoke 样例。 +- [x] 设计 pressure-motion 混合 mock coupling smoke 样例。 +- [x] 设计 stale epoch mock coupling smoke 样例。 +- [x] 新增 Solid surface pressure 输入文件。 +- [x] 新增 Shell pressure 输入文件。 +- [x] 新增 traction 输入文件。 +- [x] 新增 pressure-motion 混合输入文件。 +- [x] 新增 stale epoch 输入文件。 +- [x] 验证 smoke 中所有粒子状态保持有限。 +- [x] 验证 smoke 中 pressure 方向受控。 +- [x] 验证 smoke 中 traction 方向受控。 +- [x] 验证 smoke 中 motion boundary 方向受控。 +- [x] 验证 smoke 中 Solid 响应方向受控。 +- [x] 验证 smoke 中 Shell 平动响应方向受控。 +- [x] 验证 smoke 中总力误差和力矩误差有限。 +- [x] 验证 smoke 中 contact diagnostics 有限。 +- [x] 验证 stale epoch 诊断按预期变化。 +- [x] 新增 `coupling_smoke_081` 测试。 +- [x] 新增 `coupling_source_size_081` 测试。 +- [x] 将阶段 F 新测试接入 CTest。 +- [x] 运行 0.8.1 coupling 专项 gate。 +- [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.1 当前状态和不交付范围。 +- [x] 更新 `docs/06_test_and_verification_plan.md` 的 0.8.1 release gate。 +- [x] 更新 `docs/09_release_history.md` 的 0.8.1 本地验收记录。 +- [x] 更新 `docs/11_benchmark_matrix.md` 的 0.8.1 gate 矩阵。 +- [x] 确认文档不宣称真实 FEMLite 联合运行。 +- [x] 确认文档不宣称连续体耦合。 +- [x] 确认文档不宣称工程级船舶水下接触爆炸破坏 benchmark。 +- [x] 准备 0.8.1 发布提交说明。 +- [x] 准备阶段 F 本地提交说明。