From 2b7962eb969f2899892d85a36c5702bb84d89025 Mon Sep 17 00:00:00 2001 From: shenw Date: Wed, 1 Jul 2026 18:39:18 +0800 Subject: [PATCH] Release FemLite 0.5.3 --- CMakeLists.txt | 2 +- README.md | 2 +- docs/03_detailed_design.md | 19 + docs/04_mathematical_model_and_algorithms.md | 20 + docs/05_interface_control_document.md | 33 + docs/06_test_and_verification_plan.md | 23 + docs/07_user_manual.md | 17 + docs/08_developer_manual.md | 15 + docs/suggests.md | 532 ++++ docs/v5.3_development_plan.md | 279 ++ docs/v5_acceptance_report.md | 20 +- docs/v5_benchmark_matrix.md | 24 +- docs/v5_development_plan.md | 16 +- examples/contact_block_sliding/README.md | 6 + .../check_contact_results.py | 50 + .../contact_two_blocks_compression/README.md | 6 + .../check_contact_results.py | 45 + examples/shell_shell_contact/README.md | 3 + .../check_contact_results.py | 32 +- examples/shell_solid_contact/README.md | 3 + .../check_contact_results.py | 32 +- .../check_spherical_cap_results.py | 38 + src/base/fem_api.f90 | 8 + src/base/fem_api_diagnostics.f90 | 79 +- src/base/fem_control.f90 | 143 +- src/base/fem_precision.f90 | 2 +- src/boundary/fem_contact_history.f90 | 45 + src/boundary/fem_contact_mortar_tangent.f90 | 53 + src/boundary/fem_contact_multiplier.f90 | 100 + .../fem_contact_multiplier_report.f90 | 31 +- src/element/fem_element_internal.f90 | 8 + src/output/fem_output_csv.f90 | 149 +- src/output/fem_restart.f90 | 242 +- src/solver/fem_linear_solver_cg.f90 | 4 +- src/solver/fem_linear_solver_dispatch.f90 | 93 +- src/solver/fem_solver_implicit.f90 | 1 + src/solver/fem_solver_implicit_support.f90 | 31 +- src/solver/fem_solver_static_nonlinear.f90 | 16 + tests/interface/test_c_api.c | 2 +- tests/module/test_contact.f90 | 7 +- tests/module/test_contact_mortar_tangent.f90 | 16 +- .../module/test_contact_multiplier_report.f90 | 6 + tests/module/test_implicit_inp.f90 | 35 + tests/module/test_linear_solver_cg.f90 | 13 + tests/module/test_restart.f90 | 154 +- tests/module/test_solver_implicit.f90 | 166 +- tests/performance/perf_contact_pair.f90 | 122 +- tests/performance/perf_p1.f90 | 2 +- tests/unit/test_smoke.f90 | 2 +- todo.md | 2411 +++-------------- tools/testing/check_perf_contact_pair_omp.py | 101 +- 51 files changed, 3084 insertions(+), 2175 deletions(-) create mode 100644 docs/suggests.md create mode 100644 docs/v5.3_development_plan.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c984f4..fd01145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) project(FemLite - VERSION 0.5.2 + VERSION 0.5.3 LANGUAGES C Fortran ) diff --git a/README.md b/README.md index 51a41af..77608bc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ FemLite 是一个以 Fortran 95 为核心实现的轻量级有限元求解器,面向结构动力学、静力学、壳/实体单元、接触、材料非线性和外部耦合接口的工程验证与算法开发。 -当前项目版本为 **0.5.2**。`v0.5.0` 已作为第五版阶段验收发布标签推送;第四版 `0.4.8` 已完成阶段验收并作为稳定基线;第五版 `0.5.x` 继续推进完整工业级 mortar 接触、无第三方依赖的内部稀疏求解器强化、Mohr-Coulomb、线性屈曲、循环对称、滚压成形、粘附/脱粘和颗粒耦合等后续能力。 +当前项目版本为 **0.5.3**。`v0.5.0` 已作为第五版阶段验收发布标签推送;第四版 `0.4.8` 已完成阶段验收并作为稳定基线;第五版 `0.5.x` 继续推进 mortar/AL 接触诊断、无第三方依赖的内部稀疏求解器强化、Mohr-Coulomb、线性屈曲、循环对称、滚压成形、粘附/脱粘和颗粒耦合等后续能力;完整工业级 mortar/AL 一致切线重写不作为 0.5.3 阻塞项。 ## 当前基线 diff --git a/docs/03_detailed_design.md b/docs/03_detailed_design.md index c13f052..4bb6251 100644 --- a/docs/03_detailed_design.md +++ b/docs/03_detailed_design.md @@ -1242,3 +1242,22 @@ subroutine database_allocate(ierr) subroutine database_initialize(ierr) subroutine database_finalize(ierr) ``` + +## 21. 0.5.3 Diagnostic Design Addendum + +0.5.3 is a diagnostic hardening release, not a broad contact-solver rewrite. +The production boundary is: + +- Nonlinear failures carry stable reason ids/names through the convergence + diagnostic path. +- Nonlinear residual storage separates total, force, contact, constraint, arc + and material-local-failure categories when those quantities are available. +- Contact summaries expose stable state counts, gap/penetration statistics, + slip/friction residuals, multiplier/augmentation diagnostics and active-set + flip counts. +- Contact restart version 4 preserves accepted-increment diagnostic state in + the optional `CONTACT_PAIR_DIAGNOSTICS` block. +- Mortar/friction tangent work in 0.5.3 is an audit interface. It splits normal, + stick and slip finite-difference errors and rigid/energy residuals; it does + not replace the production contact path with a complete industrial + AL/mortar consistent tangent. diff --git a/docs/04_mathematical_model_and_algorithms.md b/docs/04_mathematical_model_and_algorithms.md index 05e03e6..487e8da 100644 --- a/docs/04_mathematical_model_and_algorithms.md +++ b/docs/04_mathematical_model_and_algorithms.md @@ -1754,3 +1754,23 @@ load-strength continuation:阶段 A 随非线性静力增量缩放外载并收 trust-region damped Newton 已进入生产非线性静力路径,并在 chain/cloud/progress CSV 中输出相应诊断;0.75 m 临界失稳位移/eqps cloud 属于后续 longrun/研究验证,不作为 V5 PASS 条件。 + +## 20. 0.5.3 Diagnostic Algorithms + +0.5.3 adds diagnostic algorithms around existing nonlinear and contact paths: + +- Nonlinear failure taxonomy maps known cutback/Newton/linear-solver/contact/ + material/constraint causes to stable reason ids and names while preserving + existing status codes. +- Residual breakdown stores total, force, contact, constraint, arc and material + local-failure categories. Categories that are not assembled by a path remain + zero instead of changing the older scalar residual contract. +- Contact state diagnostics map current history into `open`, `closed-stick`, + `closed-slip`, `closed-restick`, `separating` and `failed-projection` counts. +- Contact residual diagnostics include maximum penetration, mean gap, gap L2, + failed projection count, active-set flip count, slip increment/residual, + friction residual, multiplier residual and augmentation/update quantities. +- Tangent diagnostics remain finite-difference audits. Normal-contact, + friction-stick and friction-slip branches are reported separately, with rigid + translation and energy probes. This is not a complete production AL/mortar + consistent tangent derivation. diff --git a/docs/05_interface_control_document.md b/docs/05_interface_control_document.md index 4d369ff..67129da 100644 --- a/docs/05_interface_control_document.md +++ b/docs/05_interface_control_document.md @@ -1447,3 +1447,36 @@ fem_finalize `femlite_get_linear_solver_stats` 和 `femlite_get_linear_solver_diagnostics`, 返回/设置值与 Fortran API 常量一致。 - 上述函数只追加新符号,不改变 `femlite_get_contact_summary` 的签名和含义。 + +## 18. 0.5.3 Diagnostic Interface Addendum + +Fortran diagnostic API: + +- `fem_get_residual_breakdown(total_residual, force_residual, + contact_residual, constraint_residual, arc_residual, + material_fail_count, ierr)` returns the latest nonlinear residual + decomposition. Missing categories are returned as zero, preserving older + scalar residual queries. + +CSV/output schema: + +- `continuation_path.csv` appends `residual_total`, `residual_force`, + `residual_contact`, `residual_constraint`, `residual_arc` and + `material_failure_count` before `reason_id` and `reason_name`. +- Contact CSV/report output may include stable state counts, mean/L2 gap, + maximum penetration, failed projection count, active-set flip count, + slip increment/residual, friction residual, multiplier residual, + augmentation factor/update diagnostics and augmented multiplier values. + +Restart schema: + +- Restart files with version 4 may include optional + `CONTACT_PAIR_DIAGNOSTICS` rows after `CONTACT_MULTIPLIER`. +- Readers still accept older restart versions and old files ending directly at + `END`; version 4 is required only to round-trip the new accepted-increment + contact diagnostic fields. + +Boundary: + +- 0.5.3 documents audit and diagnostic interfaces. It does not claim complete + industrial AL/mortar consistent tangent support. diff --git a/docs/06_test_and_verification_plan.md b/docs/06_test_and_verification_plan.md index acc0b8a..dc56492 100644 --- a/docs/06_test_and_verification_plan.md +++ b/docs/06_test_and_verification_plan.md @@ -844,3 +844,26 @@ V4.2 阶段完成条件: - Fortran API 和 C ABI 可查询接触诊断统计。 - rigid plane indentation、two blocks compression 和 shell rigid plane contact 三个小算例可运行并生成 VTK 与接触结果。 - CTest 全量回归通过,`source_size` 无 hard-threshold 失败。 + +## 25. 0.5.3 Diagnostic Regression Addendum + +0.5.3 targeted regression commands: + +```powershell +cmake --build build-codex-gcc --parallel +ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp|linear_solver_cg|restart|contact_mortar_report|contact_mortar_tangent|contact_multiplier_report|perf_contact_pair_omp_consistency)$" --output-on-failure +ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure +ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure +``` + +Acceptance criteria: + +- New nonlinear failure reason ids/names are consumed by solver tests. +- Residual breakdown fields are present in API storage and path CSV output. +- Contact state, gap, slip/friction, multiplier and augmentation diagnostics + are consumed by contact tests or benchmark checkers. +- Restart preserves accepted-increment contact diagnostics. +- OpenMP contact consistency compares deterministic state/force/tangent/cache + diagnostics and ignores timing-only differences. +- Documentation must keep the explicit boundary that 0.5.3 does not deliver a + complete industrial AL/mortar consistent tangent rewrite. diff --git a/docs/07_user_manual.md b/docs/07_user_manual.md index b902b17..f13d848 100644 --- a/docs/07_user_manual.md +++ b/docs/07_user_manual.md @@ -570,3 +570,20 @@ V5 当前开发态记录: - 颗粒耦合当前已具备内置离散球颗粒、颗粒-facet 映射和动态柔性容器紧凑 benchmark;它不是工业规模 DEM 长跑,也不接入外部颗粒求解器。 - 非线性 Newmark-Newton 和复杂壳塑性仍需要更多工程基准和长时间稳定性验证。 - 大型工程算例的并行、内存和接触收敛策略仍需后续版本完善。 + +## 14. 0.5.3 Diagnostic Output Notes + +0.5.3 focuses on explainability. When nonlinear or contact runs fail, users +should inspect: + +- nonlinear reason id/name and residual breakdown fields; +- `continuation_path.csv` residual columns: + `residual_total`, `residual_force`, `residual_contact`, + `residual_constraint`, `residual_arc`, `material_failure_count`; +- contact output fields for state counts, penetration/gap norms, + failed projections, active-set flips, slip/friction residuals, multiplier + residuals and augmentation diagnostics. + +These fields are meant to separate geometry/search, normal contact, friction, +constraint, linear-solver and material-local causes. They are not a guarantee +that every large industrial AL/mortar contact path will converge in 0.5.3. diff --git a/docs/08_developer_manual.md b/docs/08_developer_manual.md index 3c82d93..3f6bd44 100644 --- a/docs/08_developer_manual.md +++ b/docs/08_developer_manual.md @@ -577,3 +577,18 @@ V4.8 起,`examples_layout` CTest 会检查 `examples/` 一级目录:有文 - 大规模接触收敛控制。 - 更多壳塑性和隐式动力长跑基准。 - 大规模性能、并行和内部稀疏求解器/预条件器强化。 + +## 19. 0.5.3 Developer Notes + +When adding or changing diagnostic fields after 0.5.3: + +- Add the storage field, public query or output column together with a module + test, checker or report audit that consumes it. +- Keep old CSV columns stable unless a versioned format change is explicitly + documented. +- Keep restart readers backward compatible; optional diagnostic blocks should + be skipped safely by older scenarios where possible. +- Treat mortar/friction tangent helpers as audit tools until the production + AL/mortar consistent tangent rewrite is explicitly scheduled. +- Do not mark compact contact benchmarks as proof of complete industrial + contact coverage. diff --git a/docs/suggests.md b/docs/suggests.md new file mode 100644 index 0000000..2a742e6 --- /dev/null +++ b/docs/suggests.md @@ -0,0 +1,532 @@ +我建议接下来**不要优先继续横向加功能**,而是把 FemLite 0.5.2 已有算法链条做“纵向闭环”:让非线性、接触、壳/屈曲、材料、restart、诊断在同一套算法规则下稳定运行。按投入产出比,优先级如下。 + +## 总体优先级 + +| 优先级 | 建议完善方向 | 为什么优先 | +| ------ | ------------------------------ | ----------------------------------------------------------------- | +| **P0** | 非线性求解状态机与一致诊断框架 | 这是 Riks、接触、材料塑性、Newmark-Newton、cutback 的共同地基 | +| **P1** | 接触一致切线、AL/mortar 长路径、摩擦状态算法 | 接触是最容易导致非线性求解不收敛、路径不稳定、restart 不一致的部分 | +| **P2** | 壳/实体几何刚度与预载屈曲链条 | 你已有 buckling 与 S4 finite-strain,下一步应补完整“预载 → 屈曲 → 后屈曲”算法链 | +| **P3** | Riks / continuation 泛化 | 现有 Riks 是有界路径,应扩展到更通用的 snap-through、snap-back、接触/塑性耦合路径 | +| **P4** | 材料积分一致切线与有限变形塑性 | MC、J2、壳 section plasticity 已有基础,下一步应提升为更可靠的工程本构算法库 | +| **P5** | Cohesive contact 主流程 | 你已有 cohesive 单点/compact benchmark,但还未进入通用 FE cohesive contact 主流程 | +| **P6** | 非零 harmonic cyclic symmetry | 现在 WAVE=0 已有,后续应补 harmonic wave、自动配对、结果展开 | +| **P7** | DEM/FEM 耦合的守恒性、subcycling 与规模化 | 颗粒路径已有 smoke/benchmark,下一步应先补算法守恒与稳定性,再谈大规模长跑 | +| **P8** | 线性求解器的非线性耦合适配 | 现有 Krylov/ILU0 足够支撑小中规模,但接触/约束/arc-length 会带来更复杂矩阵结构 | + +--- + +## 1. 第一优先:统一非线性求解状态机 + +FemLite 现在已经有非线性静力、Newmark-Newton、cutback、线搜索、trust-region damped Newton、Riks、接触 trial/commit/rollback、材料状态更新、restart 等机制。下一步最重要的是把这些机制统一成一个清晰的算法状态机。 + +建议建立统一的层次: + +```text +Step + └── Increment / Load step + └── Nonlinear iteration + ├── trial state + ├── residual assembly + ├── tangent assembly + ├── linear solve + ├── line search / damping / trust region + ├── accept / reject + └── commit / rollback +``` + +需要补的算法点: + +1. **统一 trial/commit/rollback 协议** + 材料、接触、cohesive、颗粒耦合、Newmark 状态、Riks 路径变量都应服从同一套 trial/commit/rollback 规则。否则 cutback、restart、OpenMP 并行路径很容易出现“不完全回滚”。 + +2. **统一残差分解** + 残差不应只有全局力残差,还应分解为: + + * 结构力残差; + * 接触 gap residual; + * 摩擦 slip residual; + * 约束/MPC residual; + * arc-length residual; + * Newmark 动力平衡 residual; + * 材料局部 return-mapping failure 统计。 + +3. **统一收敛准则** + 建议至少支持: + + * 力范数; + * 位移增量范数; + * 能量范数; + * 接触 gap/slip 容差; + * arc-length 约束容差; + * 材料点局部收敛容差。 + +4. **统一 cutback 决策表** + 每次 cutback 应明确原因,例如: + + * 线性求解失败; + * Newton 震荡; + * 接触 active set 反复切换; + * 材料点 return mapping 失败; + * Riks path predictor 错误; + * tangent 非正定或 pivot fallback; + * 位移增量过大; + * 接触穿透过大。 + +5. **统一 tangent audit** + 现有 MC、mortar tangent 已经有有限差分审计。建议扩展成全局机制: + + * element tangent audit; + * material tangent audit; + * contact tangent audit; + * cohesive tangent audit; + * Newmark effective tangent audit; + * Riks augmented tangent audit; + * shell finite-strain tangent audit。 + +这一项看似不是“新功能”,但它会显著提高后续所有高级算法的可靠性。 + +--- + +## 2. 第二优先:接触算法从 benchmark path 推进到长路径可信 + +你现在接触能力已经很广:面-面、analytical plane、mortar 权重、Coulomb/正则化摩擦、AL、multiplier restart、tangent audit、shell-shell、shell-solid、大滑移摩擦、OpenMP smoke。下一步应该把重点放在**一致线性化与长路径鲁棒性**。 + +建议完善: + +### 2.1 完整 AL / mortar 一致切线 + +重点补: + +* normal gap 对位移的几何导数; +* tangential slip 对位移的导数; +* 法向接触力与切向摩擦力耦合项; +* mortar 权重随大滑移投影变化的导数; +* 接触面法向变化导数; +* stick/slip 分支切换处的半光滑 Newton 或正则化切线; +* penalty/AL 参数自适应; +* active set 切换的滞回或稳定策略。 + +近期 mortar 接触文献中,AL 与 semi-smooth Newton 都是常用约束执行路线;相关工作也指出,纯 penalty 方法会带来约束满足不可直接控制和矩阵病态等问题,这正好对应 FemLite 后续应避免的问题。 + +### 2.2 接触状态机标准化 + +建议把接触状态显式分成: + +```text +open +closed-stick +closed-slip +closed-restick +separating +failed-projection +``` + +并对每个状态定义: + +* trial 更新; +* residual 贡献; +* tangent 贡献; +* 是否允许 line search; +* 是否触发 cutback; +* restart 写读字段; +* CSV 诊断字段。 + +### 2.3 接触 benchmark 应从“能跑”变成“能解释” + +建议增加这些验收指标: + +* 接触功是否非负或符合摩擦耗散; +* gap 最大值、均值、L2 范数; +* slip residual; +* active set 翻转次数; +* 每步 AL augmentation 次数; +* penalty 参数与穿透误差关系; +* tangent audit 相对误差; +* restart 前后接触力一致性; +* OpenMP 不同线程数结果差异。 + +**建议验收目标**:不是追求所有复杂接触都一步收敛,而是每次不收敛都能从日志中看出是 active set、投影、摩擦切线、线性求解还是材料状态导致。 + +--- + +## 3. 第三优先:补完整壳/实体几何刚度与预载屈曲链 + +你现在已经有: + +* Euler column; +* dense generalized eigen solver; +* generic `*BUCKLING`; +* line geometric stiffness; +* 静力预载后 line `K_G`; +* C3D4/C3D8 initial-stress `K_G`; +* S4 finite-strain bounded postbuckling; +* spherical cap benchmark。 + +这说明 FemLite 已经有屈曲和后屈曲的骨架。下一步最应该补的是: + +### 3.1 完整 shell preload-to-buckling `K_G` + +这是当前缺口里最值得优先补的一个。 + +建议覆盖: + +* 壳膜内力贡献的几何刚度; +* 弯曲应力/曲率相关几何刚度; +* transverse shear 相关项; +* director/rotation 自由度相关项; +* drilling 或伪 drilling 稳定项与 `K_G` 的关系; +* finite rotation 下的 stress stiffness; +* 多层壳 section 应力合成到几何刚度; +* 壳预载静力场到 buckling perturbation step 的状态传递。 + +线性特征值屈曲通常用于估计临界屈曲载荷,而后屈曲/不稳定路径则需要 Riks 或其他非线性路径跟踪方法;这正好对应 FemLite 现在应补齐的“预载屈曲 → 后屈曲 continuation”链条。([文档中心][1]) + +### 3.2 高阶实体几何刚度 + +建议补: + +* C3D10 initial-stress `K_G`; +* C3D20 initial-stress `K_G`; +* reduced/full integration 下的几何刚度一致性; +* 曲边高阶几何映射对 `K_G` 的影响; +* 刚体模态污染检查。 + +### 3.3 屈曲结果进入后屈曲 + +建议实现: + +```text +static preload + → eigen buckling + → select mode + → imperfection injection + → nonlinear static / Riks postbuckling + → load-displacement path output +``` + +这样球冠、圆柱壳、拱、波纹壳、循环对称扇区都能用同一条算法链验证。 + +--- + +## 4. 第四优先:Riks / arc-length 从有界路径扩展为通用 continuation 框架 + +现在已有载荷型 Riks / arc-length continuation 和直接位移控制 path 记录。下一步建议不要只做“更多 case 能跑”,而是抽象成统一 continuation 框架。 + +建议补: + +1. **混合控制变量** + + * load control; + * displacement control; + * arc-length control; + * selected DOF control; + * generalized work control。 + +2. **自动弧长调整** + + * 根据 Newton 迭代次数增减弧长; + * 根据 cutback 原因缩短弧长; + * 过极限点后允许载荷因子反向; + * 支持 snap-through 与 snap-back。 + +3. **分支检测** + + * tangent singularity 指标; + * smallest pivot/eigen estimate; + * path turning point detection; + * branch switch 诊断,不一定第一步就自动切换,但要先能识别。 + +4. **与接触/塑性兼容** + Riks 最难的不是光滑弹性拱,而是: + + * 接触 active set 变化; + * 摩擦 stick/slip 切换; + * 材料屈服面切换; + * cohesive damage softening; + * 壳后屈曲大转动。 + +Riks 类 arc-length 方法常用于不稳定、几何非线性塌曲或后屈曲问题,这类问题也正是 FemLite 当前 spherical cap、two arches、shell contact 等 benchmark 的自然延伸。([ABAQUS Documentation][2]) + +--- + +## 5. 第五优先:材料算法从“已有 return mapping”推进到“可组合材料内核” + +材料方面,你已经有线弹性、J2、J2_JC、壳 section plasticity、Mohr-Coulomb active set、张拉截断、FD tangent audit、strength reduction。下一步建议把重点放在**一致切线、有限变形、软化正则化、壳/实体共用材料点框架**。 + +### 5.1 Mohr-Coulomb + +建议优先完善: + +* non-associated flow; +* dilation angle; +* apex/edge/corner return 的更清晰分支; +* shear/tension/mixed 分支之间的稳定切换; +* consistent elastoplastic tangent; +* softening/hardening 参数; +* 强度折减下的局部化诊断; +* 黏聚力、摩擦角、张拉强度折减的一致处理; +* plane strain / plane stress / shell section 的统一接口。 + +### 5.2 J2 / J2_JC + +建议补: + +* finite-strain J2; +* multiplicative 或 corotational finite-strain plasticity 路径; +* consistent tangent; +* 温度/应变率状态变量清晰化; +* Johnson-Cook damage 暂可后置,但状态变量框架应先留好; +* cyclic loading 下的 path/restart audit。 + +### 5.3 壳 section plasticity + +当前是“代表性 section plasticity”,下一步建议推进到: + +* layer-wise section integration; +* 每层独立材料状态; +* section stress resultant 与 material point stress 的双向输出; +* 壳厚方向塑性扩展; +* 与 ABD/H 弹性 section 的统一接口。 + +--- + +## 6. 第六优先:Cohesive 从 compact benchmark 进入通用主流程 + +你已经有 cohesive law、mixed-mode damage、unloading/reload、complete decohesion、非负耗散、restart 状态保持,以及 ball adhesion/decohesion benchmark。下一步要补的是**与 FE 接触/界面主流程的整合**。 + +建议路线: + +1. **先做 cohesive interface element** + + * 零厚度 interface element; + * 法向/切向开裂位移; + * mixed-mode 能量准则; + * consistent tangent; + * damage irreversibility; + * unloading/reload; + * complete failure 后刚度退化。 + +2. **再做 cohesive contact** + + * 初始粘结; + * 损伤后压缩 re-contact; + * 失效后摩擦; + * cohesive 与 Coulomb 摩擦状态切换; + * 接触 active set 与 damage state 统一管理。 + +3. **最后再做通用 surface-based cohesive** + 这一步复杂度最高,建议放在 interface element 稳定之后。 + +建议 benchmark: + +* 单积分点 traction-separation; +* DCB; +* ENF; +* mixed-mode bending; +* 压缩闭合再接触; +* 剪切失效后摩擦滑移; +* restart 中途损伤状态恢复。 + +--- + +## 7. 第七优先:循环对称从 WAVE=0 扩展到非零 harmonic wave + +现在已有 WAVE=0、显式 master/slave 对、solid 3-DOF、shell 6-DOF cyclic MPC、扇区旋转矩阵映射。下一步建议补: + +1. **自动 cyclic 边界配对** + + * 基于旋转轴; + * 角度容差; + * 半径/高度匹配; + * shell director 方向检查; + * pair quality CSV 输出。 + +2. **非零 harmonic wave** + 有两种实现路线: + + * complex DOF 形式; + * real-valued sine/cosine doubled system。 + + 对 Fortran/C ABI 和现有 real-valued solver 来说,建议优先采用 **real block formulation**,即把一个 harmonic 的实部/虚部写成双实变量系统。 + +3. **cyclic buckling** + 循环对称屈曲通常需要按 harmonic index 组织特征值结果,并可展开到完整 360° 模型;这说明 FemLite 后续应把 `wave_id`、buckling multiplier、mode expansion、modal CSV 统一设计。([Ansys Help][3]) + +4. **结果展开** + + * sector result; + * full annulus result; + * selected harmonic result; + * phase angle result; + * VTK expanded output。 + +--- + +## 8. 第八优先:DEM/FEM 耦合先补守恒与时间步算法,不要急着做大规模长跑 + +颗粒部分现在已经有离散球状态、自由落体、墙碰撞、三颗粒堆、颗粒-facet、柔性容器映射。下一步建议先完善算法质量,而不是直接追求大规模 DEM。 + +建议补: + +1. **时间步稳定性** + + * DEM critical time step; + * FEM explicit time step; + * DEM/FEM subcycling; + * 接触刚度变化时的自动步长控制。 + +2. **守恒审计** + + * 线动量; + * 角动量; + * 接触功; + * 摩擦耗散; + * 颗粒到 facet 节点力的合力/合矩一致性; + * 能量 drift。 + +3. **接触模型** + + * normal spring-dashpot; + * tangential spring; + * frictional history; + * rolling resistance 可后置; + * restitution calibration。 + +4. **并行确定性** + + * candidate pair ordering; + * force accumulation deterministic reduction; + * OpenMP 线程数一致性。 + +只有这些稳定之后,再做大规模颗粒长跑才有意义。 + +--- + +## 9. 第九优先:线性求解器要服务非线性,而不是单纯增加 solver 名字 + +目前已有 CG、BiCGSTAB、GMRES、dense pivoting fallback、CSR、Jacobi/Gauss-Seidel/ILU0。既然已经明确拒绝外部第三方 solver 后端,下一步算法重点应是**矩阵分类、缩放、块结构预条件**。 + +建议补: + +1. **矩阵分类更细** + + * SPD; + * symmetric indefinite; + * unsymmetric; + * saddle-point-like; + * contact augmented system; + * Riks augmented system; + * MPC constrained system。 + +2. **自动 solver 选择** + + * SPD → CG; + * unsymmetric → GMRES / BiCGSTAB; + * 小规模病态 → dense pivoting fallback; + * 接触/arc-length → 优先 GMRES + scaling; + * buckling/eigen → dense generalized eigensolver 或后续 Lanczos。 + +3. **缩放与重排序** + + * row/column scaling; + * diagonal equilibration; + * simple bandwidth reduction; + * contact rows scaling; + * constraint rows scaling。 + +4. **块预条件** + + * displacement block; + * contact multiplier block; + * arc-length scalar block; + * MPC constraint block; + * shell rotational DOF scaling。 + +这部分不要急着做复杂 AMG。对 FemLite 当前阶段,更值得先把现有 Krylov 体系在非线性接触、Riks、MPC、buckling 这些场景下用稳。 + +--- + +## 10. 建议版本路线 + +### FemLite 0.6:算法地基版 + +重点目标:**非线性求解、状态管理、诊断统一化**。 + +建议交付: + +* 统一 trial/commit/rollback; +* 统一 nonlinear residual breakdown; +* 统一 tangent audit 框架; +* restart-after-each-increment audit; +* cutback reason taxonomy; +* Newmark / static / Riks / contact 共享状态机; +* 接触 AL 参数与 gap/slip 诊断增强。 + +### FemLite 0.7:接触与几何刚度版 + +重点目标:**隐式接触长路径 + 预载屈曲可靠化**。 + +建议交付: + +* mortar/AL consistent tangent 长路径; +* friction stick/slip tangent; +* shell-solid 接触稳定性增强; +* shell preload `K_G`; +* C3D10/C3D20 initial-stress `K_G`; +* buckling residual/modal audit 增强; +* prestress-to-buckling-to-postbuckling 工作流。 + +### FemLite 0.8:后屈曲、cohesive、cyclic 扩展版 + +重点目标:**工程非线性路径闭环**。 + +建议交付: + +* mixed load/displacement arc-length; +* imperfection injection; +* branch/limit-point diagnostics; +* cohesive interface element; +* cohesive contact 初版; +* cyclic auto pairing; +* nonzero harmonic wave real-block formulation; +* cyclic buckling result expansion。 + +### FemLite 0.9:规模化与工程工艺版 + +重点目标:**把 compact benchmark 推向更长、更复杂路径**。 + +建议交付: + +* roll forming 更完整工艺链; +* DEM/FEM subcycling; +* DEM 并行确定性; +* contact search scalability; +* large benchmark governance; +* solver scaling/reordering/block preconditioning; +* benchmark dashboard。 + +--- + +## 我认为最该先做的 5 个具体任务 + +1. **统一非线性状态机与 trial/commit/rollback** + 这是最底层的稳定性工程,直接影响材料、接触、Riks、Newmark、restart。 + +2. **接触 AL/mortar/friction 一致切线长路径** + 这是最能提升 FemLite 工程可信度的算法方向。 + +3. **完整 shell preload-to-buckling 几何刚度** + 你已经有壳、屈曲、S4 finite-strain、球冠后屈曲;补这个会让整条壳稳定性链条成立。 + +4. **Riks 泛化为 mixed-control continuation** + 让球冠、拱、接触失稳、cohesive softening、塑性软化都能走同一套 path-following 框架。 + +5. **材料一致切线与 layer-wise shell plasticity** + 让 MC/J2/壳塑性不只是 benchmark 可跑,而是能稳定进入复杂非线性路径。 + +最不建议现在优先做的是:直接冲完整生产级 roll forming、大规模 DEM 长跑、更多单元类型、更多材料模型名字。FemLite 0.5.2 已经“广”,下一阶段应该先把核心非线性算法做“深”。 + +[1]: https://docs.software.vt.edu/abaqusv2024/English/?show=SIMACAEANLRefMap%2Fsimaanl-c-eigenbuckling.htm&utm_source=chatgpt.com "Eigenvalue Buckling Prediction" +[2]: https://abaqusdocs.eait.uq.edu.au/v6.11/books/usb/pt03ch06s02at03.html?utm_source=chatgpt.com "6.2.4 Unstable collapse and postbuckling analysis" +[3]: https://ansyshelp.ansys.com/public/Views/Secured/corp/v242/en/ans_cycsym/advcycbucklingans.html "4.5. Linear Buckling Cyclic Symmetry Analysis" diff --git a/docs/v5.3_development_plan.md b/docs/v5.3_development_plan.md new file mode 100644 index 0000000..267a56c --- /dev/null +++ b/docs/v5.3_development_plan.md @@ -0,0 +1,279 @@ +# FemLite 0.5.3 Development Plan + +日期:2026-07-01 + +适用对象:FemLite 0.5.3 开发、评审、测试与阶段验收。 + +## 1. 版本定位 + +FemLite 0.5.3 定位为: + +```text +接触与非线性诊断加固版 +``` + +0.5.2 已经形成较宽的算法覆盖面:内部 Krylov 求解器、非线性静力/Newmark、 +Riks/continuation 有界路径、Mohr-Coulomb、紧凑接触 benchmark、屈曲/循环对称 +有界子集、finite-strain S4 有界路径、cohesive 单点/compact benchmark 和 +颗粒-FEM 耦合 benchmark 均已有回归证据。 + +0.5.3 不再优先横向增加新功能名,而是把非线性、接触、restart、cutback、 +线性求解失败和诊断输出做成更稳定的一套纵向闭环。核心目标是: + +- 失败时能明确说明失败原因。 +- 接触状态和残差能分解、记录、复现。 +- restart/cutback 后 trial/commit/rollback 语义更可信。 +- 接触 benchmark 从“能跑”推进到“能解释”。 + +## 2. 范围边界 + +### 2.1 0.5.3 应交付 + +- 统一 cutback / nonlinear failure reason 编码。 +- 统一 nonlinear residual breakdown 的基础字段和输出。 +- 接触状态机字段标准化。 +- 接触 gap/slip/multiplier residual 诊断增强。 +- contact restart-after-increment audit。 +- mortar/friction tangent audit 增强。 +- OpenMP 接触路径一致性增强。 +- 线性求解器在非线性场景下的失败状态和矩阵分类诊断增强。 +- 文档、测试、benchmark checker 同步更新。 + +### 2.2 0.5.3 不交付 + +以下内容保留为后续版本,不作为 0.5.3 阻塞项: + +- 完整工业级 AL/mortar 一致切线重写。 +- 完整 shell preload-to-buckling `K_G`。 +- C3D10/C3D20 initial-stress `K_G`。 +- 通用 mixed-control Riks/arc-length 框架。 +- finite-strain J2、完整 layer-wise shell plasticity。 +- cohesive contact 主流程。 +- cyclic 自动配对和非零 harmonic wave。 +- DEM/FEM subcycling、大规模 DEM 长跑。 +- 完整 roll forming 生产工艺流。 + +## 3. 开发原则 + +- 优先做小闭环,不做跨多个主流程的大改造。 +- 诊断字段必须有测试或 checker 消费,避免只写日志不验收。 +- 新状态字段必须考虑 restart、cutback、trial/commit/rollback。 +- 不把 compact benchmark 宣称成完整工业能力。 +- 不为了 0.5.3 改写已有 V5.12 DEFERRED 决策。 + +## 4. 任务清单 + +### 4.1 NL-1:统一 cutback / failure reason taxonomy + +目标:把非线性失败原因从零散状态码推进为可解释的分类。 + +建议新增或整理的原因类别: + +- 线性求解失败。 +- Newton 残差不降。 +- correction norm 过大。 +- line search 失败。 +- trust-region reject。 +- 接触 active set 震荡。 +- 接触投影失败。 +- 接触穿透过大。 +- 摩擦 stick/slip 反复切换。 +- 材料 return mapping 失败。 +- Riks/arc constraint 失败。 +- MPC/约束残差过大。 +- step 最小步长耗尽。 + +验收: + +- `solver_implicit` 覆盖至少 3 类 failure reason。 +- `implicit_inp` 覆盖 INP 路径下 reason 字段保持稳定。 +- CSV 或 summary 输出包含 reason id/name。 + +### 4.2 NL-2:nonlinear residual breakdown + +目标:把单一 residual 扩展为可解释分量。 + +0.5.3 建议先覆盖: + +- total residual norm。 +- internal/external force residual。 +- contact gap residual。 +- contact slip residual。 +- MPC/constraint residual。 +- arc-length residual。 +- material local failure count。 + +验收: + +- 非线性静力和 Newmark-Newton 至少输出 total、constraint、contact 三类字段。 +- spherical-cap / contact benchmark checker 能读取并验证字段存在。 +- 字段缺失时 checker 应失败。 + +### 4.3 CT-1:接触状态机字段标准化 + +目标:为接触点或接触贡献建立稳定状态名称。 + +建议状态: + +```text +open +closed-stick +closed-slip +closed-restick +separating +failed-projection +``` + +0.5.3 不要求完整状态机重写,但应做到: + +- 当前接触历史能映射到上述状态或其稳定子集。 +- CSV/report 输出每类状态计数。 +- restart 后状态计数一致。 + +验收: + +- `restart` 覆盖 active/open、stick/slip、released/separating 的读写一致性。 +- contact benchmark summary 输出状态计数。 + +### 4.4 CT-2:gap / slip / multiplier residual 诊断增强 + +目标:让接触不收敛时能看出是法向、切向还是乘子问题。 + +建议字段: + +- max penetration。 +- mean gap。 +- gap L2 norm。 +- slip increment norm。 +- slip residual。 +- normal multiplier residual。 +- tangential/friction residual。 +- active set flip count。 +- failed projection count。 +- AL augmentation count。 + +验收: + +- `contact_mortar_report` 或相关测试覆盖新增字段。 +- `example_contact_two_blocks_compression_benchmark` 和 + `example_contact_block_sliding_benchmark` 的 checker 至少消费部分字段。 + +### 4.5 CT-3:mortar/friction tangent audit 增强 + +目标:继续使用有限差分审计,而不是直接大规模重写一致切线。 + +建议增强: + +- normal-only tangent audit。 +- friction stick tangent audit。 +- friction slip tangent audit。 +- rigid translation residual。 +- row/column balance。 +- energy probe。 +- relative FD error summary。 + +验收: + +- `contact_mortar_tangent` 覆盖 normal/stick/slip 三类审计。 +- 输出可区分 tangent error、rigid residual、energy residual。 + +### 4.6 CT-4:OpenMP 接触路径一致性增强 + +目标:继续确保并行路径不改变接触统计和力学结果。 + +建议覆盖: + +- force path。 +- tangent path。 +- candidate cache path。 +- 多 step active set path。 +- 1/2/4 线程统计一致性。 + +验收: + +- `perf_contact_pair_omp_consistency` 从 1/4 线程扩展到 1/2/4 或保留 + 1/4 但增加状态计数字段。 +- checker 比较非计时统计、接触力、active set、gap/slip 诊断。 + +### 4.7 LS-1:线性求解器非线性场景诊断 + +目标:线性求解器服务非线性,而不是增加 solver 名字。 + +建议增强: + +- 矩阵分类:SPD、symmetric indefinite、unsymmetric、constraint-like、 + contact-augmented、Riks-augmented。 +- solver selected reason。 +- fallback reason。 +- preconditioner breakdown reason。 +- final relative residual 和 nonlinear reason 关联。 + +验收: + +- `linear_solver_cg` 覆盖失败状态和分类字段。 +- `solver_implicit` 能把线性失败映射到 nonlinear failure reason。 + +### 4.8 DOC-1:文档与 benchmark 矩阵同步 + +需要同步更新: + +- `docs/v5_development_plan.md` +- `docs/v5_benchmark_matrix.md` +- `docs/v5_acceptance_report.md` +- `docs/04_mathematical_model_and_algorithms.md` +- `docs/05_interface_control_document.md` +- `docs/06_test_and_verification_plan.md` +- `docs/07_user_manual.md` +- `docs/08_developer_manual.md` +- 相关 examples README 和 checker 输出说明。 + +## 5. 建议执行顺序 + +1. NL-1:先统一 reason taxonomy,建立最小公共字段。 +2. LS-1:把线性失败映射到 nonlinear failure reason。 +3. CT-1:接触状态计数字段标准化。 +4. CT-2:gap/slip/multiplier residual 诊断增强。 +5. CT-3:mortar/friction tangent audit 增强。 +6. CT-4:OpenMP 接触路径一致性增强。 +7. NL-2:补 residual breakdown 到主输出和 checker。 +8. DOC-1:最后统一文档、矩阵和验收报告。 + +## 6. 0.5.3 验收建议 + +最小验收命令建议: + +```powershell +cmake --build build-codex-gcc --parallel +ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp|linear_solver_cg|restart|contact_mortar_report|contact_mortar_tangent|contact_multiplier_report|perf_contact_pair_omp_consistency)$" --output-on-failure +ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure +ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure +``` + +通过标准: + +- 0.5.2 的 V5 acceptance 子集不回退。 +- 新增 nonlinear/contact 诊断字段由测试或 checker 校验。 +- 接触 restart 和 OpenMP 路径统计一致。 +- 失败案例能输出明确 reason,而不是只给通用 solver error。 +- 文档明确说明 0.5.3 仍不宣称完整工业级 AL/mortar 一致切线。 + +## 7. 风险与控制 + +| 风险 | 控制 | +|---|---| +| 诊断字段膨胀但无人消费 | 每个新增字段必须有测试或 checker | +| 接触状态机改动过大导致主流程不稳 | 0.5.3 只做状态映射和诊断,不重写完整接触求解器 | +| 与 Riks/cohesive/DEM 混线 | 这些能力只消费公共诊断接口,不作为 0.5.3 主开发目标 | +| benchmark 指标频繁变动 | 新增字段优先检查存在性、单调性、非负性和一致性,避免过早锁死复杂数值 | +| 文档口径再次扩大 | 明确保留 DEFERRED 边界,不把完整工业能力写成 PASS | + +## 8. 推荐结论 + +0.5.3 应优先完成: + +```text +非线性失败原因可解释 + 接触状态/残差可诊断 + restart/OpenMP 路径可复现 +``` + +这会直接提高后续 0.5.4+ 的壳预载屈曲、Riks 泛化、cohesive 主流程、 +材料一致切线和 DEM/FEM 长路径开发成功率。 diff --git a/docs/v5_acceptance_report.md b/docs/v5_acceptance_report.md index 47ed14b..5d3a7e3 100644 --- a/docs/v5_acceptance_report.md +++ b/docs/v5_acceptance_report.md @@ -99,6 +99,8 @@ ctest --test-dir build-win-ifx-v5-20-2 -C Release -L v5_acceptance --output-on-f ctest --test-dir build-win-gcc-16 -C Release -R "contact_omp1|contact_omp4|perf_contact_pair_omp_consistency" --output-on-failure -V ctest --test-dir build-win-gcc-16 -C Release -R "^(contact_mortar_tangent|restart|contact_multiplier_diag|contact_multiplier_report|contact_omp1|contact_omp4|perf_contact_pair_omp_consistency)$" --output-on-failure cmake --build build-codex-gcc --parallel +ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp|linear_solver_cg|restart|contact_mortar_report|contact_mortar_tangent|contact_multiplier_report|perf_contact_pair_omp_consistency)$" --output-on-failure +ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure ctest --test-dir build-codex-gcc -R "^example_spherical_cap_point_load_benchmark$" --output-on-failure $env:FEMLITE_SPHERICAL_CAP_NONLINEAR='1' @@ -120,8 +122,10 @@ python examples\spherical_cap_with_central_point_load\check_spherical_cap_result | `ctest --test-dir build-win-ifx-v5-20-2 -C Release -L v5_acceptance --output-on-failure` | 35/35 passed | | `ctest --test-dir build-win-gcc-16 -C Release -R "contact_omp1|contact_omp4|perf_contact_pair_omp_consistency" --output-on-failure -V` | 3/3 passed | | 0.5.1 V5.3 定向接触审计与 OpenMP smoke | 7/7 passed | -| `cmake --build build-codex-gcc --parallel` | passed; all missing V5 acceptance executables generated | -| `ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure` | 36/36 passed | +| `cmake --build build-codex-gcc --parallel` | passed for 0.5.3 | +| 0.5.3 targeted nonlinear/contact diagnostic regression on `build-codex-gcc` | 8/8 passed | +| 0.5.3 contact benchmark diagnostic checker subset on `build-codex-gcc` | 4/4 passed | +| `ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure` | 39/39 passed | | `ctest --test-dir build-codex-gcc -R "^example_spherical_cap_point_load_benchmark$" --output-on-failure` | 1/1 passed | | V5.11 bounded spherical-cap nonlinear checker, `FEMLITE_SPHERICAL_CAP_NONLINEAR=1` | passed; 54 accepted increments | @@ -158,14 +162,14 @@ python examples\spherical_cap_with_central_point_load\check_spherical_cap_result | 领域 | 原因 | 风险 | 用户影响 | |---|---|---|---| -| 完整 mortar / AL 一致切线 | 当前已有 multiplier、mortar、friction、多示例 benchmark、0.5.1 multiplier restart audit 和 tangent matrix audit;0.5.2 追加摩擦历史 stick/slip restart 审计、BiCGSTAB/GMRES 失败状态诊断和 64 面片 4 步 OpenMP force/tangent/cache 路径一致性;完整工业级一致切线和真实非线性长路径仍移入后续版本 | 大规模非线性接触可能需要更强收敛控制 | 当前可运行紧凑接触 benchmark、接触审计回归和路径级并行一致性;不能宣称覆盖所有工业接触场景 | +| 完整 mortar / AL 一致切线 | 当前已有 multiplier、mortar、friction、多示例 benchmark;0.5.3 已补 nonlinear failure reason、residual breakdown、contact state/gap/slip/friction/multiplier/augmentation diagnostics、restart v4 diagnostic round-trip、normal/stick/slip tangent audit split 和 1/2/4 线程 OpenMP deterministic path consistency;完整工业级一致切线和真实非线性长路径仍移入后续版本 | 大规模非线性接触可能需要更强收敛控制 | 当前可运行紧凑接触 benchmark、接触审计回归和路径级并行一致性;不能宣称覆盖所有工业接触场景 | | Mohr-Coulomb 结构级自动 trial 重求解 | 材料点、活动集算法一致切线和 FOS 曲线 benchmark 已完成,完整结构非线性失稳判据和 PDF 位移/塑性云图仍需扩展 | 复杂边坡或三维岩土模型可能过早/过晚判稳 | 当前适合强度折减曲线验证,不等价于完整岩土生产求解器 | | 通用 `*BUCKLING` step | 已有内部特征值和 benchmark 工具,主 `femlite` 输入流程尚未提供通用 buckling step | 用户需要通过 benchmark 工具验证屈曲,而非普通 INP 直接求解 | 小规模解析/紧凑循环 benchmark 可用,通用屈曲工况仍需后续版本 | | 完整三维滚压长跑 | 当前是辊运动学和紧凑多层 J2 截面 springback benchmark | 真实工艺网格、restart 多 step 和长时间稳定性尚未验证 | 用户可验证核心算法路径,但不能直接替代工业 roll forming 工艺仿真 | | 完整 FE cohesive 接触 step | 当前 cohesive law/state/metrics 和 ring benchmark 已完成,主接触流程切换与切线仍需集成 | 粘附/普通接触切换和 restart 长路径仍有风险 | 用户可使用 benchmark 验证 cohesive 模型,不应把它当作通用 FE cohesive 接触 | | 颗粒大规模 longrun | 当前 V5.8 限定内置离散球和紧凑柔性容器 benchmark | 大颗粒数性能、邻域搜索和长时间能量稳定性仍需验证 | 用户可验证双向映射闭环,但不能把它当作工业 DEM 装填求解器 | | 球冠完整 PDF 全曲线 | V5.11 验收收窄为 finite-strain S4 bounded postbuckling capability;完整 `uz=-6.2 m`、Shell-4/8/16 digitized reference matching、later restiffening 和 late GMRES 性能优化移入后续版本 | 严格参考曲线复现仍需更强 continuation 与性能工作 | 用户可使用 V5.11 验证 S4 finite-strain 生产路径和 post-peak load drop,不能把它声明为完整 NAFEMS/PDF 全曲线复现 | -| 后续 longrun 发布节奏 | 正式 `v0.5.0` 标签已指向包含 20.2 多平台复测和 20.4 文档治理的节点;`main` 后续提升到 `0.5.2` | 更大规模 longrun 和 V5.3-V5.7 主流程工程化仍需后续版本继续收束 | 不影响 `v0.5.0` 阶段验收结论;后续发布应明确新的 tag/commit | +| 后续 longrun 发布节奏 | 正式 `v0.5.0` 标签已指向包含 20.2 多平台复测和 20.4 文档治理的节点;`main` 后续提升到 `0.5.3` | 更大规模 longrun 和剩余 PARTIAL 能力仍需后续版本继续收束 | 不影响 `v0.5.0` 阶段验收结论;后续发布应明确新的 tag/commit | ## 暂缓或不纳入当前模块 @@ -177,10 +181,10 @@ python examples\spherical_cap_with_central_point_load\check_spherical_cap_result ## 结论 -当前 V5 开发态已经将 V5.2 和 V5.8 收束到可验收闭环,并为 V5.3-V5.7 -建立了真实算法路径、紧凑 benchmark 和可复现指标。`v5_acceptance` 标签提供 -当前 V5 验收子集,默认 Release CTest 保持 106/106 passed,并已完成 WSL GNU -和 Windows Intel/MSVC 多平台复测。 +当前 V5 开发态已经将 V5.2 和 V5.8 收束到可验收闭环,并完成 0.5.3 +nonlinear/contact explainability hardening。`v5_acceptance` 标签提供当前 V5 +验收子集,`build-codex-gcc` 当前记录为 39/39 passed;历史默认 Release CTest +保持 106/106 passed,并已完成 WSL GNU 和 Windows Intel/MSVC 多平台复测。 最终 0.5.x 发布仍需完成更大规模 longrun、最终标签决策和剩余 PARTIAL 能力的 工程化收束;不得把当前紧凑 benchmark 夸大为完整工业场景全覆盖。 diff --git a/docs/v5_benchmark_matrix.md b/docs/v5_benchmark_matrix.md index 9d0cec7..4fa27bf 100644 --- a/docs/v5_benchmark_matrix.md +++ b/docs/v5_benchmark_matrix.md @@ -37,6 +37,12 @@ Current local V5 acceptance subset evidence on `build-codex-gcc`: `ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure` passed 39/39. +Current local 0.5.3 diagnostic evidence on `build-codex-gcc`: + +- `cmake --build build-codex-gcc --parallel` passed. +- `ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp|linear_solver_cg|restart|contact_mortar_report|contact_mortar_tangent|contact_multiplier_report|perf_contact_pair_omp_consistency)$" --output-on-failure` passed 8/8. +- `ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure` passed 4/4. + ## 测试层级 | 层级 | 用途 | 推荐命令 | @@ -63,11 +69,11 @@ Current local V5 acceptance subset evidence on `build-codex-gcc`: | V5 项 | 能力 | 目录或模块 | CTest 名称 | 参考指标 | 容差/验收条件 | |---|---|---|---|---|---| | V5.2 | 内部 solver 诊断、no-external-solver 策略 | `src/solver`, `tests/module`, `tests/interface` | `linear_solver_cg`, `csr_diagnostics`, `solver_implicit`, `implicit_inp`, `c_api`, CLI implicit/static tests | CG/BiCGSTAB/GMRES/dense pivoting、残差、CSR matrix class、legacy external id rejection、非线性修正 fallback | 旧外部 method/backend id 被拒绝且不改变设置;静力、隐式和非线性路径通过内部 solver dispatch;非线性修正可在内部求解器间 fallback 且恢复用户设置 | -| V5.3 | 非匹配实体 mortar 压缩 | `examples/contact_two_blocks_compression` | `example_contact_two_blocks_compression_benchmark` | `pressure_profile.csv`, active contact, master coverage, weighted gap, multiplier residual | 多 master facet 覆盖;weighted penetration 和 multiplier residual 在 checker 容差内;VTK 输出存在 | -| V5.3 | 大滑移 mortar-friction | `examples/contact_block_sliding` | `example_contact_block_sliding_benchmark` | `sliding_profile.csv`, stick/slip, accumulated slip, tangential force, friction work | 多 master/active candidate;累计滑移和摩擦功为正且非负耗散;VTK 输出存在 | -| V5.3 | shell-shell contact | `examples/shell_shell_contact` | `example_shell_shell_contact_benchmark` | contact profile, active contact, force norm, gap residual, augmented multiplier | active contact 大于零;gap/force/multiplier 指标通过 checker | -| V5.3 | shell-solid contact | `examples/shell_solid_contact` | `example_shell_solid_contact_benchmark` | contact profile, master search, shell-to-solid force transfer | active contact 大于零;master search 和 nodal force 指标通过 checker | -| V5.3 | 接触状态、restart 和并行路径连续性 | `tests/module`, `tests/performance` | `contact_mortar_al`, `contact_mortar_iter`, `contact_mortar_report`, `contact_mortar_tangent`, `contact_multiplier_report`, `restart`, `perf_contact_pair_omp_consistency` | AL multiplier, `contact_multiplier_audit`, `mortar_tan_audit_matrix`, tangent/report diagnostics, restart restored history, 64 面片 4 步 OpenMP path stats | 接触历史、摩擦累计量、stick/slip 状态计数和 multiplier 状态在 restart 后连续;0.5.1 覆盖 active/released/open multiplier 写读、duplicate/invalid 为零、commit/trial 差异为零,并检查 mortar tangent row/column balance、刚体平移残差、非对称量和能量 probe;OpenMP 1/4 线程下 force/tangent/cache 路径非计时统计一致 | +| V5.3 | 非匹配实体 mortar 压缩 | `examples/contact_two_blocks_compression` | `example_contact_two_blocks_compression_benchmark` | `pressure_profile.csv`, active contact, master coverage, weighted gap, multiplier residual, state/status, active-set flip, gap mean/L2, augmentation diagnostics | 多 master facet 覆盖;weighted penetration、gap norm、state count、active-set flip 和 multiplier/augmentation diagnostics 在 checker 容差内;VTK 输出存在 | +| V5.3 | 大滑移 mortar-friction | `examples/contact_block_sliding` | `example_contact_block_sliding_benchmark` | `sliding_profile.csv`, stick/slip, accumulated slip, tangential force, friction work, slip/friction residuals, gap L2, augmentation diagnostics | 多 master/active candidate;累计滑移和摩擦功为正且非负耗散;slip/friction/gap/augmentation diagnostics 存在且内部一致;VTK 输出存在 | +| V5.3 | shell-shell contact | `examples/shell_shell_contact` | `example_shell_shell_contact_benchmark` | contact profile, active contact, force norm, gap residual, augmented multiplier, state/status, active-set flip, failed projection count | active contact 大于零;gap/force/multiplier/state/flip/projection 指标通过 checker | +| V5.3 | shell-solid contact | `examples/shell_solid_contact` | `example_shell_solid_contact_benchmark` | contact profile, master search, shell-to-solid force transfer, state/status, active-set flip, gap L2, failed projection count, augmentation diagnostics | active contact 大于零;master search、nodal force 和 shared diagnostic 指标通过 checker | +| V5.3 | 接触状态、restart、非线性诊断和并行路径连续性 | `tests/module`, `tests/performance` | `contact_mortar_al`, `contact_mortar_iter`, `contact_mortar_report`, `contact_mortar_tangent`, `contact_multiplier_report`, `restart`, `solver_implicit`, `implicit_inp`, `linear_solver_cg`, `perf_contact_pair_omp_consistency` | failure reason taxonomy, residual breakdown API/path CSV, AL multiplier, tangent audit split, contact report diagnostics, restart v4 restored diagnostics, 64 面片 4 步 OpenMP path stats | nonlinear/contact failure reason 与 residual breakdown 被测试消费;contact state/gap/slip/friction/multiplier/augmentation diagnostics 在 report/checker 中消费;restart 后接触诊断连续;normal/stick/slip tangent audit 分开报告;OpenMP 1/2/4 线程下 force/tangent/cache/state/residual 路径非计时统计一致 | | V5.4 | Mohr-Coulomb 材料点 | `tests/unit` | `material_mohr_coulomb`, `material_mc_driver`, `material_mc_envelope` | 三轴压缩/伸展、纯剪、张拉截断、branch id、plastic multiplier | yield margin、分支号、塑性增量和 envelope safety ratio 通过测试容差 | | V5.4 | Mohr-Coulomb 屈服面算例 | `examples/mohr_coulomb_yield_surface` | `example_mc_yield_surface_benchmark` | `yield_surface.csv`, `yield_points.csv`, `yield_summary.csv`; 原始材料和 `F=2` 折减材料 | 压缩包络、伸展包络和张拉截断符合解析公式;强度折减降低承载力;elastic/shear/tension/mixed 分支全部被代表性应力点激活 | | V5.4 | Mohr-Coulomb 边坡强度折减 benchmark | `examples/strengthReduction` | `example_strength_reduction_benchmark` | 8 个参考工况,最大 FOS 误差 `6.9392E-03`,86 trials,52 stable,34 unstable;`--nonlinear-chain` 可选输出真实 FE trial、cutback、accepted-time 和线性求解诊断;`--nl-write-cloud` 可选输出目标 FOS 云图 summary 与 VTK;0.75 m cloud route 支持内部 BiCGSTAB/ILU0、静力 predictor、自适应跳步和 accepted segment 后 VTK 刷新 | 0.75 m 网格和参考几何记录;输入使用原生实体 `DLOAD, GRAV`;上下土体界面必须为共享节点 conforming mesh;FOS 曲线在 0.02 容差内;FOS 随坡角单调降低;关联工况不弱于 Davis B 工况;plastic zone 和 displacement probe 激活;optional nonlinear chain 不伪造 VTK;optional partial/target cloud VTK 必须含 displacement/eqps 字段且网格计数匹配;0.75 m 临界失稳位移/eqps 云图属于后续 longrun/研究验证,不作为 V5 交付验收项 | @@ -87,10 +93,10 @@ Current local V5 acceptance subset evidence on `build-codex-gcc`: | 示例目录 | 主要输出 | checker | |---|---|---| -| `examples/contact_two_blocks_compression` | `pressure_profile.csv`, VTK | `check_contact_results.py` | -| `examples/contact_block_sliding` | `sliding_profile.csv`, VTK | `check_contact_results.py` | -| `examples/shell_shell_contact` | shell contact profile, VTK | `check_contact_results.py` | -| `examples/shell_solid_contact` | shell-solid contact profile, VTK | `check_contact_results.py` | +| `examples/contact_two_blocks_compression` | `pressure_profile.csv`, VTK, 0.5.3 contact state/gap/augmentation diagnostics | `check_contact_results.py` | +| `examples/contact_block_sliding` | `sliding_profile.csv`, VTK, 0.5.3 slip/friction/gap/augmentation diagnostics | `check_contact_results.py` | +| `examples/shell_shell_contact` | shell contact profile, VTK, 0.5.3 shared contact diagnostics | `check_contact_results.py` | +| `examples/shell_solid_contact` | shell-solid contact profile, VTK, 0.5.3 shared contact diagnostics | `check_contact_results.py` | | `examples/mohr_coulomb_yield_surface` | `yield_surface.csv`, `yield_points.csv`, `yield_summary.csv` | `check_mc_yield_surface_results.py` | | `examples/strengthReduction` | `strength_reduction_path.csv`, `strength_reduction_cases.csv`, summary, `plastic_zone.csv`, `displacement_probe.csv`; optional `strength_reduction_nonlinear_chain.csv` and nonlinear summary when `--nonlinear-chain` is used; optional `strength_reduction_cloud_summary.csv`, progress/trace CSV and refreshed partial/target VTK when `--nl-write-cloud` is used | `check_strength_reduction_results.py` | | `examples/euler_column_buckling` | `buckling_summary.csv`, `buckling_mode_1.csv` | `check_buckling_results.py` | diff --git a/docs/v5_development_plan.md b/docs/v5_development_plan.md index d3c1545..062adfe 100644 --- a/docs/v5_development_plan.md +++ b/docs/v5_development_plan.md @@ -126,8 +126,8 @@ FemLite 0.5.x 定位为: - `0.5.0`:第五版开发起点,提升项目版本号,建立 V5 计划、首页 README 和 V4.8 验收基线说明。 - `0.5.1`:第五版架构冻结、V4 deferred 项登记和验收矩阵建立。 - `0.5.2`:内部稀疏求解器强化、no-external-solver 策略完成,并收束 `examples/two_arches` 对应参考文献的单个选定工况;V5 不引入 COMSOL 参数化扫描。 -- `0.5.3`:V5 范围内的 mortar / augmented Lagrangian 接触补强完成; - 完整工业级一致切线和真实非线性长路径收束移入后续版本。 +- `0.5.3`:V5 范围内的 nonlinear/contact diagnostic hardening 完成; + 完整工业级 AL/mortar 一致切线和真实非线性长路径收束移入后续版本。 - `0.5.4`:完整 Mohr-Coulomb 和强度折减完成。 - `0.5.5`:线性屈曲和循环对称完成。 - `0.5.6`:真实高保真滚压成形完成。 @@ -176,7 +176,7 @@ FemLite 0.5.x 定位为: |---|---|---|---| | V5.1 架构冻结与验收矩阵 | PARTIAL | 本计划、README 和 V1-V4 回归基线已建立。 | 最终验收矩阵、干净发布分支和 `docs/v5_acceptance_report.md`。 | | V5.2 内部稀疏求解强化与 two arches 单点参考验证 | PASS | solver dispatch 记录 method、preconditioner、iteration、status、CSR matrix class、initial/final/relative residual;CG/BiCGSTAB/GMRES、内部 dense pivoting fallback、线性静力、隐式 Newmark、非线性接触修正、非线性修正 CG-to-GMRES fallback 和 C ABI 诊断回归通过;外部求解器接口、工具和构建目标已移除;`examples/two_arches` 已完成 PDF 几何、30/75 壳网格、接触激活、动态 blow-up 防护 checker 和 `para=0.02` 单个位移参考点 checker。 | 0.5.2 已补齐选定单点参考工况:`disp_upper=max_disp*para` 位移参考点、单点输出和参考指标 checker;不要求静力边载荷收敛或 COMSOL 参数化扫描。 | -| V5.3 mortar / AL 接触 | PARTIAL | 已有接触乘子、mortar AL 点/批量/约束/切线/迭代/报告模块和聚焦测试;非匹配实体压力、大滑移摩擦、shell-shell 和 shell-solid benchmark 已接入 CTest;0.5.1 新增 contact multiplier restart audit 和 mortar tangent matrix audit,并扩展 restart active/released/open 场景;OpenMP contact 性能一致性已升级为 64 面片、4 步 force/tangent/cache 路径。 | 完整工业级 AL 一致切线和更多真实非线性长路径仍需收束。 | +| V5.3 mortar / AL 接触诊断加固 | DIAGNOSTIC PASS / SOLVER REWRITE DEFERRED | 已有接触乘子、mortar AL 点/批量/约束/切线/迭代/报告模块和聚焦测试;非匹配实体压力、大滑移摩擦、shell-shell 和 shell-solid benchmark 已接入 CTest;0.5.3 新增 nonlinear failure reason taxonomy、residual breakdown API/path CSV、contact state/gap/slip/friction/multiplier/augmentation diagnostics、restart version 4 `CONTACT_PAIR_DIAGNOSTICS`、normal/stick/slip tangent audit split,以及 1/2/4 线程 OpenMP deterministic path consistency;四个 contact benchmark checker 已消费新增诊断字段。 | 0.5.3 交付可解释诊断与紧凑 benchmark 证据;完整工业级 AL/mortar 一致切线、完整接触状态机重写和更多真实非线性长路径仍移入后续版本。 | | V5.4 Mohr-Coulomb 与强度折减 | FOS PASS / DIAGNOSTIC CLOUD DEFERRED | 已有 Mohr-Coulomb、包络、材料 driver、强度折减 driver/report 模块和测试;材料点验收覆盖三轴压缩、三轴伸展、纯剪、张拉截断、mixed return、分支号、塑性增量、强度折减残余下限,以及 shear/tension/mixed 活动集算法一致切线有限差分审计;`examples/strengthReduction` 已按 `models.geomech.strength_reduction_method.pdf` 的几何和参考工况升级为 0.75 m 网格 C3D8 Mohr-Coulomb 边坡强度折减 benchmark,覆盖 4 个坡角和 2 个材料工况,输出 path、case summary、plastic zone 和 displacement probe;0.5.2 新增 `--nonlinear-chain` 真实结构级 trial 路线和 `--nl-write-cloud` 目标 FOS 云图诊断路线,调用 `fem_solve_static_nonlinear` 输出真实收敛/失败诊断,并可生成 `strength_reduction_cloud_summary.csv` 与 `result_00001525.vtk`;实体 `DLOAD, GRAV` 已接入生产外载装配;非线性静力 step 已按增量时间缩放全局 `load_factor`,并新增 `static_ramp_load` 控制支持固定外载伪时间求解;strengthReduction 上下土体界面已修正为共享节点的 conforming mesh;NC-1 默认 `TWO_STAGE_LOAD_STRENGTH` 已接入 nonlinear chain 和 target cloud:阶段 A 在 `F=1.0` 收敛完整重力/外载,阶段 B 固定外载 continuation 强度折减因子;0.75 m cloud 路线还具备内部 BiCGSTAB/ILU0 预条件器、静力割线位移预测器、自适应 continuation 跳步和 accepted segment 后 VTK 刷新,旧路线实测可从 `accepted_time=0.003` 跳到 `0.053` 并推进到 `0.0905`;NC-5 已将 `METHOD=MC_SUBSTEPPING_SEMISMOOTH` 接入生产 Mohr-Coulomb 材料分发,支持 INP 可配置局部子步,在 `statev(27:32)` 写入聚合诊断,并已把 MC point/substep/branch/max-yield/max-plastic 汇总到 strengthReduction nonlinear chain/cloud/progress 输出,由 checker 校验。 | V5 交付不要求 0.75 m 临界失稳位移/eqps 云图完整复现;该问题计算量巨大且涉及边坡失稳临界现象,移入后续 longrun/研究验证。 | | V5.5 屈曲与循环对称 | PARTIAL / BOUNDED V5 DELIVERY | 已有几何刚度、特征求解、模态输出、屈曲支持、循环对称模块/测试、Euler 柱专用 `femlite --buckling` 主程序路径、波纹壳紧凑循环屈曲 benchmark、普通 INP 小规模 dense generic `*BUCKLING` 子集和 WAVE=0 显式节点对 `*CYCLIC SYMMETRY` 主路径;相关 checker 已验证临界载荷、模态残差、`K_G` 归一化、循环边界残差和循环/全模型一致性;generic `*BUCKLING` 子集复用已装配线弹性 `K`,几何刚度支持显式 `*BUCKLING GEOMETRIC LINE`、`*BUCKLING GEOMETRIC LINE, PRELOAD` 的预载派生线刚度子集,以及 `*STATIC` 后直接 `*BUCKLING` 的 C3D4/C3D8 实体 initial-stress `K_G` 子集,summary/modal CSV 走普通输出目录工作流;主路径 cyclic 通过 MPC 罚约束覆盖实体 3-DOF 与壳 6-DOF 节点对。 | 完整预载后壳几何刚度、高阶实体几何刚度、完整壳 FE 波纹壳高保真模型、自动循环边界配对和非零 harmonic wave 主求解语义均延期到 post-V5。 | | V5.6 高保真滚压成形 | PARTIAL / DEFERRED PRODUCTION WORKFLOW | 已有刚体圆柱/辊、运动调度、滚压指标、roller kinematics benchmark 和紧凑多层 J2 springback benchmark;示例输出 slip、traction、friction energy、pressure、torque、plastic work、plastic zone、residual displacement 和 springback ratio。 | 主求解器通用滚压成形 step、完整三维工件网格滚压、restart 驱动多 step 工艺流和更大规模长跑延期到 post-V5;当前 compact benchmark 只作为回归证据。 | @@ -215,13 +215,13 @@ V5 benchmark 示例当前标记: | 发布确认提交 | `9f577c0 Fix clean release verification inputs` | | 发布确认标签 | `v0.5.0-v5-acceptance-checkpoint`,annotated tag,指向 `9f577c0` | | 正式 0.5.0 标签 | `v0.5.0`,annotated tag,指向 `78dc4a6 Complete V5 documentation governance` | -| TODO 状态 | `todo.md` 中原 V5.2 至 V5.10 事项均已用 `[x]` 标记完成;0.5.2 新增 `examples/two_arches` 单点参考验证已用 `[x]` 标记完成 | +| TODO 状态 | `todo.md` 中原 V5.2 至 V5.10 事项均已用 `[x]` 标记完成;0.5.2 新增 `examples/two_arches` 单点参考验证已用 `[x]` 标记完成;0.5.3 nonlinear/contact diagnostic hardening 已完成 | | 默认回归 | 本地原工作树和 clean clone 均记录为 `ctest --test-dir build-win-gcc-16 -C Release --output-on-failure` 106/106 passed | -| V5 验收子集 | 本地原工作树和 clean clone 均记录为 `ctest --test-dir build-win-gcc-16 -C Release -L v5_acceptance --output-on-failure` 35/35 passed | +| V5 验收子集 | 本地原工作树和 clean clone 均记录为 `ctest --test-dir build-win-gcc-16 -C Release -L v5_acceptance --output-on-failure` 35/35 passed;0.5.3 本地 `build-codex-gcc` 记录为 39/39 passed | | WSL 多平台复测 | Ubuntu 24.04 / GNU Fortran 13.3.0 / GNU C 13.3.0 / CMake 3.28.3,`build-wsl-gfortran-v5-20-2` 默认 CTest 106/106 passed,`v5_acceptance` 35/35 passed | | Windows Intel 多平台复测 | VS DevCmd 17.14.33 / MSVC 19.44.35227.0 / IntelLLVM ifx 2026.0.0,`build-win-ifx-v5-20-2` 默认 CTest 106/106 passed,`v5_acceptance` 35/35 passed | -| OpenMP smoke | `contact_omp1`、`contact_omp4` 和 `perf_contact_pair_omp_consistency` 通过;`perf_contact_pair.exe 64 1` 在 1/4 线程下非计时统计一致 | -| 发布卫生 | 根目录生成结果文件已清理;`v0.5.0` 正式标签已推送;`main` 后续开发版本提升至 `0.5.2` | +| OpenMP smoke | `contact_omp1`、`contact_omp4` 和 `perf_contact_pair_omp_consistency` 通过;0.5.3 `perf_contact_pair_omp_consistency` 覆盖 1/2/4 线程 deterministic force/tangent/cache/state/residual stats | +| 发布卫生 | 根目录生成结果文件已清理;`v0.5.0` 正式标签已推送;`main` 后续开发版本提升至 `0.5.3` | | 验收文档 | 新增 `docs/v5_acceptance_report.md` 和 `docs/v5_benchmark_matrix.md` | | solver 边界 | 第三方/外部求解器接口、工具和测试已移除;内部 CG/BiCGSTAB/GMRES 与 dense pivoting fallback 为当前生产 solver 路径 | | 示例边界 | benchmark 编排工具位于 `tools/benchmarks`,示例输入和 checker 位于对应 `examples//` 目录,不进入 `src` | @@ -1182,4 +1182,4 @@ OpenMP contact/performance smoke 记录: | `docs/v5_development_plan.md` | 已登记 20.1 发布确认、20.2 多平台复测和 20.4 治理规则;V5.9/V5.10 仍保留 PARTIAL 以反映 longrun 和部分工程化边界 | | `docs/v5_benchmark_matrix.md` | 已新增多平台复测矩阵和文档治理边界;Windows GCC、WSL GNU、Windows Intel/MSVC 和 OpenMP smoke 结果已登记 | | `docs/v5_acceptance_report.md` | 已移除“多平台复测/release hygiene 未完成”的旧口径,保留 longrun、最终 tag 决策和剩余 PARTIAL 能力边界 | -| 后续建议 | `v0.5.0` 正式标签已包含 20.2 多平台复测和 20.4 文档治理;下一步在 `0.5.2` 上优先补更大规模 longrun 和 V5.3-V5.7 的工程化主流程集成 | +| 后续建议 | `v0.5.0` 正式标签已包含 20.2 多平台复测和 20.4 文档治理;0.5.3 收束 nonlinear/contact explainability 后,下一步优先补更大规模 longrun 和剩余 PARTIAL 能力的工程化主流程集成 | diff --git a/examples/contact_block_sliding/README.md b/examples/contact_block_sliding/README.md index 42f7873..b2d1b95 100644 --- a/examples/contact_block_sliding/README.md +++ b/examples/contact_block_sliding/README.md @@ -45,3 +45,9 @@ The checker verifies active contact on multiple candidates, four available master facets, accumulated sliding, stick/slip counters, positive frictional work, nonzero tangential force and VTK output. It also writes `sliding_profile.csv` in the result directory for benchmark inspection. + +0.5.3 diagnostic checks also consume contact state/status fields, +activation/release counts, active-set flip count, gap L2, failed projection +count, augmentation factor/lambda, slip increment/residual and friction +residual fields. These checks are diagnostic guards, not a retuning of the +friction law. diff --git a/examples/contact_block_sliding/check_contact_results.py b/examples/contact_block_sliding/check_contact_results.py index 3f6230d..4725c62 100644 --- a/examples/contact_block_sliding/check_contact_results.py +++ b/examples/contact_block_sliding/check_contact_results.py @@ -26,9 +26,19 @@ def write_sliding_profile(result_dir: str, rows: list[dict[str, str]]) -> str: "stick_count", "slip_count", "accumulated_slip", + "slip_increment_norm", + "slip_residual", "friction_work_total", + "friction_residual", "tangential_force", + "status", + "activation_count", + "release_count", "gap_residual", + "gap_l2", + "failed_projection_count", + "active_set_flip_count", + "aug_factor", "aug_lambda", "search_masters", "search_active", @@ -47,9 +57,19 @@ def write_sliding_profile(result_dir: str, rows: list[dict[str, str]]) -> str: "stick_count": int(float(row["stick_count"])), "slip_count": int(float(row["slip_count"])), "accumulated_slip": float(row["accumulated_slip"]), + "slip_increment_norm": float(row["slip_increment_norm"]), + "slip_residual": float(row["slip_residual"]), "friction_work_total": float(row["friction_work_total"]), + "friction_residual": float(row["friction_residual"]), "tangential_force": (ftx * ftx + fty * fty + ftz * ftz) ** 0.5, + "status": int(float(row["status"])), + "activation_count": int(float(row["activation_count"])), + "release_count": int(float(row["release_count"])), "gap_residual": float(row["gap_residual"]), + "gap_l2": float(row["gap_l2"]), + "failed_projection_count": int(float(row["failed_projection_count"])), + "active_set_flip_count": int(float(row["active_set_flip_count"])), + "aug_factor": float(row["aug_factor"]), "aug_lambda": float(row["aug_lambda"]), "search_masters": int(float(row.get("search_masters", "0") or "0")), "search_active": int(float(row.get("search_active", "0") or "0")), @@ -70,6 +90,8 @@ def main() -> int: max_stick_count = max(int(float(row["stick_count"])) for row in pair_rows) max_slip_count = max(int(float(row["slip_count"])) for row in pair_rows) max_slip = max(float(row["accumulated_slip"]) for row in pair_rows) + max_slip_increment = max(float(row["slip_increment_norm"]) for row in pair_rows) + max_slip_residual = max(float(row["slip_residual"]) for row in pair_rows) max_fric_work = max(float(row["friction_work_total"]) for row in pair_rows) min_fric_work = min(float(row["friction_work_total"]) for row in pair_rows) max_ft = max( @@ -82,6 +104,12 @@ def main() -> int: for row in pair_rows ) max_reg = max(float(row["friction_regularization"]) for row in pair_rows) + max_friction_residual = max(float(row["friction_residual"]) for row in pair_rows) + max_gap = max(float(row["gap_residual"]) for row in pair_rows) + max_gap_l2 = max(float(row["gap_l2"]) for row in pair_rows) + max_failed_projection = max(int(float(row["failed_projection_count"])) for row in pair_rows) + max_aug_factor = max(float(row["aug_factor"]) for row in pair_rows) + max_aug_lambda = max(float(row["aug_lambda"]) for row in pair_rows) max_masters = max(int(float(row.get("search_masters", "0") or "0")) for row in pair_rows) max_search_active = max(int(float(row.get("search_active", "0") or "0")) for row in pair_rows) @@ -100,6 +128,28 @@ def main() -> int: if max_slip < MIN_ACCUMULATED_SLIP or max_ft <= 0.0: print("frictional sliding response was not detected") return 1 + if max_slip_increment < max_slip or max_slip_residual <= 0.0: + print("slip residual diagnostics were not reported") + return 1 + if max_friction_residual <= 0.0: + print("friction residual diagnostic was not reported") + return 1 + if max_gap <= 0.0 or max_gap_l2 < max_gap: + print("gap residual diagnostics were not reported consistently") + return 1 + if max_failed_projection != 0: + print(f"unexpected failed projection count: {max_failed_projection}") + return 1 + if max_aug_factor <= 0.0 or max_aug_lambda <= 0.0: + print("augmentation diagnostics were not reported") + return 1 + if any( + int(float(row["active_set_flip_count"])) + < int(float(row["activation_count"])) + int(float(row["release_count"])) + for row in pair_rows + ): + print("active-set flip diagnostic is inconsistent") + return 1 if max_slip_count <= 0 or max_stick_count <= 0: print("stick/slip transition counters were not reported") return 1 diff --git a/examples/contact_two_blocks_compression/README.md b/examples/contact_two_blocks_compression/README.md index b11b4e1..f01877a 100644 --- a/examples/contact_two_blocks_compression/README.md +++ b/examples/contact_two_blocks_compression/README.md @@ -43,4 +43,10 @@ mortar-weighted penetration and VTK output. It also writes `pressure_profile.csv` in the result directory with one row per contact output sample. +0.5.3 diagnostic checks also consume contact state/status fields, activation +and release counts, active-set flip count, augmentation factor/lambda, +failed projection count, mean gap and L2 gap. The numerical checks emphasize +existence, sign, boundedness and internal consistency rather than exact +large-path nonlinear matching. + The double-click script writes repeatable output to `results\auto_run`. diff --git a/examples/contact_two_blocks_compression/check_contact_results.py b/examples/contact_two_blocks_compression/check_contact_results.py index 4859508..058fe1e 100644 --- a/examples/contact_two_blocks_compression/check_contact_results.py +++ b/examples/contact_two_blocks_compression/check_contact_results.py @@ -24,15 +24,31 @@ def main() -> int: for index, row in enumerate(pair_rows): force_norm = float(row["force_norm"]) gap = float(row["gap_residual"]) + gap_mean = float(row["gap_mean"]) + gap_l2 = float(row["gap_l2"]) + failed_projection = int(float(row["failed_projection_count"])) + active_set_flip = int(float(row["active_set_flip_count"])) + status = int(float(row["status"])) + activation_count = int(float(row["activation_count"])) + release_count = int(float(row["release_count"])) + aug_factor = float(row["aug_factor"]) aug_lambda = float(row["aug_lambda"]) profile_rows.append( { "sample": float(index), "active_count": float(row["active_count"]), + "status": float(status), + "activation_count": float(activation_count), + "release_count": float(release_count), "pressure": force_norm / CONTACT_AREA, "max_gap": gap, + "gap_mean": gap_mean, + "gap_l2": gap_l2, + "failed_projection_count": float(failed_projection), + "active_set_flip_count": float(active_set_flip), "weighted_gap": gap * CONTACT_AREA, "multiplier_residual": abs(gap), + "aug_factor": aug_factor, "aug_lambda": aug_lambda, "search_masters": float(row.get("search_masters", "0") or "0"), } @@ -45,10 +61,18 @@ def main() -> int: fieldnames=[ "sample", "active_count", + "status", + "activation_count", + "release_count", "pressure", "max_gap", + "gap_mean", + "gap_l2", + "failed_projection_count", + "active_set_flip_count", "weighted_gap", "multiplier_residual", + "aug_factor", "aug_lambda", "search_masters", ], @@ -59,8 +83,13 @@ def main() -> int: max_active = max(int(row["active_count"]) for row in profile_rows) max_pressure = max(row["pressure"] for row in profile_rows) max_gap = max(row["max_gap"] for row in profile_rows) + max_gap_l2 = max(row["gap_l2"] for row in profile_rows) + max_failed_projection = max(int(row["failed_projection_count"]) for row in profile_rows) + max_activation_count = max(int(row["activation_count"]) for row in profile_rows) + max_release_count = max(int(row["release_count"]) for row in profile_rows) max_weighted_gap = max(row["weighted_gap"] for row in profile_rows) max_multiplier_residual = max(row["multiplier_residual"] for row in profile_rows) + max_aug_factor = max(row["aug_factor"] for row in profile_rows) max_lambda = max(row["aug_lambda"] for row in profile_rows) max_masters = max(int(row["search_masters"]) for row in profile_rows) positive_pressure_steps = sum(1 for row in profile_rows if row["pressure"] > 0.0) @@ -71,6 +100,22 @@ def main() -> int: if max_masters < MIN_MASTER_FACETS: print("nonmatching master surface did not expose four contact facets") return 1 + if max_gap_l2 < max_gap: + print("gap L2 diagnostic is inconsistent with max gap") + return 1 + if max_failed_projection != 0: + print(f"unexpected failed projection count: {max_failed_projection}") + return 1 + if any( + int(row["active_set_flip_count"]) + < int(row["activation_count"]) + int(row["release_count"]) + for row in profile_rows + ): + print("active-set flip diagnostic is inconsistent") + return 1 + if max_aug_factor <= 0.0: + print("augmentation factor was not reported") + return 1 if positive_pressure_steps < 3: print("pressure profile is too short for a benchmark check") return 1 diff --git a/examples/shell_shell_contact/README.md b/examples/shell_shell_contact/README.md index e856792..d0322c7 100644 --- a/examples/shell_shell_contact/README.md +++ b/examples/shell_shell_contact/README.md @@ -32,3 +32,6 @@ Check: ``` The checker writes `shell_shell_contact_profile.csv` in the result directory. +In 0.5.3 it also validates shared contact diagnostics: state/status fields, +activation/release counts, active-set flip count, gap L2, failed projection +count and augmentation factor/lambda. diff --git a/examples/shell_shell_contact/check_contact_results.py b/examples/shell_shell_contact/check_contact_results.py index 340beaa..72f74f1 100644 --- a/examples/shell_shell_contact/check_contact_results.py +++ b/examples/shell_shell_contact/check_contact_results.py @@ -28,6 +28,13 @@ def main() -> int: "active_count", "force_norm", "gap_residual", + "gap_l2", + "failed_projection_count", + "active_set_flip_count", + "status", + "activation_count", + "release_count", + "aug_factor", "aug_lambda", "search_masters", ] @@ -40,6 +47,13 @@ def main() -> int: "active_count": int(float(row["active_count"])), "force_norm": float(row["force_norm"]), "gap_residual": float(row["gap_residual"]), + "gap_l2": float(row["gap_l2"]), + "failed_projection_count": int(float(row["failed_projection_count"])), + "active_set_flip_count": int(float(row["active_set_flip_count"])), + "status": int(float(row["status"])), + "activation_count": int(float(row["activation_count"])), + "release_count": int(float(row["release_count"])), + "aug_factor": float(row["aug_factor"]), "aug_lambda": float(row["aug_lambda"]), "search_masters": int(float(row.get("search_masters", "0") or "0")), } @@ -48,6 +62,9 @@ def main() -> int: max_active = max(int(float(row["active_count"])) for row in pair_rows) max_force = max(float(row["force_norm"]) for row in pair_rows) max_gap = max(float(row["gap_residual"]) for row in pair_rows) + max_gap_l2 = max(float(row["gap_l2"]) for row in pair_rows) + max_failed_projection = max(int(float(row["failed_projection_count"])) for row in pair_rows) + max_aug_factor = max(float(row["aug_factor"]) for row in pair_rows) max_lambda = max(float(row["aug_lambda"]) for row in pair_rows) max_masters = max(int(float(row.get("search_masters", "0") or "0")) for row in pair_rows) @@ -57,7 +74,20 @@ def main() -> int: if max_masters <= 0: print("shell-shell contact did not search a master shell facet") return 1 - if max_lambda <= 0.0: + if max_gap_l2 < max_gap: + print("shell-shell gap L2 diagnostic is inconsistent") + return 1 + if max_failed_projection != 0: + print(f"unexpected shell-shell failed projection count: {max_failed_projection}") + return 1 + if any( + int(float(row["active_set_flip_count"])) + < int(float(row["activation_count"])) + int(float(row["release_count"])) + for row in pair_rows + ): + print("shell-shell active-set flip diagnostic is inconsistent") + return 1 + if max_aug_factor <= 0.0 or max_lambda <= 0.0: print("shell-shell augmented multiplier did not grow") return 1 if not glob.glob(os.path.join(result_dir, "result_*.vtk")): diff --git a/examples/shell_solid_contact/README.md b/examples/shell_solid_contact/README.md index 30d501c..e4d750d 100644 --- a/examples/shell_solid_contact/README.md +++ b/examples/shell_solid_contact/README.md @@ -32,3 +32,6 @@ Check: ``` The checker writes `shell_solid_contact_profile.csv` in the result directory. +In 0.5.3 it also validates shared contact diagnostics: state/status fields, +activation/release counts, active-set flip count, gap L2, failed projection +count and augmentation factor/lambda. diff --git a/examples/shell_solid_contact/check_contact_results.py b/examples/shell_solid_contact/check_contact_results.py index f9e338d..78a3df2 100644 --- a/examples/shell_solid_contact/check_contact_results.py +++ b/examples/shell_solid_contact/check_contact_results.py @@ -28,6 +28,13 @@ def main() -> int: "active_count", "force_norm", "gap_residual", + "gap_l2", + "failed_projection_count", + "active_set_flip_count", + "status", + "activation_count", + "release_count", + "aug_factor", "aug_lambda", "search_masters", ] @@ -40,6 +47,13 @@ def main() -> int: "active_count": int(float(row["active_count"])), "force_norm": float(row["force_norm"]), "gap_residual": float(row["gap_residual"]), + "gap_l2": float(row["gap_l2"]), + "failed_projection_count": int(float(row["failed_projection_count"])), + "active_set_flip_count": int(float(row["active_set_flip_count"])), + "status": int(float(row["status"])), + "activation_count": int(float(row["activation_count"])), + "release_count": int(float(row["release_count"])), + "aug_factor": float(row["aug_factor"]), "aug_lambda": float(row["aug_lambda"]), "search_masters": int(float(row.get("search_masters", "0") or "0")), } @@ -48,6 +62,9 @@ def main() -> int: max_active = max(int(float(row["active_count"])) for row in pair_rows) max_force = max(float(row["force_norm"]) for row in pair_rows) max_gap = max(float(row["gap_residual"]) for row in pair_rows) + max_gap_l2 = max(float(row["gap_l2"]) for row in pair_rows) + max_failed_projection = max(int(float(row["failed_projection_count"])) for row in pair_rows) + max_aug_factor = max(float(row["aug_factor"]) for row in pair_rows) max_lambda = max(float(row["aug_lambda"]) for row in pair_rows) max_masters = max(int(float(row.get("search_masters", "0") or "0")) for row in pair_rows) @@ -57,7 +74,20 @@ def main() -> int: if max_masters <= 0: print("shell-solid contact did not search a solid master facet") return 1 - if max_lambda <= 0.0: + if max_gap_l2 < max_gap: + print("shell-solid gap L2 diagnostic is inconsistent") + return 1 + if max_failed_projection != 0: + print(f"unexpected shell-solid failed projection count: {max_failed_projection}") + return 1 + if any( + int(float(row["active_set_flip_count"])) + < int(float(row["activation_count"])) + int(float(row["release_count"])) + for row in pair_rows + ): + print("shell-solid active-set flip diagnostic is inconsistent") + return 1 + if max_aug_factor <= 0.0 or max_lambda <= 0.0: print("shell-solid augmented multiplier did not grow") return 1 if not glob.glob(os.path.join(result_dir, "result_*.vtk")): diff --git a/examples/spherical_cap_with_central_point_load/check_spherical_cap_results.py b/examples/spherical_cap_with_central_point_load/check_spherical_cap_results.py index 407c59e..a45d226 100644 --- a/examples/spherical_cap_with_central_point_load/check_spherical_cap_results.py +++ b/examples/spherical_cap_with_central_point_load/check_spherical_cap_results.py @@ -272,6 +272,12 @@ def collect_path_curve( residual_norm = float(row["residual_norm"]) relative_residual = float(row["relative_residual"]) correction_norm = float(row["correction_norm"]) + residual_total = float(row["residual_total"]) + residual_force = float(row["residual_force"]) + residual_contact = float(row["residual_contact"]) + residual_constraint = float(row["residual_constraint"]) + residual_arc = float(row["residual_arc"]) + material_failures = int(row["material_failure_count"]) target_dt = float(row["target_dt"]) actual_dt = float(row["actual_dt"]) next_dt = float(row["next_dt"]) @@ -306,6 +312,14 @@ def collect_path_curve( "accepted continuation row has negative trust_rejections") require(residual_linf <= 1.0e-8, "crown constraint residual is too large") require(residual_l2 <= 1.0e-8, "crown constraint residual norm is too large") + require(residual_total >= 0.0, "accepted row has negative total residual") + require(residual_force >= 0.0, "accepted row has negative force residual") + require(residual_contact >= 0.0, "accepted row has negative contact residual") + require(residual_constraint >= 0.0, + "accepted row has negative constraint residual") + require(residual_arc >= 0.0, "accepted row has negative arc residual") + require(material_failures >= 0, + "accepted row has negative material failure count") require(abs(actual - prescribed) <= 1.0e-8 * max(1.0, prescribed), "actual crown displacement differs from prescribed displacement") @@ -326,6 +340,12 @@ def collect_path_curve( "residual_norm": residual_norm, "relative_residual": relative_residual, "correction_norm": correction_norm, + "residual_total": residual_total, + "residual_force": residual_force, + "residual_contact": residual_contact, + "residual_constraint": residual_constraint, + "residual_arc": residual_arc, + "material_failure_count": float(material_failures), "target_dt": target_dt, "actual_dt": actual_dt, "next_dt": next_dt, @@ -408,6 +428,12 @@ def write_curve_csv(path: Path, records: list[dict[str, float]]) -> None: "residual_norm", "relative_residual", "correction_norm", + "residual_total", + "residual_force", + "residual_contact", + "residual_constraint", + "residual_arc", + "material_failure_count", "target_dt", "actual_dt", "next_dt", @@ -436,6 +462,12 @@ def write_curve_csv(path: Path, records: list[dict[str, float]]) -> None: "residual_norm": f"{record['residual_norm']:.10E}", "relative_residual": f"{record['relative_residual']:.10E}", "correction_norm": f"{record['correction_norm']:.10E}", + "residual_total": f"{record['residual_total']:.10E}", + "residual_force": f"{record['residual_force']:.10E}", + "residual_contact": f"{record['residual_contact']:.10E}", + "residual_constraint": f"{record['residual_constraint']:.10E}", + "residual_arc": f"{record['residual_arc']:.10E}", + "material_failure_count": int(record["material_failure_count"]), "target_dt": f"{record['target_dt']:.10E}", "actual_dt": f"{record['actual_dt']:.10E}", "next_dt": f"{record['next_dt']:.10E}", @@ -770,6 +802,12 @@ def main() -> int: "residual_norm": 0.0, "relative_residual": 0.0, "correction_norm": 0.0, + "residual_total": 0.0, + "residual_force": 0.0, + "residual_contact": 0.0, + "residual_constraint": 0.0, + "residual_arc": 0.0, + "material_failure_count": 0.0, "target_dt": 0.0, "actual_dt": 0.0, "next_dt": 0.0, diff --git a/src/base/fem_api.f90 b/src/base/fem_api.f90 index d86c75c..06e0949 100644 --- a/src/base/fem_api.f90 +++ b/src/base/fem_api.f90 @@ -643,6 +643,7 @@ contains total_cutback = 0 convergence_cutback_count = 0 convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE convergence_last_accepted_time = current_time do @@ -665,11 +666,17 @@ contains convergence_last_dt = dt_step convergence_status_code = CONVERGENCE_STATUS_CUTBACK convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE ierr = FEM_SUCCESS else convergence_cutback_count = total_cutback convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT + if (linear_solver_last_status .eq. LS_STATUS_FAILED) then + convergence_failure_reason_id = NFAIL_LINEAR_SOLVE + else + convergence_failure_reason_id = NFAIL_MIN_STEP + end if return end if end do @@ -692,6 +699,7 @@ contains 'nonlinear Newmark run stopped before end time', ierr) convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_STOPPED + convergence_failure_reason_id = NFAIL_STOPPED return end if diff --git a/src/base/fem_api_diagnostics.f90 b/src/base/fem_api_diagnostics.f90 index e89c713..8a16d6b 100644 --- a/src/base/fem_api_diagnostics.f90 +++ b/src/base/fem_api_diagnostics.f90 @@ -4,7 +4,7 @@ module fem_api_diagnostics use fem_control use fem_linear_solver_cg, only: linear_solver_configure, & linear_solver_get_settings, linear_solver_get_stats, & - linear_solver_get_diagnostics + linear_solver_get_diagnostics, linear_solver_get_fail_info use fem_api_state, only: api_initialized implicit none private @@ -12,12 +12,15 @@ module fem_api_diagnostics public :: fem_get_convergence_status public :: fem_get_convergence_metrics public :: fem_get_convergence_diagnostics + public :: fem_get_convergence_reason + public :: fem_get_residual_breakdown public :: fem_get_continuation_path_count public :: fem_get_continuation_path_row public :: fem_set_linear_solver public :: fem_get_linear_solver_settings public :: fem_get_linear_solver_stats public :: fem_get_linsol_diagnostics + public :: fem_get_linsol_failure_info public :: fem_set_shell_stabilization public :: fem_get_shell_stabilization public :: fem_get_shell_stability_stats @@ -48,6 +51,11 @@ contains if (present(contact_gap_norm)) then convergence_contact_gap_norm = contact_gap_norm end if + convergence_total_resid_norm = residual_norm + convergence_force_resid_norm = residual_norm + convergence_contact_resid_norm = convergence_contact_gap_norm + convergence_cons_resid_norm = ZERO + convergence_arc_resid_norm = ZERO convergence_combined_norm = max(convergence_rel_resid_norm, & max(convergence_correction_norm, convergence_contact_gap_norm)) convergence_last_dt = last_dt @@ -56,9 +64,11 @@ contains if (converged) then convergence_status_code = CONVERGENCE_STATUS_CONVERGED convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE else convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_NONCONVERGENCE + convergence_failure_reason_id = NFAIL_NONCONVERGENCE end if end subroutine fem_record_convergence @@ -144,6 +154,59 @@ contains ierr = FEM_SUCCESS end subroutine fem_get_convergence_diagnostics + subroutine fem_get_convergence_reason(reason_id, reason_name, ierr) + integer, intent(out) :: reason_id + character(len=*), intent(out) :: reason_name + integer, intent(out) :: ierr + + reason_id = NFAIL_NONE + reason_name = 'none' + + if (.not. api_initialized) then + call error_set(FEM_ERR_INTERNAL, & + 'fem_get_convergence_reason called before fem_initialize', ierr) + return + end if + + reason_id = convergence_failure_reason_id + call convergence_failure_reason_name(reason_id, reason_name) + ierr = FEM_SUCCESS + end subroutine fem_get_convergence_reason + + subroutine fem_get_residual_breakdown(total_residual, force_residual, & + contact_residual, constraint_residual, & + arc_residual, material_fail_count, & + ierr) + real(rk), intent(out) :: total_residual + real(rk), intent(out) :: force_residual + real(rk), intent(out) :: contact_residual + real(rk), intent(out) :: constraint_residual + real(rk), intent(out) :: arc_residual + integer, intent(out) :: material_fail_count + integer, intent(out) :: ierr + + total_residual = ZERO + force_residual = ZERO + contact_residual = ZERO + constraint_residual = ZERO + arc_residual = ZERO + material_fail_count = 0 + + if (.not. api_initialized) then + call error_set(FEM_ERR_INTERNAL, & + 'fem_get_residual_breakdown called before fem_initialize', ierr) + return + end if + + total_residual = convergence_total_resid_norm + force_residual = convergence_force_resid_norm + contact_residual = convergence_contact_resid_norm + constraint_residual = convergence_cons_resid_norm + arc_residual = convergence_arc_resid_norm + material_fail_count = convergence_material_fail_count + ierr = FEM_SUCCESS + end subroutine fem_get_residual_breakdown + subroutine fem_get_continuation_path_count(count, ierr) integer, intent(out) :: count integer, intent(out) :: ierr @@ -312,6 +375,20 @@ contains call linear_solver_get_diagnostics(matrix_class, initial_residual, & final_residual, relative_residual, status_code, ierr) end subroutine fem_get_linsol_diagnostics + subroutine fem_get_linsol_failure_info(failure_class, reason, ierr) + integer, intent(out) :: failure_class + character(len=*), intent(out) :: reason + integer, intent(out) :: ierr + failure_class = LS_FAIL_NONE + reason = 'none' + if (.not. api_initialized) then + call error_set(FEM_ERR_INTERNAL, & + 'fem_get_linsol_failure_diagnostics called before fem_initialize', & + ierr) + return + end if + call linear_solver_get_fail_info(failure_class, reason, ierr) + end subroutine fem_get_linsol_failure_info subroutine fem_set_shell_stabilization(drilling_factor, s3_shear_factor, & s3_shear_min_scale, ierr) real(rk), intent(in) :: drilling_factor diff --git a/src/base/fem_control.f90 b/src/base/fem_control.f90 index 6417b90..ba9669f 100644 --- a/src/base/fem_control.f90 +++ b/src/base/fem_control.f90 @@ -17,6 +17,22 @@ module fem_control integer, parameter :: CONV_FAIL_NONCONVERGENCE = 1 integer, parameter :: CONV_FAIL_CUTBACK_LIMIT = 2 integer, parameter :: CONV_FAIL_STOPPED = 3 + integer, parameter :: NFAIL_NONE = 0 + integer, parameter :: NFAIL_LINEAR_SOLVE = 10 + integer, parameter :: NFAIL_RESIDUAL_STAGNATION = 20 + integer, parameter :: NFAIL_CORRECTION_LIMIT = 30 + integer, parameter :: NFAIL_LINE_SEARCH = 40 + integer, parameter :: NFAIL_TRUST_REJECTION = 50 + integer, parameter :: NFAIL_CONTACT_ACTIVE_SET = 60 + integer, parameter :: NFAIL_CONTACT_PROJECTION = 61 + integer, parameter :: NFAIL_CONTACT_PENETRATION = 62 + integer, parameter :: NFAIL_FRICTION_SWITCH = 70 + integer, parameter :: NFAIL_MATERIAL_RETURN = 80 + integer, parameter :: NFAIL_ARC_CONSTRAINT = 90 + integer, parameter :: NFAIL_CONSTRAINT_RESIDUAL = 100 + integer, parameter :: NFAIL_MIN_STEP = 110 + integer, parameter :: NFAIL_NONCONVERGENCE = 120 + integer, parameter :: NFAIL_STOPPED = 130 integer, parameter :: LSOLVER_CG = 1 integer, parameter :: LSOLVER_BICGSTAB = 2 integer, parameter :: LSOLVER_GMRES = 3 @@ -28,6 +44,12 @@ module fem_control integer, parameter :: LS_STATUS_IDLE = 0 integer, parameter :: LS_STATUS_CONVERGED = 1 integer, parameter :: LS_STATUS_FAILED = -1 + integer, parameter :: LS_FAIL_NONE = 0 + integer, parameter :: LS_FAIL_NONCONVERGENCE = 1 + integer, parameter :: LS_FAIL_INVALID_MATRIX = 2 + integer, parameter :: LS_FAIL_DENSE_FALLBACK = 3 + integer, parameter :: LS_FAIL_CONFIGURATION = 4 + integer, parameter :: LS_FAIL_DIAGNOSTIC = 5 integer, parameter :: NLC_TWO_STAGE = 1 integer, parameter :: NLC_ADAPT_NEWTON = 2 integer, parameter :: NLC_TRUST_DAMPED = 3 @@ -64,7 +86,12 @@ module fem_control integer, parameter :: NLC_PATH_R_NEXT_TRUST_RADIUS = 22 integer, parameter :: NLC_PATH_R_TRUST_DAMPING = 23 integer, parameter :: NLC_PATH_R_TRUST_MERIT_RATIO = 24 - integer, parameter :: NLC_PATH_REAL_COUNT = 24 + integer, parameter :: NLC_PATH_R_TOTAL_RESIDUAL = 25 + integer, parameter :: NLC_PATH_R_FORCE_RESIDUAL = 26 + integer, parameter :: NLC_PATH_R_CONTACT_RESIDUAL = 27 + integer, parameter :: NLC_PATH_R_CONS_RESIDUAL = 28 + integer, parameter :: NLC_PATH_R_ARC_RESIDUAL = 29 + integer, parameter :: NLC_PATH_REAL_COUNT = 29 integer, parameter :: NLC_PATH_I_STEP = 1 integer, parameter :: NLC_PATH_I_CONTROL_DOF_COUNT = 2 integer, parameter :: NLC_PATH_I_ITERATION = 3 @@ -78,7 +105,9 @@ module fem_control integer, parameter :: NLC_PATH_I_CUTBACK_COUNT = 11 integer, parameter :: NLC_PATH_I_TRUST_ADJUST = 12 integer, parameter :: NLC_PATH_I_TRUST_REJECTIONS = 13 - integer, parameter :: NLC_PATH_INT_COUNT = 13 + integer, parameter :: NLC_PATH_I_REASON_ID = 14 + integer, parameter :: NLC_PATH_I_MATERIAL_FAIL_COUNT = 15 + integer, parameter :: NLC_PATH_INT_COUNT = 15 integer, parameter :: BUCKLING_MAX_GEOM_LINE = 64 integer, parameter :: BUCK_GEOM_EXPLICIT = 1 integer, parameter :: BUCK_GEOM_PRELOAD = 2 @@ -146,6 +175,7 @@ module fem_control integer :: linear_solver_last_iter = 0 integer :: linear_solver_last_status = LS_STATUS_IDLE integer :: linear_solver_last_matrix_class = 1 + integer :: linsol_last_fail_class = LS_FAIL_NONE integer :: nonlinear_linear_iter_limit = 0 integer :: nonlinear_continuation_method = NLC_DEFAULT integer :: buckling_num_modes = 1 @@ -177,11 +207,18 @@ module fem_control integer :: convergence_cutback_count = 0 integer :: convergence_status_code = CONVERGENCE_STATUS_IDLE integer :: convergence_failure_code = CONV_FAIL_NONE + integer :: convergence_failure_reason_id = NFAIL_NONE + integer :: convergence_material_fail_count = 0 real(rk) :: convergence_residual_norm = ZERO real(rk) :: convergence_rel_resid_norm = ZERO real(rk) :: convergence_correction_norm = ZERO real(rk) :: convergence_contact_gap_norm = ZERO real(rk) :: convergence_combined_norm = ZERO + real(rk) :: convergence_total_resid_norm = ZERO + real(rk) :: convergence_force_resid_norm = ZERO + real(rk) :: convergence_contact_resid_norm = ZERO + real(rk) :: convergence_cons_resid_norm = ZERO + real(rk) :: convergence_arc_resid_norm = ZERO real(rk) :: linear_solver_initial_resid = ZERO real(rk) :: linear_solver_last_resid = ZERO real(rk) :: linear_solver_relative_resid = ZERO @@ -199,6 +236,7 @@ module fem_control real(rk), allocatable :: nlc_path_real(:,:) integer, allocatable :: nlc_path_int(:,:) character(len=256) :: nonlinear_trace_file = ' ' + character(len=64) :: linear_solver_last_reason = 'idle' logical :: convergence_converged = .false. logical :: use_sph_coupling = .false. logical :: use_user_dt = .false. @@ -288,6 +326,8 @@ contains linear_solver_last_iter = 0 linear_solver_last_status = LS_STATUS_IDLE linear_solver_last_matrix_class = 1 + linsol_last_fail_class = LS_FAIL_NONE + linear_solver_last_reason = 'idle' nonlinear_linear_iter_limit = 0 nonlinear_continuation_method = NLC_DEFAULT buckling_num_modes = 1 @@ -327,11 +367,18 @@ contains convergence_cutback_count = 0 convergence_status_code = CONVERGENCE_STATUS_IDLE convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE + convergence_material_fail_count = 0 convergence_residual_norm = ZERO convergence_rel_resid_norm = ZERO convergence_correction_norm = ZERO convergence_contact_gap_norm = ZERO convergence_combined_norm = ZERO + convergence_total_resid_norm = ZERO + convergence_force_resid_norm = ZERO + convergence_contact_resid_norm = ZERO + convergence_cons_resid_norm = ZERO + convergence_arc_resid_norm = ZERO linear_solver_initial_resid = ZERO linear_solver_last_resid = ZERO linear_solver_relative_resid = ZERO @@ -445,6 +492,16 @@ contains nlc_path_real(NLC_PATH_R_TRUST_DAMPING, row) = nlc_last_damping nlc_path_real(NLC_PATH_R_TRUST_MERIT_RATIO, row) = & nlc_last_merit_ratio + nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, row) = & + convergence_total_resid_norm + nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, row) = & + convergence_force_resid_norm + nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, row) = & + convergence_contact_resid_norm + nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, row) = & + convergence_cons_resid_norm + nlc_path_real(NLC_PATH_R_ARC_RESIDUAL, row) = & + convergence_arc_resid_norm nlc_path_int(NLC_PATH_I_STEP, row) = step nlc_path_int(NLC_PATH_I_CONTROL_DOF_COUNT, row) = control_dof_count @@ -459,11 +516,93 @@ contains nlc_path_int(NLC_PATH_I_CUTBACK_COUNT, row) = convergence_cutback_count nlc_path_int(NLC_PATH_I_TRUST_ADJUST, row) = nlc_last_trust_adjust nlc_path_int(NLC_PATH_I_TRUST_REJECTIONS, row) = nlc_last_rejections + nlc_path_int(NLC_PATH_I_REASON_ID, row) = convergence_failure_reason_id + nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, row) = & + convergence_material_fail_count nlc_path_count = row ierr = FEM_SUCCESS end subroutine nlc_path_append + integer function convergence_reason_from_failure(failure_code) result(reason_id) + integer, intent(in) :: failure_code + + select case (failure_code) + case (CONV_FAIL_NONE) + reason_id = NFAIL_NONE + case (CONV_FAIL_NONCONVERGENCE) + reason_id = NFAIL_NONCONVERGENCE + case (CONV_FAIL_CUTBACK_LIMIT) + reason_id = NFAIL_MIN_STEP + case (CONV_FAIL_STOPPED) + reason_id = NFAIL_STOPPED + case default + reason_id = NFAIL_NONCONVERGENCE + end select + end function convergence_reason_from_failure + + subroutine convergence_failure_reason_name(reason_id, reason_name) + integer, intent(in) :: reason_id + character(len=*), intent(out) :: reason_name + + reason_name = 'unknown' + select case (reason_id) + case (NFAIL_NONE) + reason_name = 'none' + case (NFAIL_LINEAR_SOLVE) + reason_name = 'linear-solve-failure' + case (NFAIL_RESIDUAL_STAGNATION) + reason_name = 'residual-stagnation' + case (NFAIL_CORRECTION_LIMIT) + reason_name = 'correction-norm-limit' + case (NFAIL_LINE_SEARCH) + reason_name = 'line-search-failure' + case (NFAIL_TRUST_REJECTION) + reason_name = 'trust-rejection' + case (NFAIL_CONTACT_ACTIVE_SET) + reason_name = 'contact-active-set-oscillation' + case (NFAIL_CONTACT_PROJECTION) + reason_name = 'contact-projection-failure' + case (NFAIL_CONTACT_PENETRATION) + reason_name = 'contact-excessive-penetration' + case (NFAIL_FRICTION_SWITCH) + reason_name = 'friction-stick-slip-switching' + case (NFAIL_MATERIAL_RETURN) + reason_name = 'material-return-failure' + case (NFAIL_ARC_CONSTRAINT) + reason_name = 'arc-constraint-failure' + case (NFAIL_CONSTRAINT_RESIDUAL) + reason_name = 'constraint-residual-failure' + case (NFAIL_MIN_STEP) + reason_name = 'minimum-step-exhausted' + case (NFAIL_NONCONVERGENCE) + reason_name = 'nonlinear-nonconvergence' + case (NFAIL_STOPPED) + reason_name = 'run-stopped' + end select + end subroutine convergence_failure_reason_name + + subroutine linsol_fail_class_name(failure_class, class_name) + integer, intent(in) :: failure_class + character(len=*), intent(out) :: class_name + + class_name = 'unknown' + select case (failure_class) + case (LS_FAIL_NONE) + class_name = 'none' + case (LS_FAIL_NONCONVERGENCE) + class_name = 'linear-nonconvergence' + case (LS_FAIL_INVALID_MATRIX) + class_name = 'invalid-matrix-class' + case (LS_FAIL_DENSE_FALLBACK) + class_name = 'dense-fallback-failure' + case (LS_FAIL_CONFIGURATION) + class_name = 'linear-configuration-failure' + case (LS_FAIL_DIAGNOSTIC) + class_name = 'linear-diagnostic-failure' + end select + end subroutine linsol_fail_class_name + subroutine nlc_path_ensure_capacity(required, ierr) integer, intent(in) :: required integer, intent(out) :: ierr diff --git a/src/base/fem_precision.f90 b/src/base/fem_precision.f90 index 8431e43..7fbd0b7 100644 --- a/src/base/fem_precision.f90 +++ b/src/base/fem_precision.f90 @@ -16,7 +16,7 @@ module fem_precision integer, parameter :: FEMLITE_VERSION_MAJOR = 0 integer, parameter :: FEMLITE_VERSION_MINOR = 5 - integer, parameter :: FEMLITE_VERSION_PATCH = 2 + integer, parameter :: FEMLITE_VERSION_PATCH = 3 real(rk), parameter :: ZERO = 0.0_rk real(rk), parameter :: ONE = 1.0_rk diff --git a/src/boundary/fem_contact_history.f90 b/src/boundary/fem_contact_history.f90 index ebb4ae6..dc9b4aa 100644 --- a/src/boundary/fem_contact_history.f90 +++ b/src/boundary/fem_contact_history.f90 @@ -11,12 +11,19 @@ module fem_contact_history public :: contact_history_reset public :: contact_history_stats public :: contact_history_state_stats + public :: contact_history_stable_counts public :: contact_history_write public :: contact_history_read integer, parameter, public :: CONTACT_HIST_OPEN = 0 integer, parameter, public :: CONTACT_HIST_STICK = 1 integer, parameter, public :: CONTACT_HIST_SLIP = 2 + integer, parameter, public :: CONTACT_STATE_OPEN = 0 + integer, parameter, public :: CONTACT_STATE_CLOSED_STICK = 1 + integer, parameter, public :: CONTACT_STATE_CLOSED_SLIP = 2 + integer, parameter, public :: CONTACT_STATE_CLOSED_RESTICK = 3 + integer, parameter, public :: CONTACT_STATE_SEPARATING = 4 + integer, parameter, public :: CONTACT_STATE_FAILED_PROJ = 5 integer, allocatable :: hist_pair(:) integer, allocatable :: hist_slave_elem(:) @@ -84,6 +91,44 @@ contains end do end subroutine contact_history_state_stats + subroutine contact_history_stable_counts(slot_count, open_count, & + closed_stick_count, & + closed_slip_count, & + closed_restick_count, & + separating_count, & + failed_projection_count) + integer, intent(out) :: slot_count + integer, intent(out) :: open_count + integer, intent(out) :: closed_stick_count + integer, intent(out) :: closed_slip_count + integer, intent(out) :: closed_restick_count + integer, intent(out) :: separating_count + integer, intent(out) :: failed_projection_count + integer :: slot + + slot_count = hist_count + open_count = 0 + closed_stick_count = 0 + closed_slip_count = 0 + closed_restick_count = 0 + separating_count = 0 + failed_projection_count = 0 + if (hist_count .le. 0 .or. .not. allocated(hist_status)) return + + do slot = 1, hist_count + select case (hist_status(slot)) + case (CONTACT_HIST_OPEN) + open_count = open_count + 1 + case (CONTACT_HIST_STICK) + closed_stick_count = closed_stick_count + 1 + case (CONTACT_HIST_SLIP) + closed_slip_count = closed_slip_count + 1 + case default + failed_projection_count = failed_projection_count + 1 + end select + end do + end subroutine contact_history_stable_counts + subroutine contact_history_write(unit_id, ios) integer, intent(in) :: unit_id integer, intent(out) :: ios diff --git a/src/boundary/fem_contact_mortar_tangent.f90 b/src/boundary/fem_contact_mortar_tangent.f90 index e636575..4db14cc 100644 --- a/src/boundary/fem_contact_mortar_tangent.f90 +++ b/src/boundary/fem_contact_mortar_tangent.f90 @@ -47,6 +47,12 @@ module fem_contact_mortar_tangent real(rk) :: col_sum_norm = ZERO real(rk) :: max_asym = ZERO real(rk) :: max_translation_residual = ZERO + real(rk) :: normal_rigid_residual = ZERO + real(rk) :: normal_relative_fd_error = ZERO + real(rk) :: stick_relative_fd_error = ZERO + real(rk) :: slip_relative_fd_error = ZERO + real(rk) :: friction_rigid_residual = ZERO + real(rk) :: friction_energy_residual = ZERO real(rk) :: energy_probe = ZERO logical :: balance_ok = .false. logical :: translation_ok = .false. @@ -64,6 +70,7 @@ module fem_contact_mortar_tangent public :: mortar_tan_block_values public :: mortar_tan_row_balance public :: mortar_tan_audit_matrix + public :: mortar_tan_audit_friction contains @@ -319,6 +326,7 @@ contains real(rk) :: probe(MORTAR_TAN_MAX_DOF) real(rk) :: force(MORTAR_TAN_MAX_DOF) + real(rk) :: matrix_norm integer :: idir integer :: inode integer :: i @@ -360,8 +368,15 @@ contains end do audit%max_translation_residual = max(audit%max_translation_residual, & maxval(abs(force(1:ndof)))) + if (idir .eq. NDIM) audit%normal_rigid_residual = & + maxval(abs(force(1:ndof))) end do + matrix_norm = maxval(abs(k_local(1:ndof,1:ndof))) + if (matrix_norm .gt. tiny(ONE)) then + audit%normal_relative_fd_error = audit%normal_rigid_residual / matrix_norm + end if + probe = ZERO force = ZERO do i = 1, ndof @@ -383,6 +398,38 @@ contains call error_clear(ierr) end subroutine mortar_tan_audit_matrix + subroutine mortar_tan_audit_friction(ndof, k_local, mode, balance_tol, & + audit, ierr) + integer, intent(in) :: ndof + real(rk), intent(in) :: k_local(:,:) + integer, intent(in) :: mode + real(rk), intent(in) :: balance_tol + type(mortar_tangent_audit), intent(out) :: audit + integer, intent(out) :: ierr + + real(rk) :: matrix_norm + real(rk) :: rel_error + + if (mode .ne. MORTAR_TAN_STICK .and. mode .ne. MORTAR_TAN_SLIP) then + call error_set(FEM_ERR_INPUT, 'unknown mortar friction audit mode', ierr) + return + end if + call mortar_tan_audit_matrix(ndof, k_local, balance_tol, audit, ierr) + if (ierr .ne. FEM_SUCCESS) return + + matrix_norm = maxval(abs(k_local(1:ndof,1:ndof))) + rel_error = ZERO + if (matrix_norm .gt. tiny(ONE)) rel_error = audit%max_asym / matrix_norm + if (mode .eq. MORTAR_TAN_STICK) then + audit%stick_relative_fd_error = rel_error + else + audit%slip_relative_fd_error = rel_error + end if + audit%friction_rigid_residual = audit%max_translation_residual + audit%friction_energy_residual = abs(min(ZERO, audit%energy_probe)) + call error_clear(ierr) + end subroutine mortar_tan_audit_friction + subroutine build_tangent(cons, params, mode, ndof, k_local, diag, ierr) type(mortar_constraint), intent(in) :: cons type(mortar_tangent_params), intent(in) :: params @@ -575,6 +622,12 @@ contains audit%col_sum_norm = ZERO audit%max_asym = ZERO audit%max_translation_residual = ZERO + audit%normal_rigid_residual = ZERO + audit%normal_relative_fd_error = ZERO + audit%stick_relative_fd_error = ZERO + audit%slip_relative_fd_error = ZERO + audit%friction_rigid_residual = ZERO + audit%friction_energy_residual = ZERO audit%energy_probe = ZERO audit%balance_ok = .false. audit%translation_ok = .false. diff --git a/src/boundary/fem_contact_multiplier.f90 b/src/boundary/fem_contact_multiplier.f90 index 5b759aa..cb5e0a5 100644 --- a/src/boundary/fem_contact_multiplier.f90 +++ b/src/boundary/fem_contact_multiplier.f90 @@ -1,6 +1,10 @@ module fem_contact_multiplier use fem_precision use fem_error + use fem_contact_history, only: CONTACT_STATE_OPEN, & + CONTACT_STATE_CLOSED_STICK, CONTACT_STATE_CLOSED_SLIP, & + CONTACT_STATE_CLOSED_RESTICK, CONTACT_STATE_SEPARATING, & + CONTACT_STATE_FAILED_PROJ implicit none private @@ -17,6 +21,8 @@ module fem_contact_multiplier public :: contact_multiplier_old public :: contact_multiplier_stats public :: contact_multiplier_full_stats + public :: contact_multiplier_state_counts + public :: contact_multiplier_resid_stats public :: contact_multiplier_entry public :: contact_multiplier_status_name public :: contact_multiplier_compact @@ -185,6 +191,100 @@ contains call error_clear(ierr) end subroutine contact_multiplier_full_stats + subroutine contact_multiplier_state_counts(slot_count, open_count, & + closed_stick_count, & + closed_slip_count, & + closed_restick_count, & + separating_count, & + failed_projection_count, ierr) + integer, intent(out) :: slot_count + integer, intent(out) :: open_count + integer, intent(out) :: closed_stick_count + integer, intent(out) :: closed_slip_count + integer, intent(out) :: closed_restick_count + integer, intent(out) :: separating_count + integer, intent(out) :: failed_projection_count + integer, intent(out) :: ierr + integer :: slot + integer :: state_id + + slot_count = mult_count + open_count = 0 + closed_stick_count = 0 + closed_slip_count = 0 + closed_restick_count = 0 + separating_count = 0 + failed_projection_count = 0 + + if (mult_count .le. 0) then + call error_clear(ierr) + return + end if + if (.not. allocated(mult_status)) then + failed_projection_count = mult_count + call error_set(FEM_ERR_INTERNAL, & + 'contact multiplier state count found missing status array', ierr) + return + end if + + do slot = 1, mult_count + if (.not. valid_multiplier_status(mult_status(slot))) then + state_id = CONTACT_STATE_FAILED_PROJ + else if (mult_status(slot) .eq. CONTACT_MULT_ACTIVE) then + state_id = CONTACT_STATE_CLOSED_STICK + else if (mult_status(slot) .eq. CONTACT_MULT_RELEASED) then + state_id = CONTACT_STATE_SEPARATING + else + state_id = CONTACT_STATE_OPEN + end if + + select case (state_id) + case (CONTACT_STATE_OPEN) + open_count = open_count + 1 + case (CONTACT_STATE_CLOSED_STICK) + closed_stick_count = closed_stick_count + 1 + case (CONTACT_STATE_CLOSED_SLIP) + closed_slip_count = closed_slip_count + 1 + case (CONTACT_STATE_CLOSED_RESTICK) + closed_restick_count = closed_restick_count + 1 + case (CONTACT_STATE_SEPARATING) + separating_count = separating_count + 1 + case default + failed_projection_count = failed_projection_count + 1 + end select + end do + call error_clear(ierr) + end subroutine contact_multiplier_state_counts + + subroutine contact_multiplier_resid_stats(normal_residual, update_count, & + ierr) + real(rk), intent(out) :: normal_residual + integer, intent(out) :: update_count + integer, intent(out) :: ierr + integer :: slot + real(rk) :: diff + + normal_residual = ZERO + update_count = 0 + if (mult_count .le. 0) then + call error_clear(ierr) + return + end if + if (.not. allocated(mult_lambda) .or. & + .not. allocated(mult_trial_lambda)) then + call error_set(FEM_ERR_INTERNAL, & + 'contact multiplier residual stats found missing arrays', ierr) + return + end if + + do slot = 1, mult_count + diff = abs(mult_trial_lambda(slot) - mult_lambda(slot)) + normal_residual = max(normal_residual, diff) + if (diff .gt. tiny(ONE)) update_count = update_count + 1 + end do + call error_clear(ierr) + end subroutine contact_multiplier_resid_stats + subroutine contact_multiplier_audit(slot_count, active_count, & released_count, open_count, & duplicate_count, invalid_count, & diff --git a/src/boundary/fem_contact_multiplier_report.f90 b/src/boundary/fem_contact_multiplier_report.f90 index 7434a11..7383255 100644 --- a/src/boundary/fem_contact_multiplier_report.f90 +++ b/src/boundary/fem_contact_multiplier_report.f90 @@ -67,14 +67,23 @@ contains integer :: active integer :: released integer :: open_count + integer :: state_slots + integer :: state_open + integer :: state_stick + integer :: state_slip + integer :: state_restick + integer :: state_separating + integer :: state_failed_proj integer :: duplicate_count integer :: invalid_count real(rk) :: max_lambda real(rk) :: max_trial real(rk) :: max_gap real(rk) :: max_commit_error + real(rk) :: normal_residual + integer :: al_update_count - if (len(line) .lt. 256) then + if (len(line) .lt. 512) then call error_set(FEM_ERR_OUTPUT, 'contact multiplier summary too small', & ierr) return @@ -86,12 +95,26 @@ contains duplicate_count, invalid_count, max_lambda, max_gap, max_commit_error, & ierr) if (ierr .ne. FEM_SUCCESS) return + call contact_multiplier_state_counts(state_slots, state_open, & + state_stick, state_slip, state_restick, state_separating, & + state_failed_proj, ierr) + if (ierr .ne. FEM_SUCCESS) return + call contact_multiplier_resid_stats(normal_residual, al_update_count, ierr) + if (ierr .ne. FEM_SUCCESS) return write(line, '(A,I0,A,I0,A,I0,A,I0,A,ES16.8,A,ES16.8,A,ES16.8,' // & - 'A,I0,A,I0,A,ES16.8)') & + 'A,I0,A,I0,A,ES16.8,A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,' // & + 'A,ES16.8,A,I0)') & 'slots=', slots, ',active=', active, ',released=', released, & ',open=', open_count, ',max_lambda=', max_lambda, ',max_trial=', & max_trial, ',max_gap=', max_gap, ',duplicates=', duplicate_count, & - ',invalid=', invalid_count, ',max_commit_error=', max_commit_error + ',invalid=', invalid_count, ',max_commit_error=', max_commit_error, & + ',state_slots=', state_slots, ',state_open=', state_open, & + ',state_closed_stick=', state_stick, ',state_closed_slip=', state_slip, & + ',state_closed_restick=', state_restick, & + ',state_separating=', state_separating, & + ',state_failed_projection=', state_failed_proj, & + ',normal_multiplier_residual=', normal_residual, & + ',al_update_count=', al_update_count call error_clear(ierr) end subroutine contact_mult_report_summary @@ -99,7 +122,7 @@ contains character(len=*), intent(in) :: filename integer, intent(out) :: ierr - character(len=256) :: line + character(len=512) :: line integer :: unit integer :: ios integer :: slot diff --git a/src/element/fem_element_internal.f90 b/src/element/fem_element_internal.f90 index 32999ed..64b1d4c 100644 --- a/src/element/fem_element_internal.f90 +++ b/src/element/fem_element_internal.f90 @@ -37,6 +37,7 @@ contains if (present(dt)) dt_local = dt fint = ZERO + convergence_material_fail_count = 0 do elem = 1, nelem if (elem_status(elem) .ne. 0) cycle @@ -139,6 +140,7 @@ contains stress(:,gp) = sig statev(:,gp) = state_new if (state_new(4) .ge. HALF) then + convergence_material_fail_count = convergence_material_fail_count + 1 elem_status(elem) = 1 stress(:,gp) = ZERO return @@ -271,6 +273,9 @@ contains gp = gp + 1 end do + convergence_material_fail_count = convergence_material_fail_count + & + failed_count + if (failed_count .ge. 4) then elem_status(elem) = 1 if (gp_start .gt. 0) stress(:,gp_start:gp_start+7) = ZERO @@ -372,6 +377,9 @@ contains gp = gp + 1 end do + convergence_material_fail_count = convergence_material_fail_count + & + failed_count + if (should_delete_solid(elem_type(elem), failed_count, npoint)) then elem_status(elem) = 1 if (gp_start .gt. 0) stress(:,gp_start:gp_start+npoint-1) = ZERO diff --git a/src/output/fem_output_csv.f90 b/src/output/fem_output_csv.f90 index 7b62db5..2c0c73b 100644 --- a/src/output/fem_output_csv.f90 +++ b/src/output/fem_output_csv.f90 @@ -345,6 +345,7 @@ contains integer :: unit_id integer :: ios integer :: row + character(len=64) :: reason_name if (nlc_path_count .le. 0) then ierr = FEM_SUCCESS @@ -372,7 +373,10 @@ contains 'adapt_adjust,cutback_count,trust_adjust,trust_rejections,'// & 'status_code,failure_code,linear_method,linear_precond,'// & 'linear_iterations,linear_status,linear_initial_residual,'// & - 'linear_final_residual,linear_relative_residual' + 'linear_final_residual,linear_relative_residual,'// & + 'residual_total,residual_force,residual_contact,'// & + 'residual_constraint,residual_arc,material_failure_count,'// & + 'reason_id,reason_name' if (ios .ne. 0) then close(unit_id) call error_set(FEM_ERR_OUTPUT, & @@ -381,8 +385,11 @@ contains end if do row = 1, nlc_path_count + call convergence_failure_reason_name( & + nlc_path_int(NLC_PATH_I_REASON_ID, row), reason_name) write(unit_id,'(I12,2(A,ES24.16),A,I12,9(A,ES24.16),'// & - 'A,I12,10(A,ES24.16),10(A,I12),3(A,ES24.16))',iostat=ios) & + 'A,I12,10(A,ES24.16),10(A,I12),3(A,ES24.16))', & + iostat=ios, advance='no') & nlc_path_int(NLC_PATH_I_STEP, row), & ',', nlc_path_real(NLC_PATH_R_TIME, row), & ',', nlc_path_real(NLC_PATH_R_PARAMETER, row), & @@ -420,6 +427,20 @@ contains ',', nlc_path_real(NLC_PATH_R_LIN_INIT_RESID, row), & ',', nlc_path_real(NLC_PATH_R_LIN_FINAL_RESID, row), & ',', nlc_path_real(NLC_PATH_R_LIN_REL_RESID, row) + if (ios .eq. 0) then + write(unit_id,'(5(A,ES24.16),A,I12)',iostat=ios, advance='no') & + ',', nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, row), & + ',', nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, row), & + ',', nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, row), & + ',', nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, row), & + ',', nlc_path_real(NLC_PATH_R_ARC_RESIDUAL, row), & + ',', nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, row) + end if + if (ios .eq. 0) then + write(unit_id,'(A,I12,A,A)',iostat=ios) & + ',', nlc_path_int(NLC_PATH_I_REASON_ID, row), & + ',', trim(reason_name) + end if if (ios .ne. 0) then close(unit_id) call error_set(FEM_ERR_OUTPUT, & @@ -541,8 +562,11 @@ contains write(unit_id,'(A)',iostat=ios) & 'kind,pair_id,active_count,max_penetration,force_norm,work_estimate,'// & 'cumulative_work,stick_count,slip_count,accumulated_slip,'// & + 'slip_increment_norm,slip_residual,friction_residual,'// & 'friction_work,friction_work_total,friction_regularization,ftx,fty,ftz,'// & - 'status,activation_count,release_count,gap_residual,aug_factor,aug_lambda,'// & + 'status,activation_count,release_count,gap_residual,gap_mean,'// & + 'gap_l2,failed_projection_count,active_set_flip_count,'// & + 'aug_factor,aug_lambda,'// & 'search_facets,search_masters,search_candidates,search_active,'// & 'search_bvh_nodes,search_cache_used,search_cache_overflow,'// & 'search_cpu_time,contact_force_cpu_time,'// & @@ -560,6 +584,9 @@ contains integer :: search_facets, search_masters, search_broad, search_active integer :: search_bvh_nodes, cache_used, cache_overflow real(rk) :: search_time, force_time, tangent_time + real(rk) :: gap_residual, gap_mean, gap_l2 + real(rk) :: slip_inc, slip_residual, friction_residual + integer :: failed_projection, active_set_flip integer :: ios call contact_get_search_stats(search_facets, search_masters, & @@ -567,16 +594,24 @@ contains search_bvh_nodes) call contact_get_perf_stats(search_time, force_time, tangent_time) call contact_get_cache_stats(cache_used, cache_overflow) + call output_csv_contact_gap_stats(0, gap_residual, gap_mean, gap_l2, & + failed_projection, active_set_flip) + call output_csv_contact_slip_stats(0, slip_inc, slip_residual, & + friction_residual) write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16),2(A,I12),'// & - '7(A,ES24.16),3(A,I12),3(A,ES24.16),7(A,I12),'// & + '10(A,ES24.16),3(A,I12),3(A,ES24.16),2(A,I12),'// & + '2(A,ES24.16),7(A,I12),'// & '3(A,ES24.16))',iostat=ios) & 'SUMMARY', ',', 0, ',', contact_active_count, & ',', contact_max_penetration, ',', contact_force_norm, & ',', contact_work_step, ',', contact_work_total, ',', 0, ',', 0, & - ',', ZERO, ',', contact_friction_work_step, & + ',', ZERO, ',', slip_inc, ',', slip_residual, ',', friction_residual, & + ',', contact_friction_work_step, & ',', contact_friction_work_total, ',', ZERO, & ',', ZERO, ',', ZERO, ',', ZERO, & - ',', 0, ',', 0, ',', 0, ',', ZERO, ',', ZERO, ',', ZERO, & + ',', 0, ',', 0, ',', 0, ',', gap_residual, ',', gap_mean, & + ',', gap_l2, ',', failed_projection, ',', active_set_flip, & + ',', ZERO, ',', ZERO, & ',', search_facets, ',', search_masters, ',', search_broad, & ',', search_active, ',', search_bvh_nodes, ',', cache_used, & ',', cache_overflow, ',', search_time, ',', force_time, ',', tangent_time @@ -595,7 +630,10 @@ contains integer :: search_facets, search_masters, search_broad, search_active integer :: search_bvh_nodes, cache_used, cache_overflow real(rk) :: max_pen, force_sum, work_sum + real(rk) :: gap_residual, gap_mean, gap_l2 + real(rk) :: slip_inc, slip_residual, friction_residual real(rk) :: search_time, force_time, tangent_time + integer :: failed_projection, active_set_flip integer :: ios active = 0 @@ -611,14 +649,20 @@ contains call contact_get_pair_stats(pair, search_facets, search_masters, & search_broad, search_active, search_bvh_nodes, cache_used, & cache_overflow, search_time, force_time, tangent_time) + call output_csv_contact_gap_stats(pair, gap_residual, gap_mean, gap_l2, & + failed_projection, active_set_flip) + call output_csv_contact_slip_stats(pair, slip_inc, slip_residual, & + friction_residual) write(unit_id,'(A,A,I12,A,I12,4(A,ES24.16),2(A,I12),'// & - '7(A,ES24.16),3(A,I12),3(A,ES24.16),7(A,I12),'// & + '10(A,ES24.16),3(A,I12),3(A,ES24.16),2(A,I12),'// & + '2(A,ES24.16),7(A,I12),'// & '3(A,ES24.16))',iostat=ios) & 'PAIR', ',', pair, ',', active, ',', max_pen, ',', force_sum, & ',', work_sum, ',', ZERO, & ',', contact_pair_stick_value(pair), ',', contact_pair_slip_value(pair), & ',', contact_pair_accumulated_slip(pair), & + ',', slip_inc, ',', slip_residual, ',', friction_residual, & ',', contact_pair_fric_work_value(pair), & ',', contact_pair_fric_total_value(pair), & ',', contact_pair_fric_reg_value(pair), & @@ -628,7 +672,8 @@ contains ',', contact_pair_status_value(pair), & ',', contact_pair_activation_value(pair), & ',', contact_pair_release_value(pair), & - ',', contact_pair_gap_value(pair), & + ',', gap_residual, ',', gap_mean, ',', gap_l2, & + ',', failed_projection, ',', active_set_flip, & ',', contact_pair_aug_factor_value(pair), & ',', contact_pair_aug_lambda_value(pair), & ',', search_facets, ',', search_masters, ',', search_broad, & @@ -642,6 +687,94 @@ contains end subroutine output_csv_contact_pair + subroutine output_csv_contact_gap_stats(pair, gap_residual, gap_mean, & + gap_l2, failed_projection, & + active_set_flip) + integer, intent(in) :: pair + real(rk), intent(out) :: gap_residual + real(rk), intent(out) :: gap_mean + real(rk), intent(out) :: gap_l2 + integer, intent(out) :: failed_projection + integer, intent(out) :: active_set_flip + integer :: idx + integer :: count + real(rk) :: gap + real(rk) :: gap_sum + real(rk) :: gap_sq + + gap_residual = ZERO + gap_mean = ZERO + gap_l2 = ZERO + failed_projection = 0 + active_set_flip = 0 + + if (pair .gt. 0) then + gap_residual = contact_pair_gap_value(pair) + gap_mean = gap_residual + gap_l2 = gap_residual + active_set_flip = contact_pair_activation_value(pair) + & + contact_pair_release_value(pair) + return + end if + + if (ncontact_pair .le. 0) return + count = 0 + gap_sum = ZERO + gap_sq = ZERO + do idx = 1, ncontact_pair + gap = contact_pair_gap_value(idx) + gap_residual = max(gap_residual, gap) + gap_sum = gap_sum + gap + gap_sq = gap_sq + gap * gap + active_set_flip = active_set_flip + & + contact_pair_activation_value(idx) + contact_pair_release_value(idx) + count = count + 1 + end do + if (count .gt. 0) then + gap_mean = gap_sum / real(count, rk) + gap_l2 = sqrt(gap_sq) + end if + end subroutine output_csv_contact_gap_stats + + subroutine output_csv_contact_slip_stats(pair, slip_increment, & + slip_residual, friction_residual) + integer, intent(in) :: pair + real(rk), intent(out) :: slip_increment + real(rk), intent(out) :: slip_residual + real(rk), intent(out) :: friction_residual + integer :: idx + real(rk) :: tangent_norm + + slip_increment = ZERO + slip_residual = ZERO + friction_residual = ZERO + + if (pair .gt. 0) then + slip_increment = contact_pair_accumulated_slip(pair) + if (contact_pair_slip_value(pair) .gt. 0) slip_residual = slip_increment + friction_residual = sqrt( & + contact_pair_tangent_component(pair, 1) ** 2 + & + contact_pair_tangent_component(pair, 2) ** 2 + & + contact_pair_tangent_component(pair, 3) ** 2) + return + end if + + if (ncontact_pair .le. 0) return + do idx = 1, ncontact_pair + slip_increment = max(slip_increment, & + contact_pair_accumulated_slip(idx)) + if (contact_pair_slip_value(idx) .gt. 0) then + slip_residual = max(slip_residual, & + contact_pair_accumulated_slip(idx)) + end if + tangent_norm = sqrt( & + contact_pair_tangent_component(idx, 1) ** 2 + & + contact_pair_tangent_component(idx, 2) ** 2 + & + contact_pair_tangent_component(idx, 3) ** 2) + friction_residual = max(friction_residual, tangent_norm) + end do + end subroutine output_csv_contact_slip_stats + diff --git a/src/output/fem_restart.f90 b/src/output/fem_restart.f90 index e9aa007..d19beb8 100644 --- a/src/output/fem_restart.f90 +++ b/src/output/fem_restart.f90 @@ -56,6 +56,8 @@ contains if (ios .ne. 0) go to 900 call contact_multiplier_write(unit_id, ios) if (ios .ne. 0) go to 900 + call write_contact_pair_diag(unit_id, ios) + if (ios .ne. 0) go to 900 write(unit_id,'(A)',iostat=ios) 'END' if (ios .ne. 0) go to 900 @@ -102,7 +104,7 @@ contains read(unit_id,*,iostat=ios) tag, version if (ios .ne. 0 .or. trim(tag) .ne. 'FEMLITE_RESTART') go to 910 - if (version .lt. 1 .or. version .gt. 3) then + if (version .lt. 1 .or. version .gt. 4) then close(unit_id) call error_set(FEM_ERR_OUTPUT, 'unsupported restart version', ierr) return @@ -168,7 +170,7 @@ contains integer, intent(in) :: unit_id integer, intent(out) :: ios - write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 3 + write(unit_id,'(A,1X,I4)',iostat=ios) 'FEMLITE_RESTART', 4 if (ios .ne. 0) return write(unit_id,'(A,4(1X,I12))',iostat=ios) 'COUNTS', nnode, nelem, & ndof, ngauss_total @@ -218,8 +220,8 @@ contains end if call contact_multiplier_read(unit_id, mult_slots, ierr) if (ierr .ne. FEM_SUCCESS) return - read(unit_id,*,iostat=ios) tag - if (ios .ne. 0 .or. trim(tag) .ne. 'END') go to 920 + call read_diag_or_end(unit_id, ierr) + if (ierr .ne. FEM_SUCCESS) return else if (trim(tag) .eq. 'END') then call contact_multiplier_read(unit_id, 0, ierr) if (ierr .ne. FEM_SUCCESS) return @@ -236,8 +238,8 @@ contains end if call contact_multiplier_read(unit_id, mult_slots, ierr) if (ierr .ne. FEM_SUCCESS) return - read(unit_id,*,iostat=ios) tag - if (ios .ne. 0 .or. trim(tag) .ne. 'END') go to 920 + call read_diag_or_end(unit_id, ierr) + if (ierr .ne. FEM_SUCCESS) return else if (trim(tag) .eq. 'END') then call contact_history_read(unit_id, 0, ierr) if (ierr .ne. FEM_SUCCESS) return @@ -255,6 +257,234 @@ contains call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr) end subroutine read_restart_tail + subroutine write_contact_pair_diag(unit_id, ios) + integer, intent(in) :: unit_id + integer, intent(out) :: ios + integer :: pair + integer :: active_value + integer :: prev_active_value + integer :: status_value + integer :: activation_value + integer :: release_value + integer :: stick_value + integer :: slip_value + real(rk) :: work_value + real(rk) :: max_pen_value + real(rk) :: force_value + real(rk) :: gap_value + real(rk) :: tangent_value(NDIM) + real(rk) :: slip_accum_value + real(rk) :: fric_work_value + real(rk) :: fric_total_value + real(rk) :: aug_lambda_value + + write(unit_id,'(A,1X,I12,1X,I12,6(1X,ES24.16))',iostat=ios) & + 'CONTACT_PAIR_DIAGNOSTICS', ncontact_pair, contact_active_count, & + contact_work_step, contact_work_total, contact_max_penetration, & + contact_force_norm, contact_friction_work_step, & + contact_friction_work_total + if (ios .ne. 0) return + + do pair = 1, ncontact_pair + active_value = 0 + prev_active_value = 0 + status_value = 0 + activation_value = 0 + release_value = 0 + stick_value = 0 + slip_value = 0 + work_value = ZERO + max_pen_value = ZERO + force_value = ZERO + gap_value = ZERO + tangent_value = ZERO + slip_accum_value = ZERO + fric_work_value = ZERO + fric_total_value = ZERO + aug_lambda_value = ZERO + if (allocated(contact_pair_active)) active_value = contact_pair_active(pair) + if (allocated(contact_pair_prev_active)) then + prev_active_value = contact_pair_prev_active(pair) + end if + if (allocated(contact_pair_status)) status_value = contact_pair_status(pair) + if (allocated(contact_pair_activation_count)) then + activation_value = contact_pair_activation_count(pair) + end if + if (allocated(contact_pair_release_count)) then + release_value = contact_pair_release_count(pair) + end if + if (allocated(contact_pair_stick_count)) then + stick_value = contact_pair_stick_count(pair) + end if + if (allocated(contact_pair_slip_count)) slip_value = contact_pair_slip_count(pair) + if (allocated(contact_pair_work)) work_value = contact_pair_work(pair) + if (allocated(contact_pair_max_penetration)) then + max_pen_value = contact_pair_max_penetration(pair) + end if + if (allocated(contact_pair_force_norm)) force_value = contact_pair_force_norm(pair) + if (allocated(contact_pair_gap_residual)) gap_value = contact_pair_gap_residual(pair) + if (allocated(contact_pair_tangent_force)) then + tangent_value = contact_pair_tangent_force(:,pair) + end if + if (allocated(contact_pair_slip)) slip_accum_value = contact_pair_slip(pair) + if (allocated(contact_pair_friction_work)) then + fric_work_value = contact_pair_friction_work(pair) + end if + if (allocated(contact_pair_fric_work_total)) then + fric_total_value = contact_pair_fric_work_total(pair) + end if + if (allocated(contact_pair_aug_lambda)) then + aug_lambda_value = contact_pair_aug_lambda(pair) + end if + + write(unit_id,'(8(I12,1X),11(ES24.16,1X))',iostat=ios) & + pair, active_value, prev_active_value, status_value, & + activation_value, release_value, stick_value, slip_value, & + work_value, max_pen_value, force_value, gap_value, & + tangent_value(1), tangent_value(2), tangent_value(3), & + slip_accum_value, fric_work_value, fric_total_value, & + aug_lambda_value + if (ios .ne. 0) return + end do + end subroutine write_contact_pair_diag + + subroutine read_diag_or_end(unit_id, ierr) + integer, intent(in) :: unit_id + integer, intent(out) :: ierr + character(len=256) :: line + character(len=32) :: tag + integer :: ios + integer :: pair_count + integer :: active_saved + real(rk) :: work_step_saved + real(rk) :: work_total_saved + real(rk) :: max_pen_saved + real(rk) :: force_norm_saved + real(rk) :: fric_step_saved + real(rk) :: fric_total_saved + + read(unit_id,'(A)',iostat=ios) line + if (ios .ne. 0) then + call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr) + return + end if + read(line,*,iostat=ios) tag + if (ios .ne. 0) then + call error_set(FEM_ERR_OUTPUT, 'invalid restart tail marker', ierr) + return + end if + if (trim(tag) .eq. 'END') then + ierr = FEM_SUCCESS + return + end if + if (trim(tag) .ne. 'CONTACT_PAIR_DIAGNOSTICS') then + call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr) + return + end if + + read(line,*,iostat=ios) tag, pair_count, active_saved, & + work_step_saved, work_total_saved, max_pen_saved, force_norm_saved, & + fric_step_saved, fric_total_saved + if (ios .ne. 0) then + call error_set(FEM_ERR_OUTPUT, 'invalid restart contact diagnostics', ierr) + return + end if + contact_active_count = active_saved + contact_work_step = work_step_saved + contact_work_total = work_total_saved + contact_max_penetration = max_pen_saved + contact_force_norm = force_norm_saved + contact_friction_work_step = fric_step_saved + contact_friction_work_total = fric_total_saved + call read_contact_pair_diag_rows(unit_id, pair_count, ierr) + if (ierr .ne. FEM_SUCCESS) return + + read(unit_id,*,iostat=ios) tag + if (ios .ne. 0 .or. trim(tag) .ne. 'END') then + call error_set(FEM_ERR_OUTPUT, 'restart missing END marker', ierr) + return + end if + ierr = FEM_SUCCESS + end subroutine read_diag_or_end + + subroutine read_contact_pair_diag_rows(unit_id, pair_count, ierr) + integer, intent(in) :: unit_id + integer, intent(in) :: pair_count + integer, intent(out) :: ierr + integer :: row + integer :: pair + integer :: active_value + integer :: prev_active_value + integer :: status_value + integer :: activation_value + integer :: release_value + integer :: stick_value + integer :: slip_value + integer :: ios + real(rk) :: work_value + real(rk) :: max_pen_value + real(rk) :: force_value + real(rk) :: gap_value + real(rk) :: tangent_value(NDIM) + real(rk) :: slip_accum_value + real(rk) :: fric_work_value + real(rk) :: fric_total_value + real(rk) :: aug_lambda_value + + if (pair_count .ne. ncontact_pair) then + call error_set(FEM_ERR_OUTPUT, & + 'restart contact diagnostic pair count does not match', ierr) + return + end if + + do row = 1, pair_count + read(unit_id,*,iostat=ios) pair, active_value, prev_active_value, & + status_value, activation_value, release_value, stick_value, & + slip_value, work_value, max_pen_value, force_value, gap_value, & + tangent_value(1), tangent_value(2), tangent_value(3), & + slip_accum_value, fric_work_value, fric_total_value, & + aug_lambda_value + if (ios .ne. 0 .or. pair .lt. 1 .or. pair .gt. ncontact_pair) then + call error_set(FEM_ERR_OUTPUT, 'invalid restart contact diagnostics', & + ierr) + return + end if + if (allocated(contact_pair_active)) contact_pair_active(pair) = active_value + if (allocated(contact_pair_prev_active)) then + contact_pair_prev_active(pair) = prev_active_value + end if + if (allocated(contact_pair_status)) contact_pair_status(pair) = status_value + if (allocated(contact_pair_activation_count)) then + contact_pair_activation_count(pair) = activation_value + end if + if (allocated(contact_pair_release_count)) then + contact_pair_release_count(pair) = release_value + end if + if (allocated(contact_pair_stick_count)) contact_pair_stick_count(pair) = stick_value + if (allocated(contact_pair_slip_count)) contact_pair_slip_count(pair) = slip_value + if (allocated(contact_pair_work)) contact_pair_work(pair) = work_value + if (allocated(contact_pair_max_penetration)) then + contact_pair_max_penetration(pair) = max_pen_value + end if + if (allocated(contact_pair_force_norm)) contact_pair_force_norm(pair) = force_value + if (allocated(contact_pair_gap_residual)) contact_pair_gap_residual(pair) = gap_value + if (allocated(contact_pair_tangent_force)) then + contact_pair_tangent_force(:,pair) = tangent_value + end if + if (allocated(contact_pair_slip)) contact_pair_slip(pair) = slip_accum_value + if (allocated(contact_pair_friction_work)) then + contact_pair_friction_work(pair) = fric_work_value + end if + if (allocated(contact_pair_fric_work_total)) then + contact_pair_fric_work_total(pair) = fric_total_value + end if + if (allocated(contact_pair_aug_lambda)) then + contact_pair_aug_lambda(pair) = aug_lambda_value + end if + end do + ierr = FEM_SUCCESS + end subroutine read_contact_pair_diag_rows + subroutine write_restart_dofs(unit_id, ios) integer, intent(in) :: unit_id integer, intent(out) :: ios diff --git a/src/solver/fem_linear_solver_cg.f90 b/src/solver/fem_linear_solver_cg.f90 index 24ac96d..aec9187 100644 --- a/src/solver/fem_linear_solver_cg.f90 +++ b/src/solver/fem_linear_solver_cg.f90 @@ -1,7 +1,8 @@ module fem_linear_solver_cg use fem_linear_solver_dispatch, only: linear_solver_solve, & linear_solver_configure, linear_solver_get_settings, & - linear_solver_get_stats, linear_solver_get_diagnostics + linear_solver_get_stats, linear_solver_get_diagnostics, & + linear_solver_get_fail_info use fem_linear_solver_iterative, only: linear_cg_solve, & linear_bicgstab_solve, linear_gmres_solve implicit none @@ -11,6 +12,7 @@ module fem_linear_solver_cg public :: linear_solver_get_settings public :: linear_solver_get_stats public :: linear_solver_get_diagnostics + public :: linear_solver_get_fail_info public :: linear_cg_solve public :: linear_bicgstab_solve public :: linear_gmres_solve diff --git a/src/solver/fem_linear_solver_dispatch.f90 b/src/solver/fem_linear_solver_dispatch.f90 index b2ea48a..6c11eaa 100644 --- a/src/solver/fem_linear_solver_dispatch.f90 +++ b/src/solver/fem_linear_solver_dispatch.f90 @@ -4,7 +4,7 @@ module fem_linear_solver_dispatch use fem_control use fem_sparse_csr use fem_sparse_csr_diagnostics, only: csr_profile, csr_analyze, & - csr_residual_norm + csr_residual_norm, CSR_CLASS_SPD_CAND use fem_linear_solver_iterative use fem_linear_solver_dense implicit none @@ -16,6 +16,7 @@ module fem_linear_solver_dispatch public :: linear_solver_get_settings public :: linear_solver_get_stats public :: linear_solver_get_diagnostics + public :: linear_solver_get_fail_info contains @@ -37,12 +38,16 @@ contains real(rk) :: final_resid real(rk) :: final_rel_resid integer :: matrix_class + integer :: failure_class integer :: audit_ierr + character(len=64) :: reason_text method = linear_solver_method preconditioner = linear_precond_method status = LS_STATUS_FAILED matrix_class = 1 + failure_class = LS_FAIL_NONE + reason_text = 'selected' initial_resid = ZERO initial_rel_resid = ZERO final_resid = ZERO @@ -52,9 +57,11 @@ contains if (ierr .ne. FEM_SUCCESS) then iter = 0 res_norm = ZERO + failure_class = LS_FAIL_DIAGNOSTIC + reason_text = 'csr-analysis-failure' call linear_solver_record(method, preconditioner, iter, res_norm, & status, matrix_class, initial_resid, & - final_rel_resid) + final_rel_resid, failure_class, reason_text) return end if matrix_class = profile%class_id @@ -63,9 +70,11 @@ contains if (ierr .ne. FEM_SUCCESS) then iter = 0 res_norm = ZERO + failure_class = LS_FAIL_DIAGNOSTIC + reason_text = 'initial-residual-audit-failure' call linear_solver_record(method, preconditioner, iter, res_norm, & status, matrix_class, initial_resid, & - final_rel_resid) + final_rel_resid, failure_class, reason_text) return end if @@ -84,26 +93,34 @@ contains case default iter = 0 res_norm = ZERO + failure_class = LS_FAIL_CONFIGURATION + reason_text = 'unknown-linear-solver-method' call error_set(FEM_ERR_SOLVER, 'unknown linear solver method', ierr) end select if (ierr .ne. FEM_SUCCESS) then + if (failure_class .eq. LS_FAIL_NONE) then + failure_class = linear_solver_classify_failure(method, matrix_class) + call linear_solver_reason_text(method, failure_class, reason_text) + end if call csr_residual_norm(a, b, x, final_resid, final_rel_resid, & audit_ierr) if (audit_ierr .eq. FEM_SUCCESS) res_norm = final_resid call linear_solver_record(method, preconditioner, iter, res_norm, & status, matrix_class, initial_resid, & - final_rel_resid) + final_rel_resid, failure_class, reason_text) return end if status = LS_STATUS_CONVERGED + failure_class = LS_FAIL_NONE + call linear_solver_reason_text(method, failure_class, reason_text) call csr_residual_norm(a, b, x, final_resid, final_rel_resid, & audit_ierr) if (audit_ierr .eq. FEM_SUCCESS) res_norm = final_resid call linear_solver_record(method, preconditioner, iter, res_norm, & status, matrix_class, initial_resid, & - final_rel_resid) + final_rel_resid, failure_class, reason_text) end subroutine linear_solver_solve subroutine linear_solver_configure(method, preconditioner, ierr) @@ -174,9 +191,20 @@ contains ierr = FEM_SUCCESS end subroutine linear_solver_get_diagnostics + subroutine linear_solver_get_fail_info(failure_class, reason, ierr) + integer, intent(out) :: failure_class + character(len=*), intent(out) :: reason + integer, intent(out) :: ierr + + failure_class = linsol_last_fail_class + reason = linear_solver_last_reason + ierr = FEM_SUCCESS + end subroutine linear_solver_get_fail_info + subroutine linear_solver_record(method, preconditioner, iteration, & residual_norm, status_code, matrix_class, & - initial_residual, relative_residual) + initial_residual, relative_residual, & + failure_class, reason) integer, intent(in) :: method integer, intent(in) :: preconditioner integer, intent(in) :: iteration @@ -185,6 +213,8 @@ contains integer, intent(in) :: matrix_class real(rk), intent(in) :: initial_residual real(rk), intent(in) :: relative_residual + integer, intent(in) :: failure_class + character(len=*), intent(in) :: reason linear_solver_last_method = method linear_solver_last_prec = preconditioner @@ -194,6 +224,57 @@ contains linear_solver_last_matrix_class = matrix_class linear_solver_initial_resid = initial_residual linear_solver_relative_resid = relative_residual + linsol_last_fail_class = failure_class + linear_solver_last_reason = reason end subroutine linear_solver_record + integer function linear_solver_classify_failure(method, matrix_class) & + result(failure_class) + integer, intent(in) :: method + integer, intent(in) :: matrix_class + + select case (method) + case (LSOLVER_CG) + if (matrix_class .lt. CSR_CLASS_SPD_CAND) then + failure_class = LS_FAIL_INVALID_MATRIX + else + failure_class = LS_FAIL_NONCONVERGENCE + end if + case (LSOLVER_DENSE) + failure_class = LS_FAIL_DENSE_FALLBACK + case (LSOLVER_BICGSTAB, LSOLVER_GMRES) + failure_class = LS_FAIL_NONCONVERGENCE + case default + failure_class = LS_FAIL_CONFIGURATION + end select + end function linear_solver_classify_failure + + subroutine linear_solver_reason_text(method, failure_class, reason) + integer, intent(in) :: method + integer, intent(in) :: failure_class + character(len=*), intent(out) :: reason + character(len=24) :: method_name + character(len=40) :: class_name + + select case (method) + case (LSOLVER_CG) + method_name = 'cg' + case (LSOLVER_BICGSTAB) + method_name = 'bicgstab' + case (LSOLVER_GMRES) + method_name = 'gmres' + case (LSOLVER_DENSE) + method_name = 'dense' + case default + method_name = 'unknown' + end select + + call linsol_fail_class_name(failure_class, class_name) + if (failure_class .eq. LS_FAIL_NONE) then + reason = trim(method_name)//'-selected' + else + reason = trim(method_name)//'-'//trim(class_name) + end if + end subroutine linear_solver_reason_text + end module fem_linear_solver_dispatch diff --git a/src/solver/fem_solver_implicit.f90 b/src/solver/fem_solver_implicit.f90 index e2d4d1e..18a2d1d 100644 --- a/src/solver/fem_solver_implicit.f90 +++ b/src/solver/fem_solver_implicit.f90 @@ -280,6 +280,7 @@ contains convergence_last_accepted_time = current_time convergence_status_code = CONVERGENCE_STATUS_ITERATING convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE nlc_last_target_dt = ZERO nlc_last_actual_dt = ZERO nlc_next_target_dt = ZERO diff --git a/src/solver/fem_solver_implicit_support.f90 b/src/solver/fem_solver_implicit_support.f90 index 06f3c78..00688a5 100644 --- a/src/solver/fem_solver_implicit_support.f90 +++ b/src/solver/fem_solver_implicit_support.f90 @@ -64,10 +64,17 @@ contains convergence_correction_norm = ZERO convergence_contact_gap_norm = ZERO convergence_combined_norm = ZERO + convergence_total_resid_norm = ZERO + convergence_force_resid_norm = ZERO + convergence_contact_resid_norm = ZERO + convergence_cons_resid_norm = ZERO + convergence_arc_resid_norm = ZERO + convergence_material_fail_count = 0 convergence_last_dt = dt convergence_converged = .false. convergence_status_code = CONVERGENCE_STATUS_ITERATING convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE end subroutine begin_newmark_convergence subroutine begin_static_convergence(increment_id, dt_inc) @@ -81,10 +88,17 @@ contains convergence_correction_norm = ZERO convergence_contact_gap_norm = ZERO convergence_combined_norm = ZERO + convergence_total_resid_norm = ZERO + convergence_force_resid_norm = ZERO + convergence_contact_resid_norm = ZERO + convergence_cons_resid_norm = ZERO + convergence_arc_resid_norm = ZERO + convergence_material_fail_count = 0 convergence_last_dt = dt_inc convergence_converged = .false. convergence_status_code = CONVERGENCE_STATUS_ITERATING convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE nlc_last_damping = ONE nlc_last_merit_ratio = ZERO nlc_last_rejections = 0 @@ -131,14 +145,25 @@ contains convergence_converged = .true. convergence_status_code = CONVERGENCE_STATUS_CONVERGED convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE end subroutine mark_convergence_success - subroutine mark_convergence_failure(failure_code) + subroutine mark_convergence_failure(failure_code, reason_id) integer, intent(in) :: failure_code + integer, intent(in), optional :: reason_id convergence_converged = .false. convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = failure_code + if (present(reason_id)) then + convergence_failure_reason_id = reason_id + else if (failure_code .eq. CONV_FAIL_NONCONVERGENCE .and. & + linear_solver_last_status .eq. LS_STATUS_FAILED) then + convergence_failure_reason_id = NFAIL_LINEAR_SOLVE + else + convergence_failure_reason_id = & + convergence_reason_from_failure(failure_code) + end if end subroutine mark_convergence_failure subroutine update_convergence_metrics(res_norm, ref_norm) @@ -154,6 +179,10 @@ contains if (allocated(contact_pair_gap_residual)) then convergence_contact_gap_norm = maxval(contact_pair_gap_residual) end if + convergence_total_resid_norm = res_norm + convergence_force_resid_norm = res_norm + convergence_contact_resid_norm = convergence_contact_gap_norm + convergence_cons_resid_norm = ZERO convergence_combined_norm = max(convergence_rel_resid_norm, & max(convergence_correction_norm, convergence_contact_gap_norm)) end subroutine update_convergence_metrics diff --git a/src/solver/fem_solver_static_nonlinear.f90 b/src/solver/fem_solver_static_nonlinear.f90 index dc51d6c..e3aa414 100644 --- a/src/solver/fem_solver_static_nonlinear.f90 +++ b/src/solver/fem_solver_static_nonlinear.f90 @@ -60,6 +60,7 @@ contains if (.not. arc_disp_mode) then convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_STOPPED + convergence_failure_reason_id = NFAIL_ARC_CONSTRAINT nlc_last_adjust = NLC_ADJ_FAILED call error_set(FEM_ERR_SOLVER, & 'METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL requires a nonzero '// & @@ -342,6 +343,7 @@ contains current_time = sub_target_time convergence_last_accepted_time = current_time convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE current_step = current_step + 1 nlc_last_iter = iter_inc nlc_last_actual_dt = dt_try @@ -435,6 +437,7 @@ contains convergence_last_dt = dt_try convergence_status_code = CONVERGENCE_STATUS_CUTBACK convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE nlc_last_adjust = NLC_ADJ_CUTBACK nlc_next_target_dt = dt_try call error_clear(ierr) @@ -448,6 +451,11 @@ contains if (use_static_predictor) u = u_equil convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT + if (linear_solver_last_status .eq. LS_STATUS_FAILED) then + convergence_failure_reason_id = NFAIL_LINEAR_SOLVE + else + convergence_failure_reason_id = NFAIL_MIN_STEP + end if nlc_last_adjust = NLC_ADJ_FAILED nlc_next_target_dt = ZERO end subroutine fail_static_increment @@ -503,6 +511,7 @@ contains current_time = sub_target_time convergence_last_accepted_time = current_time convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE current_step = current_step + 1 nlc_last_iter = iter_inc nlc_last_actual_dt = dt_try @@ -521,12 +530,18 @@ contains convergence_last_dt = dt_try convergence_status_code = CONVERGENCE_STATUS_CUTBACK convergence_failure_code = CONV_FAIL_NONE + convergence_failure_reason_id = NFAIL_NONE nlc_last_adjust = NLC_ADJ_CUTBACK nlc_next_target_dt = dt_try ierr = FEM_SUCCESS else convergence_status_code = CONVERGENCE_STATUS_FAILED convergence_failure_code = CONV_FAIL_CUTBACK_LIMIT + if (linear_solver_last_status .eq. LS_STATUS_FAILED) then + convergence_failure_reason_id = NFAIL_LINEAR_SOLVE + else + convergence_failure_reason_id = NFAIL_MIN_STEP + end if nlc_last_adjust = NLC_ADJ_FAILED nlc_next_target_dt = ZERO return @@ -999,6 +1014,7 @@ contains iter_used = iter call record_convergence_iteration(iter, res_norm, ref_norm, & correction_norm) + convergence_arc_resid_norm = abs(arc_residual) if ((res_norm .le. tol .or. res_norm / ref_norm .le. tol) .and. & abs(arc_residual) .le. arc_tol) then converged = .true. diff --git a/tests/interface/test_c_api.c b/tests/interface/test_c_api.c index 73c8edf..ef235a6 100644 --- a/tests/interface/test_c_api.c +++ b/tests/interface/test_c_api.c @@ -113,7 +113,7 @@ int main(void) ierr = femlite_get_version(&major, &minor, &patch); if (ierr != 0) return check_ierr(ierr, 2); - if (major != 0 || minor != 5 || patch != 2) return 3; + if (major != 0 || minor != 5 || patch != 3) return 3; ierr = femlite_read_inp("examples/c3d4_one_element.inp"); if (ierr != 0) return check_ierr(ierr, 4); diff --git a/tests/module/test_contact.f90 b/tests/module/test_contact.f90 index f6e1350..337dc89 100644 --- a/tests/module/test_contact.f90 +++ b/tests/module/test_contact.f90 @@ -661,8 +661,11 @@ contains call require_contains('contact_00000910.csv', & 'kind,pair_id,active_count,max_penetration,force_norm,work_estimate,'// & 'cumulative_work,stick_count,slip_count,accumulated_slip,'// & + 'slip_increment_norm,slip_residual,friction_residual,'// & 'friction_work,friction_work_total,friction_regularization,ftx,fty,ftz,'// & - 'status,activation_count,release_count,gap_residual,aug_factor,aug_lambda', 601) + 'status,activation_count,release_count,gap_residual,gap_mean,'// & + 'gap_l2,failed_projection_count,active_set_flip_count,'// & + 'aug_factor,aug_lambda', 601) call require_contains('contact_00000910.csv', & 'search_facets,search_masters,search_candidates,search_active,'// & 'search_bvh_nodes', 607) @@ -1088,7 +1091,7 @@ contains character(len=*), intent(in) :: filename character(len=*), intent(in) :: pattern integer, intent(in) :: code - character(len=512) :: line + character(len=1024) :: line integer :: unit_id integer :: ios logical :: found diff --git a/tests/module/test_contact_mortar_tangent.f90 b/tests/module/test_contact_mortar_tangent.f90 index 668660a..83643e6 100644 --- a/tests/module/test_contact_mortar_tangent.f90 +++ b/tests/module/test_contact_mortar_tangent.f90 @@ -299,7 +299,8 @@ contains call require_success(ierr, 146) call mortar_tan_matrix(cons, params, ndof, k_local, diag, ierr) call require_success(ierr, 147) - call mortar_tan_audit_matrix(ndof, k_local, 1.0e-8_rk, audit, ierr) + call mortar_tan_audit_friction(ndof, k_local, MORTAR_TAN_STICK, & + 1.0e-8_rk, audit, ierr) call require_success(ierr, 148) if (audit%ndof .ne. ndof) call fail(149) if (audit%node_count .ne. 4) call fail(150) @@ -307,17 +308,28 @@ contains if (.not. audit%translation_ok) call fail(152) call check_close(audit%max_asym, ZERO, 153) if (audit%energy_probe .lt. ZERO) call fail(154) + call check_close(audit%normal_rigid_residual, ZERO, 165) + call check_close(audit%normal_relative_fd_error, ZERO, 166) + call check_close(audit%stick_relative_fd_error, ZERO, 167) + call check_close(audit%slip_relative_fd_error, ZERO, 168) + call check_close(audit%friction_rigid_residual, ZERO, 169) + call check_close(audit%friction_energy_residual, ZERO, 170) params%nonsym_scale = 0.25_rk call mortar_tan_params_valid(params, ierr) call require_success(ierr, 155) call mortar_tan_slip_matrix(cons, params, ndof, k_local, diag, ierr) call require_success(ierr, 156) - call mortar_tan_audit_matrix(ndof, k_local, 1.0e-8_rk, audit, ierr) + call mortar_tan_audit_friction(ndof, k_local, MORTAR_TAN_SLIP, & + 1.0e-8_rk, audit, ierr) call require_success(ierr, 157) if (.not. audit%balance_ok) call fail(158) if (.not. audit%translation_ok) call fail(159) if (audit%max_asym .le. ZERO) call fail(160) + call check_close(audit%stick_relative_fd_error, ZERO, 161) + if (audit%slip_relative_fd_error .le. ZERO) call fail(162) + call check_close(audit%friction_rigid_residual, ZERO, 163) + call check_close(audit%friction_energy_residual, ZERO, 164) end subroutine check_tangent_audit subroutine check_projector_diag() diff --git a/tests/module/test_contact_multiplier_report.f90 b/tests/module/test_contact_multiplier_report.f90 index 4e3c71b..40e4f60 100644 --- a/tests/module/test_contact_multiplier_report.f90 +++ b/tests/module/test_contact_multiplier_report.f90 @@ -46,6 +46,12 @@ contains if (index(line, 'max_lambda=') .le. 0) call fail(24) if (index(line, 'duplicates=0,invalid=0') .le. 0) call fail(25) if (index(line, 'max_commit_error=') .le. 0) call fail(26) + if (index(line, 'state_open=1') .le. 0) call fail(27) + if (index(line, 'state_closed_stick=1') .le. 0) call fail(28) + if (index(line, 'state_separating=1') .le. 0) call fail(29) + if (index(line, 'state_failed_projection=0') .le. 0) call fail(30) + if (index(line, 'normal_multiplier_residual=') .le. 0) call fail(31) + if (index(line, 'al_update_count=2') .le. 0) call fail(32) call contact_multiplier_reset() end subroutine check_header_csv_summary diff --git a/tests/module/test_implicit_inp.f90 b/tests/module/test_implicit_inp.f90 index 5d2dcd6..fc85f8d 100644 --- a/tests/module/test_implicit_inp.f90 +++ b/tests/module/test_implicit_inp.f90 @@ -43,6 +43,7 @@ program test_implicit_inp call check_shell_static_patch('tests/data/s8_static_patch.inp', 2, 220) call check_s4_comp_section_inp() call check_static_nonlinear_elastic() + call check_static_nl_fail_reason() call check_static_nonlinear_j2_disp() call check_buckling_step_inp() call check_buckling_preload_inp() @@ -386,6 +387,7 @@ contains integer :: conv_cutback_count integer :: conv_status_code integer :: conv_failure_code + integer :: conv_reason_id integer :: query_nodes(4) integer :: query_elems(1) real(rk) :: res_norm @@ -407,6 +409,7 @@ contains real(rk) :: eqps(1) real(rk) :: damage(1) logical :: conv_converged + character(len=64) :: conv_reason_name call fem_initialize(ierr) if (ierr .ne. 0) call fail(250) @@ -440,6 +443,10 @@ contains if (conv_status_code .ne. CONVERGENCE_STATUS_CONVERGED) call fail(286) call check_close(conv_last_accepted_time, ONE, 287) if (conv_failure_code .ne. CONV_FAIL_NONE) call fail(288) + call fem_get_convergence_reason(conv_reason_id, conv_reason_name, ierr) + if (ierr .ne. 0) call fail(2288) + if (conv_reason_id .ne. NFAIL_NONE) call fail(2289) + if (trim(conv_reason_name) .ne. 'none') call fail(2290) call fem_get_convergence_metrics(conv_relative_residual, & conv_contact_gap, conv_combined_norm, ierr) @@ -486,6 +493,34 @@ contains if (ierr .ne. 0) call fail(276) end subroutine check_static_nonlinear_elastic + subroutine check_static_nl_fail_reason() + integer :: ierr + integer :: iter + integer :: conv_reason_id + real(rk) :: res_norm + character(len=64) :: conv_reason_name + + call fem_initialize(ierr) + if (ierr .ne. 0) call fail(2291) + + call fem_read_inp('tests/data/c3d4_static_nonlinear_elastic.inp', ierr) + if (ierr .ne. 0) call fail(2292) + + call fem_build_model(ierr) + if (ierr .ne. 0) call fail(2293) + + call fem_solve_static_nonlinear(4, 1, 1.0e-30_rk, iter, res_norm, ierr) + if (ierr .eq. 0) call fail(2294) + + call fem_get_convergence_reason(conv_reason_id, conv_reason_name, ierr) + if (ierr .ne. 0) call fail(2295) + if (conv_reason_id .ne. NFAIL_MIN_STEP) call fail(2296) + if (trim(conv_reason_name) .ne. 'minimum-step-exhausted') call fail(2297) + + call fem_finalize(ierr) + if (ierr .ne. 0) call fail(2298) + end subroutine check_static_nl_fail_reason + subroutine check_static_nonlinear_j2_disp() integer :: ierr integer :: iter diff --git a/tests/module/test_linear_solver_cg.f90 b/tests/module/test_linear_solver_cg.f90 index 3a6d549..c6ccf1e 100644 --- a/tests/module/test_linear_solver_cg.f90 +++ b/tests/module/test_linear_solver_cg.f90 @@ -342,12 +342,14 @@ contains integer :: preconditioner integer :: status_code integer :: matrix_class + integer :: failure_class real(rk) :: b(3) real(rk) :: x(3) real(rk) :: res_norm real(rk) :: initial_resid real(rk) :: final_resid real(rk) :: relative_resid + character(len=64) :: failure_reason call linear_solver_configure(method_in, LPRECOND_JACOBI, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code_base) @@ -375,6 +377,17 @@ contains if (initial_resid .le. ONE) call fail(code_base + 12) if (final_resid .le. ZERO) call fail(code_base + 13) if (relative_resid .le. ZERO) call fail(code_base + 14) + call linear_solver_get_fail_info(failure_class, failure_reason, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(code_base + 17) + if (method_in .eq. LSOLVER_CG) then + if (failure_class .ne. LS_FAIL_INVALID_MATRIX) call fail(code_base + 18) + if (index(trim(failure_reason), 'invalid-matrix-class') .le. 0) & + call fail(code_base + 19) + else + if (failure_class .ne. LS_FAIL_NONCONVERGENCE) call fail(code_base + 20) + if (index(trim(failure_reason), 'linear-nonconvergence') .le. 0) & + call fail(code_base + 21) + end if call csr_free(a, ierr) if (ierr .ne. FEM_SUCCESS) call fail(code_base + 15) diff --git a/tests/module/test_restart.f90 b/tests/module/test_restart.f90 index c2416a8..e1ebe52 100644 --- a/tests/module/test_restart.f90 +++ b/tests/module/test_restart.f90 @@ -7,8 +7,10 @@ program test_restart shell_rotation_rotate_vector use fem_contact_multiplier, only: contact_multiplier_store_trial, & contact_multiplier_commit, contact_multiplier_stats, & - contact_multiplier_audit - use fem_contact_history, only: contact_history_state_stats + contact_multiplier_audit, contact_multiplier_state_counts, & + contact_multiplier_resid_stats + use fem_contact_history, only: contact_history_state_stats, & + contact_history_stable_counts implicit none real(rk), parameter :: DT_TEST = 1.0e-8_rk @@ -158,24 +160,90 @@ contains integer :: hist_slots_after integer :: stick_after integer :: slip_state_after + integer :: stable_slots_before + integer :: state_open_before + integer :: state_stick_before + integer :: state_slip_before + integer :: state_restick_before + integer :: state_separating_before + integer :: state_failed_before + integer :: stable_slots_after + integer :: state_open_after + integer :: state_stick_after + integer :: state_slip_after + integer :: state_restick_after + integer :: state_separating_after + integer :: state_failed_after + integer :: active_summary_before + integer :: active_summary_after + integer :: active_pair_before + integer :: activated_pair_before + integer :: maintained_pair_before + integer :: released_pair_before + integer :: active_pair_after + integer :: activated_pair_after + integer :: maintained_pair_after + integer :: released_pair_after + real(rk) :: work_step_before + real(rk) :: work_total_before + real(rk) :: max_pen_before + real(rk) :: force_norm_before + real(rk) :: work_step_after + real(rk) :: work_total_after + real(rk) :: max_pen_after + real(rk) :: force_norm_after + real(rk) :: max_gap_before + real(rk) :: max_aug_before + real(rk) :: max_gap_after + real(rk) :: max_aug_after + real(rk) :: fric_step_before + real(rk) :: fric_total_before + real(rk) :: max_slip_before + real(rk) :: fric_step_after + real(rk) :: fric_total_after + real(rk) :: max_slip_after call prepare_contact_model(ierr) if (ierr .ne. FEM_SUCCESS) return call run_contact_steps(CONTACT_STEPS, ierr) if (ierr .ne. FEM_SUCCESS) return + call fem_get_contact_summary(active_summary_before, work_step_before, & + work_total_before, max_pen_before, force_norm_before, ierr) + if (ierr .ne. FEM_SUCCESS) return + call fem_get_contact_diagnostics(active_pair_before, & + activated_pair_before, maintained_pair_before, released_pair_before, & + max_gap_before, max_aug_before, ierr) + if (ierr .ne. FEM_SUCCESS) return + call fem_get_contact_friction(fric_step_before, fric_total_before, & + max_slip_before, ierr) + if (ierr .ne. FEM_SUCCESS) return call fem_get_contact_hist_stats(slots_before, slip_before, & work_before, tangent_before, ierr) if (ierr .ne. FEM_SUCCESS) return call contact_history_state_stats(hist_slots_before, stick_before, & slip_state_before) + call contact_history_stable_counts(stable_slots_before, & + state_open_before, state_stick_before, state_slip_before, & + state_restick_before, state_separating_before, state_failed_before) if (slots_before .le. 0) call fail(13) if (slip_before .le. ZERO) call fail(14) if (work_before .le. ZERO) call fail(15) if (tangent_before .le. ZERO) call fail(16) + if (active_summary_before .le. 0) call fail(395) + if (active_pair_before .le. 0) call fail(396) + if (force_norm_before .le. ZERO) call fail(397) + if (max_gap_before .le. ZERO) call fail(398) + if (max_slip_before .le. ZERO) call fail(399) if (hist_slots_before .ne. slots_before) call fail(360) if (stick_before + slip_state_before .ne. hist_slots_before) & call fail(361) + if (stable_slots_before .ne. hist_slots_before) call fail(367) + if (state_open_before .ne. 0) call fail(368) + if (state_stick_before .ne. stick_before) call fail(369) + if (state_slip_before .ne. slip_state_before) call fail(370) + if (state_restick_before + state_separating_before + & + state_failed_before .ne. 0) call fail(371) call fem_write_restart(CONTACT_RESTART_FILE, ierr) if (ierr .ne. FEM_SUCCESS) return @@ -183,7 +251,11 @@ contains if (ierr .ne. FEM_SUCCESS) return call contact_history_state_stats(hist_slots_after, stick_after, & slip_state_after) + call contact_history_stable_counts(stable_slots_after, & + state_open_after, state_stick_after, state_slip_after, & + state_restick_after, state_separating_after, state_failed_after) if (hist_slots_after .ne. 0) call fail(362) + if (stable_slots_after .ne. 0) call fail(372) call fem_get_contact_hist_stats(slots_after, slip_after, work_after, & tangent_after, ierr) if (ierr .ne. FEM_SUCCESS) return @@ -196,6 +268,9 @@ contains if (ierr .ne. FEM_SUCCESS) return call contact_history_state_stats(hist_slots_after, stick_after, & slip_state_after) + call contact_history_stable_counts(stable_slots_after, & + state_open_after, state_stick_after, state_slip_after, & + state_restick_after, state_separating_after, state_failed_after) if (slots_after .ne. slots_before) call fail(18) call check_close(slip_after, slip_before, 19) @@ -205,6 +280,37 @@ contains if (stick_after .ne. stick_before) call fail(364) if (slip_state_after .ne. slip_state_before) call fail(365) if (stick_after + slip_state_after .ne. hist_slots_after) call fail(366) + if (stable_slots_after .ne. stable_slots_before) call fail(373) + if (state_open_after .ne. state_open_before) call fail(374) + if (state_stick_after .ne. state_stick_before) call fail(375) + if (state_slip_after .ne. state_slip_before) call fail(376) + if (state_restick_after .ne. state_restick_before) call fail(377) + if (state_separating_after .ne. state_separating_before) call fail(378) + if (state_failed_after .ne. state_failed_before) call fail(379) + call fem_get_contact_summary(active_summary_after, work_step_after, & + work_total_after, max_pen_after, force_norm_after, ierr) + if (ierr .ne. FEM_SUCCESS) return + call fem_get_contact_diagnostics(active_pair_after, activated_pair_after, & + maintained_pair_after, released_pair_after, max_gap_after, & + max_aug_after, ierr) + if (ierr .ne. FEM_SUCCESS) return + call fem_get_contact_friction(fric_step_after, fric_total_after, & + max_slip_after, ierr) + if (ierr .ne. FEM_SUCCESS) return + if (active_summary_after .ne. active_summary_before) call fail(400) + if (active_pair_after .ne. active_pair_before) call fail(401) + if (activated_pair_after .ne. activated_pair_before) call fail(402) + if (maintained_pair_after .ne. maintained_pair_before) call fail(403) + if (released_pair_after .ne. released_pair_before) call fail(404) + call check_close(work_step_after, work_step_before, 405) + call check_close(work_total_after, work_total_before, 406) + call check_close(max_pen_after, max_pen_before, 407) + call check_close(force_norm_after, force_norm_before, 408) + call check_close(max_gap_after, max_gap_before, 409) + call check_close(max_aug_after, max_aug_before, 410) + call check_close(fric_step_after, fric_step_before, 411) + call check_close(fric_total_after, fric_total_before, 412) + call check_close(max_slip_after, max_slip_before, 413) end subroutine check_contact_history_restart subroutine check_mult_restart(ierr) @@ -215,6 +321,17 @@ contains integer :: open_count integer :: duplicate_count integer :: invalid_count + integer :: state_slots + integer :: state_open + integer :: state_stick + integer :: state_slip + integer :: state_restick + integer :: state_separating + integer :: state_failed + integer :: al_update_before + integer :: al_update_after + real(rk) :: mult_resid_before + real(rk) :: mult_resid_after real(rk) :: max_lambda real(rk) :: max_gap real(rk) :: max_commit_error @@ -244,6 +361,20 @@ contains if (released_count .ne. 1) call fail(30) if (open_count .ne. 1) call fail(31) if (duplicate_count .ne. 0 .or. invalid_count .ne. 0) call fail(32) + call contact_multiplier_state_counts(state_slots, state_open, & + state_stick, state_slip, state_restick, state_separating, & + state_failed, ierr) + if (ierr .ne. FEM_SUCCESS) return + if (state_slots .ne. 3) call fail(380) + if (state_open .ne. 1) call fail(381) + if (state_stick .ne. 1) call fail(382) + if (state_slip + state_restick + state_failed .ne. 0) call fail(383) + if (state_separating .ne. 1) call fail(384) + call contact_multiplier_resid_stats(mult_resid_before, & + al_update_before, ierr) + if (ierr .ne. FEM_SUCCESS) return + call check_close(mult_resid_before, ZERO, 391) + if (al_update_before .ne. 0) call fail(392) call check_close(max_lambda, 9.0_rk, 33) call check_close(max_gap, 0.04_rk, 34) call check_close(max_commit_error, ZERO, 35) @@ -254,6 +385,11 @@ contains if (ierr .ne. FEM_SUCCESS) return call contact_multiplier_stats(slot_count, active_count, max_lambda, max_gap) if (slot_count .ne. 0) call fail(23) + call contact_multiplier_state_counts(state_slots, state_open, & + state_stick, state_slip, state_restick, state_separating, & + state_failed, ierr) + if (ierr .ne. FEM_SUCCESS) return + if (state_slots .ne. 0) call fail(385) call fem_read_restart(MULT_RESTART_FILE, ierr) if (ierr .ne. FEM_SUCCESS) return @@ -269,6 +405,20 @@ contains if (released_count .ne. 1) call fail(36) if (open_count .ne. 1) call fail(37) if (duplicate_count .ne. 0 .or. invalid_count .ne. 0) call fail(38) + call contact_multiplier_state_counts(state_slots, state_open, & + state_stick, state_slip, state_restick, state_separating, & + state_failed, ierr) + if (ierr .ne. FEM_SUCCESS) return + if (state_slots .ne. 3) call fail(386) + if (state_open .ne. 1) call fail(387) + if (state_stick .ne. 1) call fail(388) + if (state_separating .ne. 1) call fail(389) + if (state_slip + state_restick + state_failed .ne. 0) call fail(390) + call contact_multiplier_resid_stats(mult_resid_after, al_update_after, & + ierr) + if (ierr .ne. FEM_SUCCESS) return + call check_close(mult_resid_after, mult_resid_before, 393) + if (al_update_after .ne. al_update_before) call fail(394) call check_close(max_commit_error, ZERO, 39) end subroutine check_mult_restart diff --git a/tests/module/test_solver_implicit.f90 b/tests/module/test_solver_implicit.f90 index 84c153b..3a64f7d 100644 --- a/tests/module/test_solver_implicit.f90 +++ b/tests/module/test_solver_implicit.f90 @@ -6,9 +6,10 @@ program test_solver_implicit use fem_boundary use fem_element_mass use fem_solver_implicit + use fem_output_csv use fem_linear_solver_cg, only: linear_solver_configure, & linear_solver_get_diagnostics, linear_solver_get_settings, & - linear_solver_get_stats + linear_solver_get_stats, linear_solver_get_fail_info use fem_sparse_csr_diagnostics, only: CSR_CLASS_GENERAL, & CSR_CLASS_SPD_CAND implicit none @@ -31,6 +32,7 @@ program test_solver_implicit call check_newmark_nonlinear_contact() call check_newmark_trial_rollback() call check_static_cutback_rollback() + call check_newmark_nonconv_reason() call check_static_adapt_newton() call check_static_trust_damped() call check_static_arc_load_riks() @@ -40,6 +42,7 @@ program test_solver_implicit call check_static_arc_disp_adaptive() call check_static_arc_disp_trust() call check_nonlinear_cg_fallback() + call check_nl_linear_failure_reason() contains @@ -359,6 +362,12 @@ contains if (iter .le. 0 .or. iter .gt. 5) call fail(93) if (res_norm .gt. TOL) call fail(94) if (convergence_correction_norm .le. ZERO) call fail(101) + call check_close(convergence_total_resid_norm, res_norm, 5500) + call check_close(convergence_force_resid_norm, res_norm, 5501) + call check_close(convergence_contact_resid_norm, ZERO, 5502) + call check_close(convergence_cons_resid_norm, ZERO, 5503) + call check_close(convergence_arc_resid_norm, ZERO, 5504) + if (convergence_material_fail_count .ne. 0) call fail(5505) dof = dof_id(1,2) call check_close(u(dof), 15.0_rk / 68.0_rk, 95) @@ -543,6 +552,8 @@ contains call check_close(convergence_last_dt, 0.25_rk, 161) if (convergence_failure_code .ne. CONV_FAIL_CUTBACK_LIMIT) & call fail(162) + if (convergence_failure_reason_id .ne. NFAIL_MIN_STEP) call fail(5164) + call check_reason_name(NFAIL_MIN_STEP, 'minimum-step-exhausted', 5165) call check_close(convergence_last_accepted_time, ZERO, 163) allow_step_cutback = old_cutback @@ -554,6 +565,34 @@ contains if (ierr .ne. FEM_SUCCESS) call fail(157) end subroutine check_static_cutback_rollback + subroutine check_newmark_nonconv_reason() + integer :: ierr + integer :: iter + real(rk) :: res_norm + + call setup_pull_model(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5166) + call element_compute_lumped_mass(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5167) + + current_time = ZERO + + call implicit_newmark_nonlinear_step(0.1_rk, 0.25_rk, 0.5_rk, & + 1, 1.0e-30_rk, iter, res_norm, ierr) + if (ierr .eq. FEM_SUCCESS) call fail(5168) + if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) & + call fail(5169) + if (convergence_failure_code .ne. CONV_FAIL_NONCONVERGENCE) & + call fail(5170) + if (convergence_failure_reason_id .ne. NFAIL_NONCONVERGENCE) & + call fail(5171) + call check_reason_name(NFAIL_NONCONVERGENCE, & + 'nonlinear-nonconvergence', 5172) + + call database_finalize(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5173) + end subroutine check_newmark_nonconv_reason + subroutine check_static_adapt_newton() integer :: ierr integer :: iter @@ -600,6 +639,12 @@ contains if (convergence_status_code .ne. CONVERGENCE_STATUS_CONVERGED) & call fail(200) if (.not. convergence_converged) call fail(201) + call check_close(convergence_total_resid_norm, res_norm, 5510) + call check_close(convergence_force_resid_norm, res_norm, 5511) + call check_close(convergence_contact_resid_norm, ZERO, 5512) + call check_close(convergence_cons_resid_norm, ZERO, 5513) + call check_close(convergence_arc_resid_norm, ZERO, 5514) + if (convergence_material_fail_count .ne. 0) call fail(5515) nonlinear_continuation_method = old_method nlc_target_newton = old_target @@ -757,6 +802,10 @@ contains if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) & call fail(287) if (convergence_failure_code .ne. CONV_FAIL_STOPPED) call fail(288) + if (convergence_failure_reason_id .ne. NFAIL_ARC_CONSTRAINT) & + call fail(5290) + call check_reason_name(NFAIL_ARC_CONSTRAINT, & + 'arc-constraint-failure', 5291) nonlinear_continuation_method = old_method @@ -802,6 +851,14 @@ contains CONVERGENCE_STATUS_CONVERGED) call fail(246) if (nlc_path_int(NLC_PATH_I_FAILURE_CODE, 2) .ne. CONV_FAIL_NONE) & call fail(247) + if (nlc_path_real(NLC_PATH_R_TOTAL_RESIDUAL, 2) .gt. TOL) call fail(5520) + if (nlc_path_real(NLC_PATH_R_FORCE_RESIDUAL, 2) .gt. TOL) call fail(5521) + call check_close(nlc_path_real(NLC_PATH_R_CONTACT_RESIDUAL, 2), ZERO, & + 5522) + call check_close(nlc_path_real(NLC_PATH_R_CONS_RESIDUAL, 2), ZERO, 5523) + if (nlc_path_int(NLC_PATH_I_MATERIAL_FAIL_COUNT, 2) .ne. 0) & + call fail(5524) + call check_path_breakdown_header(5530) nonlinear_continuation_method = old_method @@ -1000,6 +1057,61 @@ contains if (ierr .ne. FEM_SUCCESS) call fail(262) end subroutine check_nonlinear_cg_fallback + subroutine check_nl_linear_failure_reason() + integer :: ierr + integer :: iter + integer :: old_method + integer :: old_preconditioner + integer :: old_linear_limit + integer :: failure_class + integer :: status_code + real(rk) :: res_norm + real(rk) :: final_residual + real(rk) :: relative_residual + real(rk) :: initial_residual + character(len=64) :: failure_reason + + call setup_unconstrained_load(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5400) + + call linear_solver_get_settings(old_method, old_preconditioner, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5401) + old_linear_limit = nonlinear_linear_iter_limit + + call linear_solver_configure(LSOLVER_DENSE, LPRECOND_NONE, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5402) + nonlinear_linear_iter_limit = 1 + current_time = ZERO + current_step = 0 + + call implicit_solve_nonlinear_static(ONE, 1, 20, 1.0e-12_rk, & + iter, res_norm, ierr) + if (ierr .eq. FEM_SUCCESS) call fail(5403) + if (convergence_status_code .ne. CONVERGENCE_STATUS_FAILED) & + call fail(5404) + if (convergence_failure_reason_id .ne. NFAIL_LINEAR_SOLVE) call fail(5405) + + call linear_solver_get_diagnostics(failure_class, initial_residual, & + final_residual, relative_residual, status_code, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5406) + if (status_code .ne. LS_STATUS_FAILED) call fail(5407) + if (initial_residual .le. ZERO) call fail(5408) + if (relative_residual .le. ZERO) call fail(5409) + + call linear_solver_get_fail_info(failure_class, failure_reason, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5410) + if (failure_class .ne. LS_FAIL_DENSE_FALLBACK) call fail(5411) + if (index(trim(failure_reason), 'dense-fallback-failure') .le. 0) & + call fail(5412) + + nonlinear_linear_iter_limit = old_linear_limit + call linear_solver_configure(old_method, old_preconditioner, ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5413) + + call database_finalize(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(5414) + end subroutine check_nl_linear_failure_reason + subroutine setup_pull_model(ierr) integer, intent(out) :: ierr @@ -1060,6 +1172,18 @@ contains ierr = FEM_SUCCESS end subroutine setup_single_free_dof_model + subroutine setup_unconstrained_load(ierr) + integer, intent(out) :: ierr + + call setup_base_tet(0, 1, ierr) + if (ierr .ne. FEM_SUCCESS) return + + cload_target(1) = '2' + cload_dof(1) = 1 + cload_value(1) = 5.0_rk + ierr = FEM_SUCCESS + end subroutine setup_unconstrained_load + subroutine setup_prescribed_model(ierr) integer, intent(out) :: ierr @@ -1197,6 +1321,46 @@ contains if (abs(actual - expected) .gt. TOL) call fail(code) end subroutine check_close + subroutine check_reason_name(reason_id, expected, code) + integer, intent(in) :: reason_id + character(len=*), intent(in) :: expected + integer, intent(in) :: code + character(len=64) :: actual + + call convergence_failure_reason_name(reason_id, actual) + if (trim(actual) .ne. trim(expected)) call fail(code) + end subroutine check_reason_name + + subroutine check_path_breakdown_header(code_base) + integer, intent(in) :: code_base + character(len=2048) :: header + integer :: ierr + integer :: ios + integer :: unit_id + + call output_csv_set_directory('build-codex-gcc/test_solver_implicit_path', & + ierr) + if (ierr .ne. FEM_SUCCESS) call fail(code_base) + call output_csv_write_path(ierr) + if (ierr .ne. FEM_SUCCESS) call fail(code_base + 1) + + unit_id = 94 + open(unit=unit_id, & + file='build-codex-gcc/test_solver_implicit_path/continuation_path.csv', & + status='old', action='read', iostat=ios) + if (ios .ne. 0) call fail(code_base + 2) + read(unit_id,'(A)',iostat=ios) header + close(unit_id) + if (ios .ne. 0) call fail(code_base + 3) + if (index(header, 'residual_total') .le. 0) call fail(code_base + 4) + if (index(header, 'residual_force') .le. 0) call fail(code_base + 5) + if (index(header, 'residual_contact') .le. 0) call fail(code_base + 6) + if (index(header, 'residual_constraint') .le. 0) call fail(code_base + 7) + if (index(header, 'residual_arc') .le. 0) call fail(code_base + 8) + if (index(header, 'material_failure_count') .le. 0) & + call fail(code_base + 9) + end subroutine check_path_breakdown_header + subroutine check_solver_diag(code_base) integer, intent(in) :: code_base integer :: ierr diff --git a/tests/performance/perf_contact_pair.f90 b/tests/performance/perf_contact_pair.f90 index f1e79c7..0cc2f7e 100644 --- a/tests/performance/perf_contact_pair.f90 +++ b/tests/performance/perf_contact_pair.f90 @@ -4,7 +4,8 @@ program perf_contact_pair use fem_database use fem_contact use fem_contact_state, only: contact_get_search_stats, & - contact_get_perf_stats, contact_get_cache_stats + contact_get_perf_stats, contact_get_cache_stats, CONTACT_PAIR_OPEN, & + CONTACT_PAIR_ACTIVATED, CONTACT_PAIR_MAINTAINED, CONTACT_PAIR_RELEASED use fem_assembly_csr use fem_sparse_csr implicit none @@ -27,6 +28,8 @@ program perf_contact_pair integer :: path_bvh_nodes_total integer :: path_cache_used_total integer :: path_cache_overflow_total + integer :: path_activated_total + integer :: path_released_total integer :: step_search_facets integer :: step_search_masters integer :: step_search_broad @@ -34,9 +37,24 @@ program perf_contact_pair integer :: step_search_bvh_nodes integer :: step_cache_used integer :: step_cache_overflow + integer :: state_open_count + integer :: state_activated_count + integer :: state_maintained_count + integer :: state_released_count + integer :: activation_count + integer :: release_count real(rk) :: search_time real(rk) :: force_time real(rk) :: tangent_time + real(rk) :: path_force_total + real(rk) :: path_tangent_matrix_total + real(rk) :: path_tangent_force_total + real(rk) :: path_gap_total + real(rk) :: path_slip_total + real(rk) :: final_force_total + real(rk) :: final_tangent_force_total + real(rk) :: final_gap_total + real(rk) :: final_slip_total real(rk) :: t0 real(rk) :: t1 @@ -52,6 +70,13 @@ program perf_contact_pair path_bvh_nodes_total = 0 path_cache_used_total = 0 path_cache_overflow_total = 0 + path_activated_total = 0 + path_released_total = 0 + path_force_total = ZERO + path_tangent_matrix_total = ZERO + path_tangent_force_total = ZERO + path_gap_total = ZERO + path_slip_total = ZERO call cpu_time(t0) do step = 1, step_count call update_slave_path(step, step_count) @@ -63,10 +88,19 @@ program perf_contact_pair call exit_if_error(ierr, 'assembly_build_csr_pattern') call contact_apply_plane_tangent(kmat, ZERO, ierr) call exit_if_error(ierr, 'contact_apply_plane_tangent') + path_tangent_matrix_total = path_tangent_matrix_total + csr_abs_sum(kmat) call csr_free(kmat, ierr) call exit_if_error(ierr, 'csr_free') end if path_active_total = path_active_total + contact_active_count + path_force_total = path_force_total + pair_force_sum() + path_tangent_force_total = path_tangent_force_total + pair_tan_force_sum() + path_gap_total = path_gap_total + pair_gap_sum() + path_slip_total = path_slip_total + pair_slip_sum() + path_activated_total = path_activated_total + & + count_pair_status(CONTACT_PAIR_ACTIVATED) + path_released_total = path_released_total + & + count_pair_status(CONTACT_PAIR_RELEASED) call contact_get_search_stats(step_search_facets, step_search_masters, & step_search_broad, step_search_active, & step_search_bvh_nodes) @@ -79,6 +113,16 @@ program perf_contact_pair call cpu_time(t1) active_count = contact_active_count + state_open_count = count_pair_status(CONTACT_PAIR_OPEN) + state_activated_count = count_pair_status(CONTACT_PAIR_ACTIVATED) + state_maintained_count = count_pair_status(CONTACT_PAIR_MAINTAINED) + state_released_count = count_pair_status(CONTACT_PAIR_RELEASED) + activation_count = pair_activation_sum() + release_count = pair_release_sum() + final_force_total = pair_force_sum() + final_tangent_force_total = pair_tan_force_sum() + final_gap_total = pair_gap_sum() + final_slip_total = pair_slip_sum() call contact_get_search_stats(search_facets, search_masters, search_broad, & search_active, search_bvh_nodes) call contact_get_cache_stats(cache_used, cache_overflow) @@ -101,15 +145,34 @@ program perf_contact_pair write(*,'(A,I8)') ' facets_per_side: ', nfacet write(*,'(A,I8)') ' path_steps: ', step_count write(*,'(A,I8)') ' path_active: ', path_active_total + write(*,'(A,I8)') ' path_activated: ', path_activated_total + write(*,'(A,I8)') ' path_released: ', path_released_total write(*,'(A,I8)') ' path_bvh_nodes: ', path_bvh_nodes_total write(*,'(A,I8)') ' path_cache_used: ', path_cache_used_total + write(*,'(A,I8)') ' path_cache_over: ', path_cache_overflow_total + write(*,'(A,ES16.8)') ' path_force_sum: ', path_force_total + write(*,'(A,ES16.8)') ' path_tan_mat_sum:', path_tangent_matrix_total + write(*,'(A,ES16.8)') ' path_tan_f_sum: ', path_tangent_force_total + write(*,'(A,ES16.8)') ' path_gap_sum: ', path_gap_total + write(*,'(A,ES16.8)') ' path_slip_sum: ', path_slip_total write(*,'(A,I8)') ' active_count: ', active_count + write(*,'(A,I8)') ' state_open: ', state_open_count + write(*,'(A,I8)') ' state_activated: ', state_activated_count + write(*,'(A,I8)') ' state_maintained:', state_maintained_count + write(*,'(A,I8)') ' state_released: ', state_released_count + write(*,'(A,I8)') ' activation_count:', activation_count + write(*,'(A,I8)') ' release_count: ', release_count write(*,'(A,I8)') ' search_facets: ', search_facets write(*,'(A,I8)') ' search_masters: ', search_masters write(*,'(A,I8)') ' search_broad: ', search_broad write(*,'(A,I8)') ' search_active: ', search_active write(*,'(A,I8)') ' bvh_nodes: ', search_bvh_nodes write(*,'(A,I8)') ' cache_used: ', cache_used + write(*,'(A,I8)') ' cache_overflow: ', cache_overflow + write(*,'(A,ES16.8)') ' force_sum: ', final_force_total + write(*,'(A,ES16.8)') ' tan_force_sum: ', final_tangent_force_total + write(*,'(A,ES16.8)') ' gap_sum: ', final_gap_total + write(*,'(A,ES16.8)') ' slip_sum: ', final_slip_total write(*,'(A,ES12.5)') ' search_cpu: ', search_time write(*,'(A,ES12.5)') ' force_cpu: ', force_time write(*,'(A,ES12.5)') ' tangent_cpu: ', tangent_time @@ -300,6 +363,63 @@ contains stop 1 end subroutine require_positive + integer function count_pair_status(status) + integer, intent(in) :: status + + count_pair_status = 0 + if (.not. allocated(contact_pair_status)) return + count_pair_status = count(contact_pair_status .eq. status) + end function count_pair_status + + integer function pair_activation_sum() + pair_activation_sum = 0 + if (allocated(contact_pair_activation_count)) then + pair_activation_sum = sum(contact_pair_activation_count) + end if + end function pair_activation_sum + + integer function pair_release_sum() + pair_release_sum = 0 + if (allocated(contact_pair_release_count)) then + pair_release_sum = sum(contact_pair_release_count) + end if + end function pair_release_sum + + real(rk) function pair_force_sum() + pair_force_sum = ZERO + if (allocated(contact_pair_force_norm)) then + pair_force_sum = sum(contact_pair_force_norm) + end if + end function pair_force_sum + + real(rk) function pair_tan_force_sum() + pair_tan_force_sum = ZERO + if (allocated(contact_pair_tangent_force)) then + pair_tan_force_sum = sum(abs(contact_pair_tangent_force)) + end if + end function pair_tan_force_sum + + real(rk) function pair_gap_sum() + pair_gap_sum = ZERO + if (allocated(contact_pair_gap_residual)) then + pair_gap_sum = sum(contact_pair_gap_residual) + end if + end function pair_gap_sum + + real(rk) function pair_slip_sum() + pair_slip_sum = ZERO + if (allocated(contact_pair_slip)) then + pair_slip_sum = sum(contact_pair_slip) + end if + end function pair_slip_sum + + real(rk) function csr_abs_sum(a) + type(csr_matrix), intent(in) :: a + + csr_abs_sum = ZERO + if (associated(a%val)) csr_abs_sum = sum(abs(a%val)) + end function csr_abs_sum + subroutine exit_if_error(ierr_in, label) integer, intent(in) :: ierr_in character(len=*), intent(in) :: label diff --git a/tests/performance/perf_p1.f90 b/tests/performance/perf_p1.f90 index e9b15f0..b566f85 100644 --- a/tests/performance/perf_p1.f90 +++ b/tests/performance/perf_p1.f90 @@ -40,7 +40,7 @@ program perf_p1 call fem_get_version(major, minor, patch, ierr) call exit_if_error(ierr) - if (major .ne. 0 .or. minor .ne. 5 .or. patch .ne. 2) then + if (major .ne. 0 .or. minor .ne. 5 .or. patch .ne. 3) then write(*,'(A,I1,A,I1,A,I1)') 'unexpected FemLite version ', major, '.', minor, '.', patch call exit(3) end if diff --git a/tests/unit/test_smoke.f90 b/tests/unit/test_smoke.f90 index fe1e420..019be8e 100644 --- a/tests/unit/test_smoke.f90 +++ b/tests/unit/test_smoke.f90 @@ -94,7 +94,7 @@ program test_smoke if (ierr .ne. 0) stop 2 if (major .ne. 0) stop 3 if (minor .ne. 5) stop 4 - if (patch .ne. 2) stop 5 + if (patch .ne. 3) stop 5 call fem_read_inp('examples/c3d4_one_element.inp', ierr) if (ierr .ne. 0) stop 11 diff --git a/todo.md b/todo.md index 89f735d..0874be7 100644 --- a/todo.md +++ b/todo.md @@ -1,2142 +1,377 @@ -# FemLite V5 Remaining TODO +# FemLite 0.5.3 TODO -Status date: 2026-06-30 +Source plan: `docs/v5.3_development_plan.md` -This file is the executable TODO list for the current 0.5.x development cycle. -The phase status table is maintained only in `docs/v5_development_plan.md`. +Version goal: -## 2026-06-30 V5 Release Scope Decision +```text +FemLite 0.5.3 = 接触与非线性诊断加固版 +``` -The V5 release boundary is narrowed to a shippable V5.11 capability checkpoint. -V5.11 must prove that the finite-membrane-strain S4 production route is present, -tested, documented, and capable of a non-monotone spherical-cap postbuckling -signature under the agreed Shell-4 translational-rim benchmark口径. It is not -required to fully reproduce the entire `uz=-6.2 m` PDF curve or close all -Shell-4/8/16 reference-shape differences before the V5 release. +Boundary: -The following items are explicitly deferred to the next version line and must -not block V5 release: +- Do not add broad new feature families in 0.5.3. +- Do not claim complete industrial AL/mortar consistent tangent. +- Do not move deferred shell preload buckling, high-order solid `K_G`, mixed-control + Riks, cohesive contact mainline, nonzero harmonic cyclic, DEM subcycling or + production roll forming into the 0.5.3 must-complete list. +- Every new diagnostic field must be consumed by a test, checker or report audit. -- Full spherical-cap PDF curve reproduction through `uz=-6.2 m`. -- Strict Shell-4/8/16 curve-family comparison to digitized PDF values. -- True pseudo-arclength / branch-following continuation beyond the default - direct-displacement path improvements. -- Late post-peak GMRES/performance optimization beyond documented diagnostics. -- The V5.12 backlog: `two_arches` single reference-point check, industrial mortar/AL close-out, - Mohr-Coulomb critical-instability cloud longrun, generic buckling/cyclic main-solver - integration, roll forming production workflow, cohesive contact main-flow - integration, high-fidelity example upgrades, and longrun/performance close-out. +## Execution Order -V5.11 may be marked release-ready when its checker, documentation, and evidence -validate the bounded capability claim: finite-strain S4 production dispatch, -stable shell geometry inputs, continuation-path diagnostics, the fixed support -口径, and a reproducible post-peak load drop with documented remaining limits. +1. NL-1: failure reason taxonomy. +2. LS-1: linear solver nonlinear-diagnostic bridge. +3. CT-1: contact state count standardization. +4. CT-2: contact residual diagnostics. +5. CT-3: mortar/friction tangent audit enhancement. +6. CT-4: OpenMP contact path consistency enhancement. +7. NL-2: nonlinear residual breakdown output. +8. DOC-1: documentation and benchmark matrix synchronization. +9. REL-1: 0.5.3 build/regression/version close-out. -Rules for closing an item: +## Detailed Execution Map -- Completed task headings use `[x]`; open task headings use `[ ]`. -- Code must be implemented in production modules, not benchmark-only helpers in - `src`. -- Tests must be automated through CTest or a documented extended test command. -- Examples must live under `examples/`, one folder per case, with README, input, - double-click run script and a check script when the case is used for - acceptance. -- Documentation must describe the algorithm, interface, user behavior and - developer maintenance path. -- Large generated result files must not be committed. +| TODO | Code targets | Output/API contract | Test/checker target | Not in scope | +|---|---|---|---|---| +| 0.5.3-1 | `src/base/fem_control.f90`, `src/base/fem_api_diagnostics.f90`, nonlinear solver failure markers | Add stable `NFAIL_*` id/name while keeping existing `CONV_FAIL_*` status codes | `solver_implicit`, `implicit_inp` | Rewrite cutback/Newton algorithms | +| 0.5.3-2 | `src/solver/fem_solver_implicit_support.f90`, `src/solver/fem_linear_solver_dispatch.f90` | Map linear-solver failure diagnostics into nonlinear reason id/name | `linear_solver_cg`, `solver_implicit` | Add new linear solver backends | +| 0.5.3-3 | `src/boundary/fem_contact_history.f90`, `src/boundary/fem_contact_multiplier.f90`, contact report writers | Standard contact state counts: open/stick/slip/restick/separating/failed projection | `restart`, contact report module tests | Full contact state-machine rewrite | +| 0.5.3-4 | Contact search/history diagnostics and contact CSV/report output | Add max penetration, mean gap, gap L2, failed projection and active-set flip fields | `contact_mortar_report`, compression checker | Change contact enforcement method | +| 0.5.3-5 | Friction history diagnostics and sliding/contact report output | Add slip increment/residual and tangential residual fields | friction/contact module tests, sliding checker | Retune friction law | +| 0.5.3-6 | Multiplier and mortar AL diagnostics/report paths | Add multiplier residual and augmentation/update count fields | `contact_multiplier_report`, `restart` | Industrial AL/mortar consistent tangent rewrite | +| 0.5.3-7 | Mortar tangent audit helpers/output | Split normal tangent finite-difference audit fields | `contact_mortar_tangent` | Replace production normal-contact tangent | +| 0.5.3-8 | Friction tangent audit helpers/output | Split stick/slip tangent finite-difference audit fields | `contact_mortar_tangent` | Replace production friction tangent | +| 0.5.3-9 | `perf_contact_pair` and `tools/testing/check_perf_contact_pair_omp.py` | Compare deterministic force/tangent/cache/state/residual fields across threads | `perf_contact_pair_omp_consistency` | Treat timing differences as failures | +| 0.5.3-10 | Nonlinear static/Newmark diagnostic storage | Store total/force/contact/constraint/arc/material residual breakdown | `solver_implicit` | Add new nonlinear control family | +| 0.5.3-11 | Path CSV/contact summary writers and schema comments | Write residual breakdown columns without removing old columns | continuation/contact checkers | Break old CSV consumers | +| 0.5.3-12 | Restart writer/reader and restart contact audit test | Verify contact diagnostics before/after restart after an accepted increment | `restart`, compact INP restart if needed | Redesign restart format | +| 0.5.3-13 | Contact example checkers and README field notes | Check explainable diagnostic fields in compression/sliding/shell contact examples | four contact benchmark CTest entries | Overfit exact nonlinear values | +| 0.5.3-14 | V5 docs, interface docs, manuals, example docs | Document new diagnostic boundary and deferred items | wording `rg` checks | Claim full industrial AL/mortar tangent | +| 0.5.3-15 | V5 matrix/report/version files | Close 0.5.3 only after green targeted and V5 acceptance tests | build, targeted tests, V5 acceptance, `git diff --check` | Release/version bump before tests pass | -## V5.2 Dependency-Free Sparse Solver Hardening +## Implementation Rules -Boundary for this module: +- Work in the execution order above; do not mark a TODO done until its tests or + checker target consumes the new field. +- Prefer additive fields and thin accessors over changing existing public + signatures. +- If a task exposes multiple incompatible implementation routes, pause and ask + for a decision before editing that route. +- If a later task needs a field created by an earlier task, finish and test the + earlier task first rather than partially implementing both. -- Do not add third-party solver libraries. -- Do not introduce an external solver process as a required or accepted - production backend. -- Do not expose third-party or external solver method/backend interfaces through - the Fortran API, C ABI, CMake options or helper tools. -- Legacy external solver numeric values must be rejected as invalid - configuration and must leave the active internal solver settings unchanged. +## 0.5.3 Task List -### [x] DONE V5.2-1: Harden internal sparse solver workflows +### [x] TODO 0.5.3-1: Define nonlinear failure reason taxonomy +- Source: + - `docs/v5.3_development_plan.md` section 4.1, NL-1. - Implementation: - - Keep CG, BiCGSTAB, GMRES and the internal dense pivoting fallback as the - production solver family. - - Reject legacy external solver method/backend ids at the configuration - boundary with no fallback solve and no state mutation. - - Record method, preconditioner, iteration count, residual, matrix class and - failure status for every static and implicit solve. - - Reuse the existing CSR diagnostics to classify SPD, structurally symmetric - and nonsymmetric systems before dispatch. + - [x] Add stable reason ids and names for nonlinear/cutback failures. + - [x] Cover at least these categories: linear solve failure, residual + stagnation, correction norm too large, line-search failure, trust rejection, + contact active-set oscillation, projection failure, excessive penetration, + material return failure, Riks/arc constraint failure, constraint residual + failure and minimum step exhaustion. + - [x] Keep existing solver status codes compatible; add mapping rather than + replacing public status values abruptly. + - [x] Expose the last reason id/name through the existing nonlinear diagnostic + path or a thin new accessor. - Tests: - - Add or extend CTest coverage for SPD CG, nonsymmetric BiCGSTAB, - nonsymmetric GMRES and dense pivoting matrices. - - Add structural workflow checks for linear static, implicit Newmark and one - nonlinear/contact correction path using internal solvers. - - Add a C ABI check that the legacy external solver method value is rejected - and does not change solver settings. + - [x] Add `solver_implicit` coverage for at least three distinct failure + reasons. + - [x] Add `implicit_inp` coverage that reason fields remain stable through + INP-driven nonlinear failure. - Acceptance: - - Default builds have no third-party solver dependency. - - No external solver constants, C ABI prototypes, CMake targets or helper - tools remain in the module. - - Static, implicit and nonlinear/contact paths solve through internal - dispatch and report diagnostics. - - Legacy external solver selection never silently falls back to an internal - solve. -- Completion evidence: - - `linear_solver_solve` records CSR matrix class, initial residual, final - residual, relative residual, method, preconditioner, iteration and status. - - `linear_solver_cg`, `solver_implicit`, `implicit_inp` and `c_api` cover the - internal diagnostic path and legacy external method rejection. - - `linear_solver_cg` now also covers the internal dense pivoting solve on an - indefinite matrix; `solver_implicit` covers a nonlinear correction path that - restores user settings after an automatic CG-to-GMRES fallback. + - [x] Failure summaries no longer report only a generic solver error when a + known nonlinear/cutback cause is available. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp)$" --output-on-failure` passed. -### [x] DONE V5.2-2: Document no-external-solver policy +### [x] TODO 0.5.3-2: Map linear solver failures into nonlinear failure reasons +- Source: + - `docs/v5.3_development_plan.md` sections 4.7 and 5, LS-1 before CT tasks. - Implementation: - - Update user, algorithm and developer documentation to state that the core - module is dependency-free with respect to sparse solvers. - - Document the supported internal solver methods, preconditioners and + - [x] Extend linear-solver diagnostics with selected method, preconditioner, + matrix class, initial/final/relative residual and failure class. + - [x] Map linear solver nonconvergence, invalid matrix class and dense fallback + failure into nonlinear failure reason ids. + - [x] Preserve current CG/BiCGSTAB/GMRES/dense behavior; this task must not add + a new solver backend. + - [x] Add a selected-solver reason string for nonlinear contexts. +- Tests: + - [x] Extend `linear_solver_cg` failure-state coverage. + - [x] Extend `solver_implicit` to verify linear failure becomes a nonlinear + failure reason. +- Acceptance: + - [x] A nonlinear solve that fails because the linear solve failed reports both + linear residual diagnostics and the mapped nonlinear reason. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(linear_solver_cg|solver_implicit|implicit_inp)$" --output-on-failure` passed. + +### [x] TODO 0.5.3-3: Standardize contact state count fields + +- Source: + - `docs/v5.3_development_plan.md` section 4.3, CT-1. +- Implementation: + - [x] Define stable contact state names or ids for the 0.5.3 subset: + `open`, `closed-stick`, `closed-slip`, `closed-restick`, `separating` and + `failed-projection`. + - [x] Map existing contact history and active/released/open multiplier states + onto the stable subset without rewriting the full contact solver. + - [x] Add aggregate state counts to contact report/summary data. + - [x] Ensure state counts are available after trial, commit and restart paths. +- Tests: + - [x] Extend `restart` to check active/open and stick/slip state count + preservation. + - [x] Extend a contact report/module test to validate state count totals. +- Acceptance: + - [x] Contact benchmark summaries expose stable state counts that survive + restart round trips. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(restart|contact_multiplier_report)$" --output-on-failure` passed. + +### [x] TODO 0.5.3-4: Add contact gap and penetration residual diagnostics + +- Source: + - `docs/v5.3_development_plan.md` section 4.4, CT-2. +- Implementation: + - [x] Add max penetration, mean gap and gap L2 norm to contact diagnostics. + - [x] Track failed projection count where the current search/projection path + can identify it. + - [x] Add active-set flip count for multi-step contact paths where previous + contact state is available. + - [x] Write these fields to contact report/summary output. +- Tests: + - [x] Extend `contact_mortar_report` or adjacent contact tests for gap fields. + - [x] Update `example_contact_two_blocks_compression_benchmark` checker to + consume at least max penetration and gap norm fields. +- Acceptance: + - [x] Compression contact failures can be distinguished as penetration/gap + issues rather than opaque nonlinear failures. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(contact|example_contact_two_blocks_compression_benchmark)$" --output-on-failure` passed. + +### [x] TODO 0.5.3-5: Add contact slip and friction residual diagnostics + +- Source: + - `docs/v5.3_development_plan.md` section 4.4, CT-2. +- Implementation: + - [x] Add slip increment norm and slip residual to contact/friction diagnostics. - - Document that external solver interfaces have been removed and legacy - external method values are invalid. + - [x] Add tangential/friction residual summary where friction history is + active. + - [x] Keep friction work and accumulated slip fields backward compatible. + - [x] Write slip/friction diagnostic fields to sliding benchmark output or + contact report output. - Tests: - - Keep default CTest working without any optional solver package. - - Add source/documentation checks when practical to prevent reintroducing - third-party solver build options. + - [x] Extend friction/contact module tests for slip residual fields. + - [x] Update `example_contact_block_sliding_benchmark` checker to consume at + least one slip/friction diagnostic field. - Acceptance: - - V5 planning and release documentation no longer list external solver - enablement or adapter interfaces as current-version acceptance items. -- Completion evidence: - - User, algorithm, interface, test and developer documentation now describe - the no-external-solver policy and the internal solver diagnostic fields. + - [x] Sliding contact output can distinguish normal contact problems from + tangential stick/slip residual problems. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(contact|example_contact_block_sliding_benchmark)$" --output-on-failure` passed. -## V5.3 Mortar / Augmented Lagrangian Contact - -### [x] DONE V5.3-1: Promote two-block contact to nonmatching mortar benchmark - -- Implementation: - - `examples/contact_two_blocks_compression` uses a nonmatching 4-facet lower - master face against a 1-facet upper slave face. - - The checker derives pressure profile, max gap, weighted gap, multiplier - residual and augmented multiplier metrics from contact CSV output. - - `pressure_profile.csv` is written in the result directory for benchmark - inspection. -- Tests: - - `check_contact_results.py` checks active contact, master-facet coverage, - pressure range, weighted penetration, multiplier residual, augmented - multiplier growth and VTK output. - - CTest `example_contact_two_blocks_compression_benchmark` runs the example - and calls the check script through `tools/testing/run_example_smoke.py`. -- Acceptance: - - The nonmatching pressure benchmark passes in the default Release CTest - path. - - Example README documents the nonmatching mesh, reference metrics and - limitations. -- Completion evidence: - - `ctest --test-dir build-win-gcc-16 -C Release -R example_contact_two_blocks_compression_benchmark --output-on-failure` - passed on 2026-06-26. - -### [x] DONE V5.3-2: Promote sliding contact to large-sliding mortar-friction benchmark - -- Implementation: - - `examples/contact_block_sliding` now uses a nonmatching 4-facet lower - master surface and a 1-facet upper slave surface. - - The upper block is force-driven over the master surface while normal - augmented multiplier history and tangential stick/slip/friction-work - output remain coupled through the production contact path. - - Restart continuity for contact friction and multiplier state is covered by - the module-level `restart` CTest; the example benchmark focuses on the - large-sliding friction trajectory. -- Tests: - - `check_contact_results.py` writes `sliding_profile.csv` and checks - multiple master facets, multiple active candidates, accumulated slip, - stick/slip counters, tangential force, positive friction work and VTK - output. - - CTest `example_contact_block_sliding_benchmark` runs the full example and - checker through `tools/testing/run_example_smoke.py`. - - Existing `contact_omp1`, `contact_omp4` and - `perf_contact_pair_omp_consistency` continue to cover OpenMP contact - consistency at module/performance-smoke level. -- Acceptance: - - Stick/slip transitions are reported. - - Frictional work is nonnegative within tolerance. - - Restart continues multiplier and friction history without jumps in the - module restart regression. -- Completion evidence: - - `ctest --test-dir build-win-gcc-16 -C Release -R example_contact_block_sliding_benchmark --output-on-failure` - passed on 2026-06-26. - -### [x] DONE V5.3-3: Add shell/solid contact benchmark coverage - -- Implementation: - - Added `examples/shell_shell_contact` with an S4-to-S4 contact benchmark. - - Added `examples/shell_solid_contact` with an S4 slave surface contacting a - C3D8 solid master face. - - Both examples use the existing contact pair, mortar force/output and - augmented multiplier paths; no special-case production path was added. -- Tests: - - Each example has a local checker that writes a compact profile CSV and - checks active contact, force norm, gap residual, augmented multiplier, - master search and VTK output. - - CTest entries `example_shell_shell_contact_benchmark` and - `example_shell_solid_contact_benchmark` run the examples and checkers. -- Acceptance: - - At least one shell-solid and one shell-shell contact case pass automated - checks. -- Completion evidence: - - `ctest --test-dir build-win-gcc-16 -C Release -R "example_shell_(shell|solid)_contact_benchmark" --output-on-failure` - passed on 2026-06-26. - -## V5.4 Mohr-Coulomb And Strength Reduction - -### [x] DONE V5.4-1: Finish material-point acceptance tests - -- Implementation: - - Cover triaxial compression, triaxial extension, pure shear and tensile - cutoff. - - Record active branch or return-map mode for each test. -- Tests: - - Add explicit tolerance checks for stress, plastic multiplier and branch id. -- Acceptance: - - All material-point tests pass without substep explosion. - - Tangent or algorithmic stiffness limitations are documented. -- Completion evidence: - - `test_material_mohr_coulomb` now covers triaxial compression, triaxial - extension, pure shear, tensile cutoff, mixed return, branch id, - post-return yield tolerance and plastic increment checks. - - `test_material_mc_driver` and `test_material_mc_envelope` cover path - driver diagnostics, branch counts, limited status, tangent diagnostics, - envelope margins, safety ratios and reduced material parameters. - - Algorithm, detailed design, interface, test, user and developer - documentation now describe the Mohr-Coulomb equations, input format, - state variables, driver diagnostics and engineering tangent limitations. - - Targeted CTest command: - `ctest --test-dir build-win-gcc-16 -C Release -R "material_mohr_coulomb|material_mc_driver|material_mc_envelope" --output-on-failure`. - -### [x] DONE V5.4-2: Replace strengthReduction placeholder with MC benchmark - -- Implementation: - - Update `examples/strengthReduction` to use real Mohr-Coulomb material input. - - Add strength reduction search controls and output safety-factor history. - - Output plastic zone and displacement control probe. -- Tests: - - Add check script for final safety factor range, bracket convergence and - plastic-zone extent. -- Acceptance: - - Safety factor lies inside documented tolerance. - - Check script fails if the solve only runs linear elastic behavior. -- Completion evidence: - - `strength_reduction_slope_static.inp` now uses `MC_SOIL` with - `*MOHR COULOMB` friction, cohesion, dilation, tensile cutoff, residual - parameters and reduction factor fields. - - `tools/benchmarks/strength_reduction_benchmark.f90` links the production - core and calls the Mohr-Coulomb yield path plus strength-reduction - driver/report modules to generate safety-factor history, summary, - plastic-zone and displacement-probe files. - - `check_strength_reduction_results.py` rejects the old elastic placeholder - and checks converged safety factor, real stable/unstable bracket, plastic - zone activation, displacement probe signs, VTK and node output. - - CTest `example_strength_reduction_benchmark` passed on 2026-06-26 with - `FS=1.21125`, 8 trials, 3 stable trials, 5 unstable trials and 2 active - plastic probes. - -## V5.5 Linear Buckling And Cyclic Symmetry - -### [x] DONE V5.5-1: Add analytic buckling verification - -- Implementation: - - Add a small column or beam benchmark with known Euler critical load. - - Assemble prestress/geometric stiffness through the production path. -- Tests: - - Check first eigenvalue relative error. -- Acceptance: - - Relative error and mode normalization are documented. -- Completion evidence: - - Added `examples/euler_column_buckling` with README, benchmark input, - double-click `run_case.bat` and `check_buckling_results.py`. - - Added production `src/solver/fem_buckling_column.f90`; it reads the Euler - `*BUCKLING COLUMN` block, assembles beam bending stiffness through - `geom_beam2d_column_stiffness`, calls `buckling_dense_solve`, compares - against `buckling_euler_column_load` and writes summary/mode CSV files. - - Kept `tools/benchmarks/euler_column_buckling_benchmark.f90` outside `src` - as a thin wrapper around `buckling_column_run_file`; the old duplicate - helper-side assembly/solve algorithm has been deleted. - - Hardened `buckling_dense_solve` so the internal dense Jacobi eigensolver - iteration budget scales with problem size. - - `examples/euler_column_buckling/run_case.bat` and - `check_buckling_results.py` now run the main `femlite --buckling` - workflow. - - CTest `example_euler_column_buckling_benchmark` passed on 2026-06-27 with - relative error `3.27661E-05`, residual `1.50015E-11` and - `phi^T K_G phi = 1.0`. - -### [x] DONE V5.5-2: Upgrade corrugated shell benchmark - -- Implementation: - - Replace static-only smoke with buckling eigenvalue analysis. - - Add cyclic sector model and full-model comparison when feasible. - - Write mode shape output through modal output path. -- Tests: - - Check critical load range and cyclic/full consistency. -- Acceptance: - - README documents eigenvalue, mode count, cyclic wave number and tolerance. -- Completion evidence: - - Added `tools/benchmarks/corrugated_shell_buckling_benchmark.f90` outside - `src`; it builds a sixteen-sector reduced corrugated-shell periodic - buckling model, calls production `buckling_dense_solve`, validates the - selected wave through `fem_cyclic_symmetry` and writes modal output through - `modal_write_csv`. - - Added `corrugated_shell_buckling_benchmark.inp`, - `check_buckling_results.py`, updated `run_case.bat` and rewrote the - example README with reference metrics and tolerances. - - Replaced CTest `example_buckling_corrugated_shell_smoke` with - `example_buckling_corrugated_shell_benchmark`. - - CTest `example_buckling_corrugated_shell_benchmark` passed on 2026-06-26 - with selected wave 4 load `453.031407`, critical wave 8 load - `393.369677`, cyclic/full relative error `1.25473461E-16` and modal - residual `1.31855319E-12`. - - `source_size` CTest passed after the new benchmark tool was added. - -## V5.6 High-Fidelity Roll Forming - -### [x] DONE V5.6-1: Add real roller kinematics to contact workflow - -- Implementation: - - Ensure rigid roller rotation contributes to relative tangential velocity. - - Couple roller translation, down-feed and angular velocity in input/control. - - Output roller force, torque, contact pressure band and friction work. -- Tests: - - Unit test roller kinematics and relative velocity sign. - - Example check for nonzero rolling traction and stable energy trend. -- Acceptance: - - Removing angular velocity changes tangential traction in the check case. -- Completion evidence: - - Added production `roller_regularized_traction` to `fem_rigid_roller`; it - uses the same roller tangential velocity path and a smooth - `tanh(slip/reference_speed)` friction factor so spin changes traction - magnitude, not only slip speed. - - Extended `test_rigid_roller` with a spin/no-spin comparison that verifies - angular speed changes slip and regularized traction. - - Added `tools/benchmarks/roll_forming_kinematics_benchmark.f90` outside - `src`; it drives production roller pose, schedule, contact kinematics, - regularized traction and roll metrics to output roller history and summary. - - Added `examples/roll_forming/roll_forming_kinematics_benchmark.inp`, - `check_roller_kinematics.py` and updated `run_case.bat`/README. - - CTest `example_roll_forming_kinematics_benchmark` passed on 2026-06-26 - with mean slip `0.4` with spin vs `0.2` without spin, mean traction - `289.208274` with spin vs `228.478247` without spin, max traction delta - `60.7300272` and positive roller torque `14.4604137`. - -### [x] DONE V5.6-2: Add plastic forming and springback benchmark - -- Implementation: - - Upgrade `examples/roll_forming` to include plastic workpiece and unloading. - - Output residual displacement, plastic zone and springback metric. -- Tests: - - Check forming force range, positive plastic work and springback sign/range. -- Acceptance: - - Example is no longer only an elastic contact surrogate. -- Completion evidence: - - Added production roll metrics helpers for residual displacement and - springback ratio, with `test_rigid_roller` coverage. - - Added `tools/benchmarks/roll_forming_springback_benchmark.f90` outside - `src`; it drives production roller kinematics, regularized traction, - roll metrics and J2 small-strain material updates on a compact multilayer - workpiece section, then solves unloading release curvature by bending - moment balance. - - Added `examples/roll_forming/roll_forming_springback_benchmark.inp` and - `check_springback_results.py`; `run_case.bat` now runs the springback - benchmark after the friction smoke and kinematics benchmark. - - Targeted checker passed on 2026-06-26 with springback ratio `0.473154068`, - residual displacement `0.0316107559`, plastic work `1.11591736e-05`, - 56/81 active plastic points and residual moment absolute value - `8.92778801e-11`. - -## V5.7 Cohesive Adhesion / Decohesion - -### [x] DONE V5.7-1: Add cohesive single-point acceptance tests - -- Implementation: - - Cover loading, unloading, mixed-mode damage and complete decohesion. - - Track damage, maximum opening, energy and status. -- Tests: - - Verify nonnegative dissipated energy and irreversible damage. -- Acceptance: - - Restarted state preserves damage and maximum opening. -- Completion evidence: - - `test_cohesive_contact` now drives one cohesive integration point through - bonded loading, mixed-mode damage, unloading, reload and complete - decohesion. - - The path records damage, maximum opening, effective separation, dissipated - energy and status through `fem_cohesive_state` and `fem_cohesive_metrics`. - - The test verifies nonnegative energy increments, irreversible damage, - failed-state zero traction, failed-area metrics and restart preservation of - damage, maximum opening, maximum effective separation, energy and status. - - Targeted command passed on 2026-06-26: - `ctest --test-dir build-win-gcc-16 -C Release -R "cohesive_contact|source_size" --output-on-failure`. - -### [x] DONE V5.7-2: Upgrade ball adhesion/decohesion example - -- Implementation: - - Use cohesive law/state in `examples/ball_adhesion_decohesion`. - - Output force-displacement curve, cohesive energy and decohesion area. -- Tests: - - Add check script for hysteresis, peak pull-off force and dissipated energy. -- Acceptance: - - Example fails if cohesive damage is not activated. -- Completion evidence: - - Added `tools/benchmarks/ball_adhesion_cohesive_benchmark.f90` outside - `src`; it discretizes the adhesive ball/membrane patch into concentric - rings and drives compression, unloading and pull-off through production - `fem_cohesive_law`, `fem_cohesive_state` and `fem_cohesive_metrics`. - - Added `ball_adhesion_cohesive_benchmark.inp` and - `check_cohesive_results.py` under `examples/ball_adhesion_decohesion`; - `run_case.bat` now runs the original contact smoke and the cohesive - benchmark. - - The benchmark writes `adhesion_history.csv`, `adhesion_summary.csv` and - `decohesion_profile.csv`, covering force-displacement hysteresis, - cohesive energy, peak pull-off force, damage and decohesion area. - - CTest `example_ball_adhesion_cohesive_benchmark` passed on 2026-06-26 with - peak pull-off force `119.246023`, min compression force `-362.051100`, - dissipated energy `0.451891017`, hysteresis area `0.898170568` and final - failed fraction `1.0`. - -## V5.8 Particle / Flexible Container Coupling - -### [x] DONE V5.8-1: Complete particle acceptance primitives - -- Implementation: - - Cover particle free fall, wall collision, particle-particle pile and - particle-facet coupling with production modules. - - Output mass, momentum, kinetic energy, dissipated energy and max overlap. -- Tests: - - Add checks for mass conservation, bounded overlap and nonnegative - dissipation. -- Acceptance: - - Diagnostics are available through Fortran and documented output paths. -- Completion evidence: - - Added `pstep_diag_values` to expose `particle_step_diag` mass, momentum, - kinetic energy, step dissipated energy and max-overlap values through the - Fortran module API. - - Added CTest `particle_acceptance`, covering free fall, damped wall rebound, - three-particle pile contact and particle-facet load transfer with the - production particle state/contact/step/facet modules. - - The test checks mass conservation, bounded overlap, nonnegative - dissipation, kinetic/momentum diagnostics and particle-facet nodal force - balance. - - `ctest --test-dir build-win-gcc-16 -C Release -R "particle_acceptance|source_size" --output-on-failure` - passed on 2026-06-26. - -### [x] DONE V5.8-2: Upgrade dynamic grain container example - -- Implementation: - - Replace pressure surrogate with real particles and flexible container - two-way force mapping. - - Record particle count, contact count, container displacement and energy. -- Tests: - - Add example check script for particle statistics and container response. -- Acceptance: - - Example fails if particle forces are not mapped back to the FEM model. -- Completion evidence: - - Added `tools/benchmarks/dynamic_grain_container_benchmark.f90` outside - `src`; it loads a pressure-free flexible S4 container, applies real - particle-facet contact through `particle_fem_apply_all`, maps nodal loads - through `fsph`, advances the FEM response and preserves particle reaction - forces for particle integration. - - Added `dynamic_grain_container_benchmark.inp`, - `flexible_container_grain_benchmark.inp` and - `check_grain_container_results.py` under - `examples/Dynamic_Grain_Packing_of_a_Flexible_Container`; `run_case.bat` - now runs the old smoke and the V5.8 benchmark checker. - - The checker rejects pressure surrogate input and verifies particle count, - contact count, mapped nodal force, downward container response, mass - conservation, bounded overlap and nonnegative energy. - - CTest `example_dynamic_grain_container_benchmark` passed on 2026-06-26 - with 4 particles, 4 facet contacts, `mapped_steps=40`, max mapped vertical - load `3.68E+01`, minimum center displacement `-7.29240354E-06` and max - overlap `3.00615680E-03`. - - Full Release command - `ctest --test-dir build-win-gcc-16 -C Release --output-on-failure` - passed on 2026-06-26 with 106/106 tests. - -## V5.9 Benchmark, Performance And Documentation - -### [x] DONE V5.9-1: Build V5 benchmark matrix - -- Implementation: - - Add a table mapping every V5 completed capability to an example directory, - test name, reference metric and tolerance. - - Keep smoke and benchmark tiers separate. -- Tests: - - Default CTest remains fast. - - Extended benchmark command runs the V5 acceptance checks. -- Acceptance: - - No completed V5 capability relies only on a smoke test. -- Completion evidence: - - Added `docs/v5_benchmark_matrix.md` with V5.2-V5.8 capability-to-test - mapping, example directories, output files, reference metrics and - acceptance tolerances. - - Added CTest label `v5_acceptance` to current V5 acceptance tests and - benchmark examples while preserving existing default CTest behavior. - - Documented the extended command - `ctest --test-dir build-win-gcc-16 -C Release -L v5_acceptance --output-on-failure`. - - The extended command passed on 2026-06-26 with 35/35 tests. - -### [x] DONE V5.9-2: Refresh documentation after each capability closes - -- Implementation: - - Update requirements, architecture, detailed design, algorithms, interface, - test plan, user manual and developer manual only with factual implementation - details. - - Keep status markers only in `docs/v5_development_plan.md`. -- Acceptance: - - Status-table wording remains confined to `docs/v5_development_plan.md`. -- Completion evidence: - - Updated README, `docs/01_requirements_specification.md`, - `docs/02_software_architecture_design.md`, `docs/03_detailed_design.md`, - `docs/04_mathematical_model_and_algorithms.md`, - `docs/05_interface_control_document.md`, - `docs/06_test_and_verification_plan.md`, `docs/07_user_manual.md`, - `docs/08_developer_manual.md`, `docs/v5_development_plan.md` and - `docs/v5_benchmark_matrix.md` for V5.8 and V5.9-1 changes. - - Core docs describe the implemented particle algorithm, staggered - particle-container coupling, benchmark CLI, output files and verification - commands without adding phase status markers outside - `docs/v5_development_plan.md`. - - Documentation checks verified no phase-status markers in the core docs - listed above. - -## V5.10 Acceptance And Release - -### [x] DONE V5.10-1: Create V5 acceptance report - -- Implementation: - - Add `docs/v5_acceptance_report.md`. - - Summarize completed, incomplete and postponed items from - `docs/v5_development_plan.md`. - - Include exact test commands, environment and results. -- Acceptance: - - Report identifies every remaining deferred item, reason, risk and effect on - users. -- Completion evidence: - - Added `docs/v5_acceptance_report.md` with the current V5 acceptance scope, - Windows Release environment, exact CMake/CTest commands, 106/106 default - CTest record and 35/35 `v5_acceptance` record. - - The report summarizes completed V5.2-V5.8 capabilities, remaining - engineering gaps, and postponed or out-of-current-module items with reason, - risk and user effect. - - README now links to the V5 acceptance report. - -### [x] DONE V5.10-2: Final release hygiene - -- Implementation: - - Ensure worktree is clean except intended release files. - - Clean generated root result files. - - Run default CTest and any enabled extended benchmark tests. -- Acceptance: - - Release branch or main merge has reproducible test output. - - README and version metadata match the release state. -- Completion evidence: - - Root-level generated result files (`history.csv`, `nodes_*.csv`, - `elements_*.csv`, `reactions_*.csv`, `contact_*.csv`, `result_*.vtk`, - `femlite.log`) were removed after the final full CTest run. - - `ctest --test-dir build-win-gcc-16 -C Release -L v5_acceptance --output-on-failure` - passed on 2026-06-26 with 35/35 tests. - - `ctest --test-dir build-win-gcc-16 -C Release --output-on-failure` - passed on 2026-06-26 with 106/106 tests. - - README and version metadata are aligned on `0.5.0`. - - V5 release changes are prepared as the intended release-file set on `main`; - committing these changes makes the worktree clean for the current release - checkpoint. - -## V5.11 Finite-Membrane-Strain Shell And Spherical Cap Postbuckling - -Boundary for this module: - -- V5.11 release acceptance is a finite-strain S4 production capability - checkpoint, not a full PDF curve-reproduction claim. The spherical-cap case - must demonstrate the agreed postbuckling口径 with a reproducible post-peak load - drop, but full `uz=-6.2 m` curve matching to - `models.sme.spherical_cap_with_central_point_load.pdf` is deferred. -- The production route is Abaqus-style finite-membrane-strain S4: finite - rotation director update, finite membrane strain, Koiter-Sanders type - curvature increment, MITC/ANS assumed strain, and analytic consistent tangent. -- The old S4 diagnostic route was temporary technical debt. It explained earlier - failures, but it is not a stable interface and not acceptance evidence. - V5.11-1 removes its production dispatch, input aliases, tests, documentation - entry points, and unused helper code. Do not leave fallback interfaces. -- Reusable foundations are limited to `fem_shell_section`, shell layer/resultant - state, shell pressure follower tangent, internal nonsymmetric solver support, - and continuation path output. -- The V5 checker must reject regressions to linear, small-strain, monotone-only - or old corotational behavior. It does not need to pass strict Shell-4/8/16 PDF - digitized-curve matching in this release. - -Current facts: - -- `examples/spherical_cap_with_central_point_load` checks reference geometry, - material scale and Shell-16 small-strain samples; the Shell-4 deck now uses - the all-S4 finite-strain target route with translational rim support as the - V5.11 postbuckling capability proof. -- `continuation_path.csv` records accepted displacement/reaction rows, linear - solver diagnostics, path-control diagnostics and trust diagnostics, so the - checker can validate the bounded V5 post-peak signature and preserve evidence - for the deferred full-curve work. -- `SHELL_GEOMETRIC=YES`, `GEOMETRIC_SHELL`, `COROTATIONAL_SHELL`, and - `S4_COROTATIONAL` are removed migration-era interfaces; the target user-facing - syntax is `SHELL_GEOMETRIC=FINITE_STRAIN` or `SHELL_GEOMETRIC=LINEAR`. - -### [x] TODO V5.11-0: Redesign docs around finite-strain S4 - -- Implementation: - - [x] Update `docs/03_detailed_design.md` with finite-strain S4 modules: - rotation state, finite kinematics, assumed strain, nonlinear driver, - tangent, drilling, and section coupling. - - [x] Update `docs/04_mathematical_model_and_algorithms.md` with finite - membrane strain, finite rotation director update, Koiter-Sanders type - curvature, MITC/ANS, and analytic tangent requirements. - - [x] Update `docs/05_interface_control_document.md`, - `docs/06_test_and_verification_plan.md`, `docs/07_user_manual.md`, - `docs/08_developer_manual.md`, and `docs/v5_development_plan.md` so they no - longer describe corotational S4 as the V5.11 completion route. - - [x] Record the deletion rule: old exploratory code and aliases must be - removed after the complete implementation replaces them. -- Acceptance: - - [x] Documentation separates reusable foundations from temporary - corotational code and explicitly forbids keeping unused interfaces. - -### [x] DONE V5.11-1: Delete obsolete corotational interfaces and dead code - -- Implementation: - - [x] Inventory every production call site, input alias, public API, test, and - documentation reference containing `corotational`, `COROTATIONAL_SHELL`, - `S4_COROTATIONAL`, or old boolean-only `SHELL_GEOMETRIC` semantics. - - [x] Keep only foundations required by finite-strain S4: - `fem_shell_section`, shell layer state, `shell_resultant`, pressure follower - tangent, nonsymmetric solver support, and continuation path output. - - [x] Delete production dispatch paths, parser aliases, helper routines, and - tests that only serve the old corotational route and are not needed by the - finite-strain implementation. - - [x] Add input validation so `SHELL_GEOMETRIC=FINITE_STRAIN` and - `SHELL_GEOMETRIC=LINEAR` are the stable forms; old aliases fail with a clear - input error after migration. -- Tests: - - [x] Add parser tests proving old aliases are rejected after migration. - - [x] Run shell, implicit input, spherical cap, and source-size regressions. -- Acceptance: - - [x] No stable user-visible or internal production interface remains for the - old corotational route. - - [x] `rg -n "COROTATIONAL_SHELL|S4_COROTATIONAL|corotational"` returns only - historical notes or intentionally named removed-history comments, not live - production dispatch. -- Completion evidence: - - Removed `src/element/fem_shell_corotational.f90` from source and CMake. - - Removed old shell corotational production dispatch and FD tangent/resultant - helper routines from `fem_element_internal` and `fem_element_stiffness`. - - Replaced `shell_geometric_nonlinear` with - `shell_finite_strain_requested`; `SHELL_GEOMETRIC` now accepts only - `FINITE_STRAIN` or `LINEAR`. - - Old `GEOMETRIC_SHELL`/`COROTATIONAL_SHELL`/`S4_COROTATIONAL` aliases are - rejected with a clear input error and parser rollback is tested. - - Removed the old curved S4 nonlinear patch input and tests that only served - the deleted route. - - Updated spherical-cap Shell-16 deck to `SHELL_GEOMETRIC=LINEAR` and Shell-4 - target deck to `SHELL_GEOMETRIC=FINITE_STRAIN`; finite-strain shell requests - now fail clearly until V5.11-4 through V5.11-6 are implemented. - - Build passed: - `cmake --build build-win-gcc-16 --target femlite test_implicit_inp test_shell_internal -j 4`. - - Targeted CTest passed: - `ctest --test-dir build-win-gcc-16 -R "^(implicit_inp|shell_internal|source_size|example_spherical_cap_point_load_benchmark)$" --output-on-failure`. - -### [x] DONE V5.11-2: Implement finite rotation shell state - -- Implementation: - - [x] Add node or shell-node rotation trial/committed state using exponential - map or quaternion update. - - [x] Integrate rotation state with reset, backup, rollback, commit, cutback, - line-search rejection, Newmark rollback, and restart. - - [x] Keep global node DOF 4:6 as Newton increments while committed director - state carries finite rotation history. -- Tests: - - [x] Rigid-body large rotation produces zero or near-zero finite-kinematics - strain once the rotation state is consumed by the V5.11-3 S4 kinematics - module. - - [x] Failed increments restore rotation state exactly. -- Acceptance: - - [x] Rotation state is not recomputed from small-angle accumulated DOF in a - way that loses finite rotation objectivity. -- Completion evidence: - - Added production `fem_shell_rotation` with per-node quaternion committed, - trial and backup state; nodal DOF 4:6 remain incremental Newton rotation - corrections and update trial orientation by exponential-map quaternion - increments. - - `element_state_ensure/reset/begin/restore/commit/abort` now includes shell - rotation lifecycle so cutback, rejected trial steps and Newmark rollback - restore the finite-rotation state together with integration-point state. - - Restart format version 3 writes and reads the committed shell rotation - block; version 1/2 restarts initialize the rotation state to identity. - - `test_element_state` verifies identity initialization, 90-degree - finite-rotation vector behavior, commit, restore and abort rollback. - `test_restart` verifies shell rotation restart persistence and vector - rotation after reload. - - Build passed: - `cmake --build build-win-gcc-16 --target test_element_state test_restart femlite -j 4`. - - Targeted CTest passed: - `ctest --test-dir build-win-gcc-16 -R "^(element_state|restart|implicit_inp|shell_internal|source_size|example_spherical_cap_point_load_benchmark)$" --output-on-failure`. - -### [x] DONE V5.11-3: Implement S4 finite kinematics and MITC/ANS - -- Implementation: - - [x] Compute reference/current covariant bases, director fields, surface - metrics, finite membrane strain, Koiter-Sanders type curvature increment, - and transverse shear strain for S4. - - [x] Handle initially curved or warped shell reference geometry without - flattening the element into a small-strain local plane. - - [x] Implement S4 MITC/ANS transverse shear sampling and keep extension points - for membrane/bending assumed strain if needed. -- Tests: - - [x] Small-rotation finite-strain S4 matches existing linear S4 patch - kinematics. - - [x] MITC transverse shear patch is verified at the kinematic projection - level. - - [x] Warped/curved reference patch has no spurious initial strain. -- Acceptance: - - [x] The formulation works for the spherical-cap mesh geometry, not only flat - plates. -- Completion evidence: - - Added production `fem_shell_finite_kinematics` for S4 reference/current - covariant bases, director interpolation, surface metrics, finite membrane - strain, Koiter-Sanders-style curvature increment, local engineering strain - projection and direct/MITC transverse shear sampling. - - The module consumes arbitrary reference/current director fields, including - directors generated from `fem_shell_rotation`; it does not accumulate small - angle DOF values as finite orientation history. - - Added CTest `shell_finite_kinematics`, covering small membrane strain, - small bending curvature, MITC constant shear projection, warped reference - zero strain, quaternion-state rigid rotation zero strain and spherical-cap - patch geometry. - - Build passed: - `cmake --build build-win-gcc-16 --target test_shell_finite_kinematics test_shell_internal test_element_state test_restart test_implicit_inp femlite -j 4`. - - Targeted CTest passed: - `ctest --test-dir build-win-gcc-16 -R "^(shell_finite_kinematics|shell_internal|element_state|restart|implicit_inp|source_size|example_spherical_cap_point_load_benchmark)$" --output-on-failure`. - -### [x] DONE V5.11-4: Implement analytic consistent shell tangent - -- Implementation: - - [x] Assemble material tangent `B^T D_alg B`. - - [x] Assemble geometric tangent from membrane force, bending moment, and - transverse shear resultants. - - [x] Assemble rotation tangent from director and curvature linearization. - - [x] Assemble drilling stabilization tangent as a separate energy-consistent - contribution. - - [x] Keep finite-difference tangent only as an audit tool, never as the final - production Newton tangent. - - [x] Connect the GP tangent to the S4 element/global assembly only after the - solver synchronizes nodal rotation DOF increments into `shell_rotation_trial` - at every residual/tangent evaluation. -- Tests: - - [x] Finite-difference column audit passes for elastic S4. - - [x] J2/J2_JC/composite section tangent audit passes under large rotation. - - [x] S4 element-level tangent audit passes; spherical-cap Newton/cutback - evidence is tracked in V5.11-6 because the current target deck contains - unsupported S3 crown fan elements. -- Acceptance: - - [x] The tangent is analytic, documented, and does not rely on hidden - benchmark-only code. -- Progress evidence: - - Added `shell4_finite_bmat_at` and `shell4_finite_derivs_at` in - `fem_shell_finite_kinematics`; the derivative tensor is the algorithmic - finite-rotation linearization used by the residual, not a symmetric - coordinate Hessian. - - Added production `fem_shell_finite_tangent`, assembling - `K = B^T D_alg B + sum_i R_i dB_i/du` at S4 integration-point level for - membrane, bending and MITC transverse shear resultants. - - Added CTest `shell_finite_tangent`; `shell_finite_kinematics` now audits - finite-strain values, B columns and `dB/du`, while `shell_finite_tangent` - audits the 24-by-24 elastic GP tangent against internal-force column finite - differences. - - Build passed: - `cmake --build build-win-gcc-16 --target test_shell_finite_tangent test_shell_finite_kinematics -j 4`. - - Targeted CTest passed: - `ctest --test-dir build-win-gcc-16 -R "^(shell_finite_kinematics|shell_finite_tangent)$" --output-on-failure`. - - Added production `fem_shell_finite_element`: `SHELL_GEOMETRIC=FINITE_STRAIN` - now dispatches S4 elements through finite-strain internal force and tangent - assembly, including averaged nodal reference directors, current director - trial rotations, section resultants, geometric/rotation tangent and - energy-consistent drilling energy. - - `fem_shell_rotation` now synchronizes rotation DOFs incrementally inside an - active trial: each residual/tangent evaluation multiplies only the newest - Newton rotation correction into `shell_rotation_trial`, matching the - `dB/du` linearization. - - Added CTest `shell_finite_element`, covering S4 production dispatch, element - 24-column finite-difference tangent, drilling residual/stiffness energy - consistency, unsymmetric composite membrane-bending coupling, J2/J2_JC large - rotation section tangents, composite plastic layer state, and plastic - rollback. - - Targeted CTest passed: - `ctest --test-dir build-win-gcc-16 -R "^(shell_finite_element|shell_finite_kinematics|shell_finite_tangent|shell_internal|element_state|implicit_inp|restart|source_size|example_spherical_cap_point_load_benchmark)$" --output-on-failure`. - - Remaining spherical-cap postbuckling evidence is deferred to V5.11-6: - the Shell-4 target deck has since been converted to all-S4 topology, but - the nonlinear curve still fails the PDF load drop/restiffening signature. - -### [x] DONE V5.11-5: Couple finite-strain S4 to shell sections and materials - -- Implementation: - - [x] Route ELASTIC, J2, J2_JC, and composite shell sections through - `fem_shell_section` with trial/rollback semantics. - - [x] Complete multilayer plastic through-thickness state where composite - layers use plastic materials. - - [x] Preserve membrane-bending coupling for unsymmetric laminates. -- Tests: - - [x] ELASTIC/J2/J2_JC/composite large-rotation shell material tests pass. - - [x] Plastic layer state rolls back after failed increment. -- Acceptance: - - [x] Unsupported shell material models fail explicitly, with no fallback to an - elastic engineering tangent. -- Completion evidence: - - `fem_shell_section` now owns the public production APIs - `shell_section_update_resultants` and `shell_section_tangent_at`; finite and - small-strain shell paths share the same state update, through-thickness - layer integration, algorithmic tangent and rollback storage. - - `shell_finite_element` covers ELASTIC, unsymmetric elastic composite, J2, - J2_JC and composite-with-J2-layer finite-strain S4 paths under large - rotations, plus rollback after a rejected plastic trial. - - Targeted CTest passed as listed in V5.11-4. - -### [x] DONE V5.11-6: Close bounded spherical-cap postbuckling capability benchmark - -- Implementation: - - [x] Generate Shell-16 baseline and Shell-4 finite-strain target decks with - `a = 10 m`, `th = 0.203840 m`, `E = 210 GPa`, `nu = 0.3`, cap angle - `pi/4`, and documented support口径. - - [x] Output nondimensional curve data: - `wn = -w/th`, `Fn = -F*a/(E*th^3*2*pi)`. - - [x] Use production continuation and finite-strain shell code only. - - [x] Resolve the Shell-4 target mesh blocker: the deck no longer contains S3 - crown fan elements and now uses an all-S4 square-disk crown remesh matching - the PDF radius, thickness, cap angle and fixed rim geometry. - - [x] Resolve the release-blocking physics question at bounded scope: the - all-S4 Shell-4 translational-rim target shows a clear post-peak load drop, - so V5.11 has evidence of nonlinear postbuckling behavior and is no longer - blocked by the absence of a limit-point signature. - - [x] Diagnose the main reference口径 differences before changing more - production physics: top-surface offset is not the dominant scale error, - while rim rotational clamping strongly changes the curve and masks the - post-peak branch. The V5.11 Shell-4 target therefore uses translational rim - support; full PDF curve matching remains deferred. - - [x] Update the spherical-cap checker so the V5 bounded nonlinear route - validates the bounded capability claim: Shell-16 baseline geometry, Shell-4 - finite-strain all-S4 target, translational rim support, continuation-path - columns, non-monotone post-peak load drop and documented known limits. - - [x] Move strict Shell-4/8/16 PDF curve matching, full `uz=-6.2 m` - reproduction and restiffening-window tuning into the next-version backlog. - - [x] Expose nonlinear stage tracing through `femlite --trace-nonlinear` - so long spherical-cap runs show whether time is spent in pattern assembly, - stiffness assembly or linear solves. - - [x] Avoid the expensive CG-first path for finite-strain shell nonlinear - corrections: small finite-shell systems now use the internal dense solver - directly, while larger finite-shell systems switch to GMRES before the - existing fallback chain. - - [x] Expose `femlite --linear-iter` so benchmark and diagnostic runs can - bound nonlinear correction solve attempts before fallback handling. - - [x] Expose `femlite --shell-drilling` and wire the spherical-cap nonlinear - checker to `FEMLITE_SPHERICAL_CAP_SHELL_DRILLING` so drilling-stabilization - sensitivity can be audited without changing defaults. - - [x] Confirm on the rebuilt E-drive GCC build that Shell-4 direct - displacement reaches `uz=-2 m` with a post-peak load drop and restiffening - in the accepted continuation path; the remaining blocker is the larger - displacement/path and reference-shape mismatch, not the absence of any - limit-point signature. - - [x] Run a short drilling-stabilization sensitivity probe: the default - Shell-4 `uz=-2 m` path completed with the same load-drop/restiffening - signature, while zero drilling stabilization did not complete within the - diagnostic timeout, so the next fix should not be a simple stabilization - reduction. - - [x] Add shell strain diagnostic columns to `elements_*.csv` - (`shell_mem_max`, `shell_ben_max`, `shell_shr_max`, `shell_k11`, - `shell_k22`, `shell_k12`) so spherical-cap runs can separate membrane, - bending and shear contributions without adding benchmark-only code. - - [x] Confirm on the Shell-4 `uz=-2 m` diagnostic run that the final state is - not dominated by transverse shear locking: at `wn ~= 9.8`, the largest - element values are approximately membrane `4.1e-2`, bending curvature - `3.9e-1`, and shear `1.1e-2`; the next audit should focus on membrane/ - bending coupling, curvature sign/scale, and mesh/path effects. - - [x] Add a finite-kinematics unit audit for spherical normal offset so the - membrane and bending curvature signs are checked on a curved reference - patch, not only on flat bending patches. - - [x] Tighten that finite-kinematics audit so the same spherical offset also - checks membrane and bending curvature scale (`offset/R` and `offset/R^2`). - This passed on the E-drive GCC build, so the current Shell-4 over-stiffening - is unlikely to be a basic curved-patch strain-scale amplification. - - [x] Test angle-weighted production reference-director averaging. It is a - generic robustness improvement and passes finite-shell regressions, but the - Shell-4 `uz=-2 m` curve is essentially unchanged (`Fn` at `wn ~= 9.8` - changes from about `0.83302` to `0.83289`), so the dominant V5.11-6 issue is - unlikely to be nodal director averaging alone. - - [x] Run a Shell-8 `uz=-2 m` square-disk finite-strain diagnostic. It - completed in about 130 s with 10 increments and 85 Newton iterations. The - early curve is much softer than Shell-4 and closer to the PDF/Shell-16 - reference scale (`Fn ~= 0.591` at `wn ~= 6.28`, versus Shell-4 `Fn ~= 0.653` - at the same displacement), but it is still monotone through `wn ~= 9.8`. - This points to a combined mesh/path-resolution issue rather than a single - obvious curvature-sign bug. - - [x] Re-run the Shell-8 short diagnostic after the displacement-amplitude - correction. A temporary all-S4 Shell-8 deck to `uz=-1.984 m` completed in - about 113 s with 13 accepted increments and 91 Newton iterations; at - `wn ~= 9.73`, `Fn ~= 0.804`. This confirms that mesh refinement softens the - response but does not by itself close the PDF-scale mismatch. - - [x] Add an experimental finite S4 membrane-locking control path: - `--shell-membrane-locking center` uses an element-center assumed membrane - strain and matching membrane tangent rows, while the default remains off. - The switch is covered by `shell_finite_element`. A spherical-cap probe with - the switch enabled reached heavy iteration near `time ~= 0.78`, so it is - retained as a controlled diagnostic instead of becoming the production - default. - - [x] Improve continuation path sampling for long diagnostics: - displacement-control and arc-length accepted steps now refresh - `continuation_path.csv` immediately after `nlc_path_append`, so a long run - can be inspected before the full analysis finishes. Verified with - `c3d4_static_arc_disp_continuation.inp` and `--output-interval 0`, producing - a two-row path CSV. - - [x] Extend `continuation_path.csv` with per-row linear-solver diagnostics: - method, preconditioner, iteration count, status, initial residual, final - residual and relative residual. This makes long spherical-cap runs - inspectable without enabling a separate trace file. Verified with the - compact `c3d4_static_arc_disp_continuation.inp` path CSV. - - [x] Extend `continuation_path.csv` with accepted-step path-control - diagnostics: `target_dt`, `actual_dt`, `next_dt`, `adapt_adjust` and - cumulative `cutback_count`. Path rows are now recorded after the next-step - decision is available, so long post-peak runs show whether the driver is - growing, keeping, shrinking or recovering from cutback at each accepted - increment. Covered by `solver_implicit` and a compact path-column probe. - - [x] Re-run the Shell-4 `time=0.48` diagnostic with path-level linear-solver - stats. It completed in about 40 s with 24 increments and 168 Newton - iterations; the last accepted steps used GMRES/Jacobi with roughly 75-94 - linear iterations and final relative residuals around `1e-7`. The runtime - issue is therefore repeated Newton corrections plus moderate GMRES work, - not a single runaway linear solve. - - [x] Add controlled direct-displacement path adaptivity instead of making it - unconditional: `DISP_ADAPTIVE=YES` in `*NONLINEAR CONTINUATION` or - `femlite --disp-path-adaptive on` routes direct displacement control through - the existing target-Newton adaptive loop. Later V5.11 post-peak diagnostics - showed that the fixed-grid default was still too brittle for the - translational-rim spherical-cap path, so this adaptive route was promoted to - the default direct-displacement continuation behavior; explicit - `DISP_ADAPTIVE=NO` / `--disp-path-adaptive off` remains available for old - fixed-grid sampling. - - [x] Add `femlite --linear-precond none|jacobi|gs|ilu0` for controlled - nonlinear diagnostics. On the Shell-4 `time=0.48` probe, ILU0 reduced the - last-step GMRES iteration count from roughly 90 to roughly 15, but total - runtime increased from about 40 s to about 62 s, so the default remains - Jacobi for this benchmark size. - - [x] Create CSV/VTK output directories automatically in - `output_csv_set_directory`, including nested paths. This covers immediate - path flushing when `--output-interval 0` is used and no output directory - exists yet; `vtk_output` now exercises a fresh nested output directory. - - [x] Fix direct displacement-control path sampling for prescribed - displacements that already carry an amplitude. `*BOUNDARY, AMPLITUDE=...` - under `METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL` now uses the amplitude as - the displacement path instead of multiplying it by the static `load_factor` - a second time. The Shell-4 spherical cap target is therefore linear in - `time` again (`uz = -6.2*time`, not `-6.2*time^2`), and - `solver_implicit` covers the amplitude regression. - - [x] Lower the finite-strain shell nonlinear auto-dense threshold from 1000 - DOF to 250 DOF. The 486-DOF Shell-4 spherical-cap diagnostic now routes to - the nonsymmetric Krylov path instead of the slow dense pivot path; the - `time=0.48` diagnostic improved from roughly 94 s to roughly 63 s with the - same 24 accepted increments and 168 Newton iterations. - - [x] Add `femlite --static-predictor on|off` so nonlinear static predictor - behavior can be audited without changing defaults. On the Shell-4 - `time=0.48` diagnostic it did not reduce Newton iterations, so it is not a - default spherical-cap fix. - - [x] Audit center crown rotation constraints by running a temporary input - without `CROWN, 4, 6, 0.0`; the curve matched the fixed-rotation run through - `time=0.48`, so crown rotations are not the observed stiffness source. - - [x] Capture a `time=0.48` element diagnostic after the amplitude fix: - at `wn ~= 14.6`, `Fn ~= 2.108`, max membrane strain is about `4.4e-2`, - max bending curvature about `4.75e-1`, and max transverse shear about - `8.4e-3`. The remaining physics mismatch is therefore still dominated by - membrane/bending path behavior rather than transverse shear. - - [x] Resolve the remaining reference-model口径 gap before changing more - production physics: the COMSOL PDF shell setup uses a selected boundary - with `Thickness and Offset` set to `Top surface on boundary` and notes that - the shell normal points inward, while the current all-S4 deck treats the - generated spherical geometry as the shell midsurface. The PDF also describes - the shell fixed constraint as a point constraint in its axisymmetric setup, - while the current 3D deck fixes the full rim node set in DOF 1-6. These - differences need a controlled diagnostic deck before the curve mismatch is - treated as a finite-shell formulation bug. The follow-up diagnostic deck - showed that top-surface offset is not the dominant scale error, while - translational rim support restores the expected bounded post-peak drop. - - [x] Run controlled reference-scope diagnostic decks at the same - `wn ~= 14.60` short target. Moving the spherical shell surface outward by - `th/2` changed the clamped-rim response only from `Fn ~= 2.108` to - `Fn ~= 2.066`, so the COMSOL top-surface offset is not the dominant scale - error. Changing the rim from full DOF 1-6 clamping to translational DOF 1-3 - support softened the response to `Fn ~= 1.286` (`Fn ~= 1.296` with the same - outward half-thickness shift), much closer to the PDF interpolation - `Fn ~= 1.094` at the same `wn`. The next benchmark decision should focus on - whether the 3D cap deck should represent the PDF shell rim as translational - support rather than full rotational clamping. - - [x] Extend the rim-translational-support diagnostic toward `uz=-4.0 m`. - The run accepted 42 increments before the long diagnostic was stopped/ - ended at `time ~= 0.84`, reaching `wn ~= 16.48` and `Fn ~= 0.920`. - It shows a clear post-peak load drop: the accepted path peaked at - `Fn ~= 1.341` near `wn ~= 13.74`, then decreased through `Fn ~= 1.296` at - `wn ~= 14.52`, `Fn ~= 1.097` at `wn ~= 15.70`, and `Fn ~= 0.920` at - `wn ~= 16.48`. This confirms that the previous full-rim rotational clamping - was masking the benchmark's postbuckling signature. The remaining blocker is - long-path robustness/restiffening capture for the translational-rim support - deck, not the absence of a limit point. - - [x] Solidify the benchmark support口径 before further path-control work. - The generator now writes `RIM_DOF_MAX=6` for the historical Shell-16 - small-strain baseline and `RIM_DOF_MAX=3` plus `RIM, 1, 3, 0.0` for the - Shell-4 finite-strain postbuckling target. The checker now requires this - split and rejects accidental Shell-4 full rotational rim clamping; the - example README documents why the translational-rim support is the Shell-4 - target after the offset/rim diagnostic. - - [x] Retry the same `uz=-4.0 m` rim-translational-support deck with - `--allow-cutback`. Cutback crossed the formerly failing increment 43 by - reducing the time step from `0.02` to `0.005`, then accepted increment 44 at - `time ~= 0.846875`, `wn ~= 16.62`, `Fn ~= 0.807`. The run was stopped after - no additional accepted row appeared over the next observation window; the - next improvement should make direct-displacement cutback/adaptivity less - prone to very small late-path steps or reduce the heavy GMRES work in this - post-peak region. - - [x] Try direct-displacement adaptive stepping on the rim-translational deck - with `DISP_ADAPTIVE=YES`, `TARGET_NEWTON=12`, `GROWTH=1.5` and - `--allow-cutback`. A shorter `uz=-3.5 m` diagnostic advanced farther than - fixed cutback, accepting to `time ~= 0.965`, `uz ~= -3.3775 m`; the path - retained the same post-peak drop but still stalled before the target. This - suggests the right production path is adaptive direct displacement plus a - post-peak linear-solver/runtime improvement, not just enabling cutback. - - [x] Re-run that adaptive `uz=-3.5 m` diagnostic with `--linear-precond ilu0`. - ILU0 reduced post-peak GMRES iterations dramatically (typical accepted - rows near `time=0.80..0.965` dropped from roughly `145..266` iterations with - Jacobi to roughly `20..30` with ILU0), but the run still stalled after the - same accepted row at `time ~= 0.965`. The remaining blocker is therefore - primarily nonlinear path/step acceptance around the steep post-peak branch; - ILU0 is useful for runtime once that path control is improved. - - [x] Expose CLI line-search diagnostics: - `--line-search-min-alpha`, `--line-search-reduction`, and - `--line-search-accept-ratio`. A smoke run accepts valid values and rejects - an invalid zero min-alpha. Lowering min alpha to `0.03125` with adaptive - displacement, cutback and ILU0 let the `uz=-3.5 m` diagnostic move slightly - farther, from `time ~= 0.965` to `time ~= 0.9675`, but it remained too slow - to finish. This confirms line-search damping helps but is not sufficient; - the next production change should focus on more robust post-peak step-size - control rather than only exposing solver knobs. - - [x] Expose CLI cutback diagnostics: - `--max-cutback` and `--cutback-factor` now override the retry count and - shrink factor for a single run without changing benchmark inputs. A compact - displacement-control smoke accepts `--allow-cutback --max-cutback 12 - --cutback-factor 0.25` and rejects invalid `--cutback-factor 1.0`. - - [x] Run one long Shell-4 rim-translational diagnostic with the new path - columns before changing path-control algorithms. With adaptive displacement - stepping, ILU0, `--line-search-min-alpha 0.03125`, `--max-cutback 16` and - `--cutback-factor 0.35`, the 15-minute diagnostic was stopped after 39 - accepted rows at `time ~= 0.5469`, `uz ~= -3.3907 m`, `wn ~= 16.63`, - `Fn ~= 0.747`. The path peaked at `Fn ~= 1.339` near `wn ~= 13.38` and - dropped by about 44 percent, so the translational-rim benchmark口径 is still - producing the expected post-peak branch. The new diagnostics show the - blocker is step-size collapse after repeated cutbacks (`actual_dt` down to - about `3.75e-5`), not runaway linear solves: ILU0 linear iterations peaked - at 115 and ended at 52 with relative residual around `5e-9`. - - [x] Run a compact cutback-factor comparison before changing defaults. - Keeping the same rim-translational Shell-4 setup and diagnostics, - `--cutback-factor 0.5` reached essentially the same post-peak point - (`wn ~= 16.63`, `Fn ~= 0.754`) within the observation window but retained a - larger final step (`actual_dt ~= 6.25e-4`, two cumulative cutbacks and max - linear iterations 36). A more conservative `--cutback-factor 0.7` retained - an even larger accepted step (`actual_dt ~= 1.75e-3`) but moved fewer rows - in the same time and pushed the last linear solve to about 111 iterations. - This confirms the next production change should not be a fixed cutback - factor default; it should be a guarded post-cutback recovery/growth policy - that avoids both collapse to tiny increments and expensive over-large - retries. - - [x] Try and reject an immediate/two-stage post-cutback recovery gate. The - immediate version grew the accepted `0.00125` post-cutback step to - `0.00153` and then produced no additional accepted row in the same - observation window; the delayed two-stage version avoided that premature - growth but still stopped at the same accepted row (`time ~= 0.54625`, - `wn ~= 16.61`) and did not outperform the plain `--cutback-factor 0.5` - diagnostic. The production change was therefore reverted. The remaining - path-control issue likely needs a more deliberate continuation strategy - around the steep post-peak branch, not a local growth gate. - - [x] Add and probe an explicit trust-region diagnostic for direct - displacement-control ARC_DISP paths. A positive `TRUST_RADIUS` on the - continuation line, or CLI `--trust-radius`, now reuses the existing damped - Newton correction limiter while keeping ARC_DISP path output; default - ARC_DISP remains unchanged. Compact tests cover parsing, CLI validation and - a direct-displacement path with trust enabled. Spherical-cap probes showed - `--trust-radius 0.05` was too conservative, accepting many small rows but - only reaching about `wn ~= 11.94` in the observation window. A looser - `--trust-radius 0.2` removed cutbacks and held `dt ~= 0.0025` through - `wn ~= 16.58`, but still did not outperform the plain `--cutback-factor - 0.5` run within the same wall-clock window. Keep this as a controlled - diagnostic, not a default fix. - - [x] Extend continuation path output with trust-region diagnostics: - `trust_radius`, `next_trust_radius`, `trust_damping`, - `trust_merit_ratio`, `trust_adjust` and `trust_rejections`. The spherical - cap checker carries these through to `spherical_cap_load_displacement.csv`, - so future trust probes can distinguish "stable but slow because heavily - damped" from ordinary step-size or linear-solver stalls. - - [x] Re-run a looser trust diagnostic with the new trust output columns. - `--trust-radius 0.4` reached `time ~= 0.54625`, `wn ~= 16.61` and - `Fn ~= 0.816` with one cumulative cutback and max linear iterations 36. - The trust columns showed no actual correction damping on accepted rows - (`trust_damping = 1.0`), only radius adjustment near the last accepted - increment (`trust_radius ~= 0.0225`, next `~= 0.03375`). This makes the - result useful diagnostically but not a better fix than the plain - `--cutback-factor 0.5` run, which reached a slightly farther/lower - post-peak point in the same diagnostic window. - - [x] Start the explicit default continuation-path改造 instead of continuing - local parameter probes. Direct prescribed-displacement - `ARC_LENGTH_OR_DISPLACEMENT_CONTROL` now defaults to adaptive path spacing, - and accepted path rows feed back into the next step size: if the generalized - reaction changes by more than about 8 percent over the last accepted path - segment, the next displacement increment is capped before the following - Newton solve. The direct-displacement path also uses a relaxed default - internal Newton target of 12 when the input keeps the historical default - `TARGET_NEWTON=6`, so accepted 4-6 iteration steps can grow instead of - staying stuck at an early limited step. In a 90 s Shell-4 spherical-cap - observation window, the old default adaptive behavior produced 163 accepted - rows by `time ~= 0.5435` with `dt ~= 0.0031`; the new default reached the - same post-peak region in 30 accepted rows by `time ~= 0.5342`, with no - cutbacks and `next_dt ~= 0.0146`. The remaining cost is high late GMRES - iteration count, not path fragmentation. - - [x] Test two follow-up post-peak path-control ideas and reject them as - insufficient: keeping the accepted small step immediately after a cutback - did not move the `uz=-3.5 m` diagnostic beyond the previous stalled region, - so that production change was reverted; enabling the existing static - predictor changed the accepted substep pattern but again stalled around - `time ~= 0.9675`. The remaining work now requires a deliberate path-control - design choice rather than another local parameter tweak. - - [x] Record the remaining full-curve limits in README/user docs instead of - treating them as V5 release blockers: full `uz=-6.2 m` runtime, strict PDF - mid-path scale matching, later restiffening capture and late GMRES cost. -- Tests: - - [x] Checker validates the V5 bounded post-peak load-drop capability and - writes the current curve metrics to `spherical_cap_load_displacement.csv`. - - [x] Checker records but does not require strict Shell-4/8/16 PDF digitized - curve matching in this release. - - [x] Checker fails monotone curves, small-strain samples, and old - corotational diagnostic decks. -- Acceptance: - - [x] `example_spherical_cap_point_load_benchmark` validates the fast - Shell-16/Shell-4口径 checks, and the documented extended nonlinear checker - validates the bounded V5.11 finite-strain S4 postbuckling capability while - documenting deferred full-curve limitations. -- Current evidence: - - `cmake -S . -B build-codex-gcc -G "MinGW Makefiles"` configured the current - `E:\Codex\FemLite` checkout with GCC/GFortran 16.1.0. - - `cmake --build build-codex-gcc --target femlite test_shell_finite_kinematics - test_shell_finite_tangent test_shell_finite_element test_shell_internal - test_implicit_inp` passed after the solver-dispatch changes. - - `ctest --test-dir build-codex-gcc -R - "^(shell_finite_kinematics|shell_finite_tangent|shell_finite_element|shell_internal|implicit_inp)$" - --output-on-failure` passed 5/5. - - `python tools/testing/check_source_size.py . --warn-file-lines 1500 - --max-file-lines 2000 --warn-routine-lines 100 --max-routine-lines 128 - --exceptions tests/source_size_exceptions.txt` passed. - - After adding the direct-displacement trust diagnostics and path output - columns, `ctest --test-dir build-codex-gcc -R - "^(solver_implicit|implicit_inp|example_spherical_cap_point_load_benchmark)$" - --output-on-failure` passed 3/3, and the direct source-size check passed - with only the existing review warnings. - - After rewriting the V5 release scope, the default spherical-cap benchmark - passed with - `ctest --test-dir build-codex-gcc -R "^example_spherical_cap_point_load_benchmark$" --output-on-failure`. - The extended bounded nonlinear checker passed with - `FEMLITE_SPHERICAL_CAP_NONLINEAR=1`, 54 accepted increments, final - `wn=15.89482`, final `Fn=1.058395`, and sampled `Fn=1.340817` at - `wn=13.642`, proving a reproducible post-peak load drop without claiming - full `uz=-6.2 m` PDF curve reproduction. - -### [x] DONE V5.11-7: Final documentation, benchmark matrix, and evidence - -- Implementation: - - [x] Update benchmark matrix with the bounded V5.11 spherical-cap acceptance: - finite-strain S4 production path, translational-rim Shell-4 target, - post-peak load-drop evidence, continuation diagnostics and deferred strict - PDF full-curve matching. - - [x] Update acceptance report with exact commands, dates, curve metrics, - Newton/cutback counts, path-control metrics and known limits. - - [x] Remove obsolete corotational/old shell tangent documentation references - after code removal. - - [x] Add a next-version backlog note for full `uz=-6.2 m` PDF matching, - pseudo-arclength/branch following and late post-peak GMRES optimization. -- Tests: - - [x] Run targeted shell/implicit/spherical-cap/source-size regressions. - - [x] Run the relevant V5 acceptance subset if benchmark status changes. -- Acceptance: - - [x] V5.11 can be marked release-ready when implementation, tests, docs, and - benchmark evidence all align with the bounded V5 release claim and all - full-curve limitations are explicitly deferred. - -## V5.12 V5 Development Plan Open Backlog - -Boundary for this module: - -- V5.12 is the next-version backlog and does not block the V5.11 release-ready - checkpoint. -- This section mirrors the still-open `PARTIAL` and `DEFERRED` items in - `docs/v5_development_plan.md`, especially the 0.5.2 `two_arches` reference - route and the engineering close-out priorities listed in section 20.3. -- Do not duplicate release hygiene items already closed in V5.10 unless the - development plan still describes a concrete remaining engineering action. -- A compact benchmark can be kept as regression coverage, but it cannot close a - task that explicitly calls for a production workflow, full continuation path - or high-fidelity reference case. - -### [x] DONE V5.12-1: Finish `examples/two_arches` single reference-point check +### [x] TODO 0.5.3-6: Add multiplier and AL augmentation diagnostics - Source: - - `docs/v5_development_plan.md` now marks `examples/two_arches` as - `PASS / 0.5.2`. - - Completed coverage now has two explicit layers: a geometry/contact smoke - and a single displacement reference-point check at `para = 0.02`. - - Scope correction on 2026-07-01: the COMSOL reference uses a parametric - sweep, but FemLite V5 does not introduce a general parametric-sweep feature. - V5.12-1 only needs one representative displacement reference point, not - the complete sweep, a static edge-load solve or a full static path - reproduction. + - `docs/v5.3_development_plan.md` section 4.4, CT-2. - Implementation: - - [x] Split the current two-arches status into completed geometry/contact - smoke coverage and a separate single reference-point check. - The README and checker output now describe the existing case as a smoke - check rather than a full reference-result pass. - - 2026-06-30 diagnostic note: a direct static displacement-control conversion - of the current micro-step deck was tried as a temporary probe, including a - reduced contact penalty and an additional upper-end vertical constraint - variant. Both runs reached the prescribed midpoint displacement but produced - nonphysical residual/reaction magnitudes, so that temporary route cannot be - used as single-point reference evidence. - - [x] Keep the default dynamic micro-step as geometry/contact binding - regression, and use a separate `run_two_arches_reference_point.py` driver - to generate the selected displacement reference-point evidence. - - [x] Use `disp_upper` as the upper-arch midpoint vertical displacement and - `max_disp = 60 mm`. The single reference point uses `para = 0.02`, so the - target displacement is `1.2 mm`. This is an input/checker reference value, - not a FemLite parameter-sweep feature. - - [x] Keep the PDF geometry and mesh values explicit in the generator/input: - `Ri_upper = 80 mm`, `Ri_lower = 100 mm`, shell width/thickness `d = 3 mm`, - upper arc `80 deg`, lower arc `100 deg`, upper 30 mapped shell elements - and lower 75 mapped shell elements. - - [x] Keep material values explicit: lower arch `E = 40 GPa`, `nu = 0.2`, - `rho = 1`; upper arch `E = 20 GPa`, `nu = 0.3`, `rho = 1`. - - [x] Apply the smoke-scope in-plane constraints, lower-end fixed constraints, - out-of-plane `y` constraints and prescribed upper-midpoint displacement. - - [x] Do not add a V5 parameter-sweep or static edge-load requirement. The - selected V5 reference point is the documented upper-midpoint displacement - `disp_upper = -1.2 mm`. - - [x] Use frictionless shell-shell contact with upper arch as source/slave and - lower arch as destination/master. - - [x] Output `two_arches_reference_point.csv` with `para`, `disp_upper`, - reference mode, active contact count, max gap/penetration, contact force, - residual and run status. + - [x] Add normal multiplier residual summary. + - [x] Add AL augmentation count or equivalent update count where available. + - [x] Preserve existing multiplier duplicate/invalid/max commit error audit + fields. + - [x] Include multiplier/AL fields in report summary output. - Tests: - - [x] Keep `examples/two_arches/check_two_arches_results.py` as a - geometry/contact smoke checker and make its pass message explicit. - - [x] Add a separate reference-point checker that rejects parameter-sweep, - static edge-load and non-displacement-control evidence for this V5 point. - - [x] Verify geometry coordinates, 30/75 mesh counts, - the 1.2 mm midpoint displacement, active contact and bounded dynamic - displacement for the smoke route. - - [x] Verify material values, - `disp_upper=max_disp*para` residual, contact active set, bounded gap, - nonnegative/bounded contact work and downward displacement sign. The - checker now accepts exactly one final reference point rather than a - parameter sweep. - - [x] Add a lightweight CTest entry for the optional reference-point deck: - `example_two_arches_reference_point_prepare` validates displacement - reference deck generation and `two_arches_reference_point.csv` schema. - - [x] Execute the optional single reference-point run to convergence and - record the `check_two_arches_reference_point.py` PASS evidence through - `example_two_arches_reference_point` and - `example_two_arches_reference_point_check`. - - 2026-06-30 probe: `para=0.02`, one outer solve, ILU0 preconditioner, - static predictor on, `initial_dt=0.10`, `max_dt=0.20` and a 90 s solve - timeout still produced no accepted nodal output. - - 2026-06-30 follow-up: `--trace-nonlinear` localized the first static - edge-load cost to nonlinear linear solves. The default CG path repeatedly - falls through to the 1284-DOF dense/regularized fallback, taking roughly - 9-10 s per correction. The CLI and optional driver now expose - `--linear-solver`; the single-point driver defaults to GMRES and records - failure diagnostics parsed from stdout when no `history.csv` or nodal - output exists. - - 2026-06-30 follow-up probes with one-step tiny edge load - (`initial-load=-1e-3`, `initial_dt=max_dt=1.0`) showed that GMRES avoids - the dense fallback but still ends in cutback failure before a complete - static solve (`accepted_time` about `0.044` to `0.140` depending on - tolerance). BiCGSTAB/ILU0 failed earlier with a large correction norm, and - dense solve reported a singular pivot. - - 2026-07-01 scope decision: V5 does not need the static edge-load solve - for this example. The accepted V5 reference is the single displacement - point already present in the PDF-derived input, with independent - reference-point CSV/checker evidence. + - [x] Extend `contact_multiplier_report` coverage for new fields. + - [x] Extend restart or contact report coverage to verify committed multiplier + diagnostics are stable after restart. - Acceptance: - - [x] `examples/two_arches` has a bounded geometry/contact smoke route that - passes without claiming the full COMSOL sweep. - - [x] `examples/two_arches` passes a single displacement reference-point - checker without relying on static edge-load convergence. - - [x] The checker compares the selected result fields against the documented - reference point from `models.sme.two_arches.pdf`. + - [x] Multiplier-related contact failures can be separated from geometry/gap + and friction/slip failures. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(contact_multiplier_report|restart)$" --output-on-failure` passed. -### [x] DONE V5.12-2: Close scoped mortar / AL contact gaps for V5 +### [x] TODO 0.5.3-7: Enhance normal-contact tangent audit - Source: - - V5.3 remains `PARTIAL` in `docs/v5_development_plan.md`; V5.12-2 closes - the bounded V5 hardening scope and explicitly defers the full production - AL/mortar tangent rewrite to a later version. + - `docs/v5.3_development_plan.md` section 4.5, CT-3. - Implementation: - - [x] Do not claim complete industrial-grade AL/mortar consistent tangent - behavior for nonlinear contact paths in V5. The production contact tangent - still uses the current compact `ktan` block; replacing it with the full - `fem_contact_mortar_tangent` audit matrix is a later high-risk contact - solver redesign item. - - [x] Expand restart coverage beyond current active/released/open multiplier - audits where the development plan still calls for more scenarios. - - [x] `test_restart` now preserves and audits contact friction history - stick/slip state counts in addition to slots, accumulated slip, - friction work and tangential force. - - [x] Add a larger OpenMP contact path benchmark: `perf_contact_pair` - accepts a third `path_steps` argument, and - `perf_contact_pair_omp_consistency` now compares a 64-facet, 4-step - force/tangent/cache path under 1/4 OpenMP threads. - - [x] Clarify node-based surface to general element master support: V5 now - explicitly defers node-to-element-master contact pair support, documents - the boundary and rejects `TYPE=NODE` slave with element master at model - build time. `tests/data/s4_node_surface_element_master.inp` and - `implicit_inp` cover the failure path. + - [x] Split tangent audit output so normal-only tangent error is explicit. + - [x] Keep rigid translation residual and row/column balance diagnostics. + - [x] Add a relative finite-difference error summary for normal contact. + - [x] Avoid replacing the production contact tangent with a broad new + consistent tangent implementation in this task. - Tests: - - [x] Add V5-scope contact hardening tests with force, tangent, restart and - OpenMP consistency checks. - - [x] OpenMP force/tangent/cache path consistency is covered by - `perf_contact_pair_omp_consistency`. - - [x] Ensure internal BiCGSTAB/GMRES paths expose true status for - nonsymmetric or difficult tangent systems instead of hiding failures: - `linear_solver_cg` now forces BiCGSTAB/GMRES nonconvergence through the - dispatcher and checks `LS_STATUS_FAILED`, method/preconditioner, final - residual and relative residual diagnostics. + - [x] Extend `contact_mortar_tangent` to verify normal-only tangent audit + fields. - Acceptance: - - Contact mainline is closer to a production constraint solve, with - documented convergence diagnostics, restart continuity and OpenMP path - consistency. Full industrial AL/mortar nonlinear long-path tangent - convergence is not claimed by V5 and remains deferred. + - [x] Tangent audit output can identify normal-contact tangent error + independently from friction tangent error. + - Evidence: `ctest --test-dir build-codex-gcc -R "^contact_mortar_tangent$" --output-on-failure` passed. -### [x] DONE V5.12-3: Close scoped Mohr-Coulomb structural workflow gaps for V5 +### [x] TODO 0.5.3-8: Enhance friction stick/slip tangent audit - Source: - - V5.4 and `examples/strengthReduction` are scoped as `FOS PASS` for V5: - the delivered benchmark is the Mohr-Coulomb strength-reduction FOS curve, - plastic-zone probes, displacement probes and nonlinear diagnostic schema. - - The 0.75 m `FOS = 1.525` displacement/eqps cloud is a large - critical-instability validation problem. Its cost is inherent to the - benchmark and it is not a V5 delivery target. -- Planned INP selector: - - [x] Add a production INP-level nonlinear continuation selector: - `*NONLINEAR CONTINUATION, METHOD=value`. - - [x] Accept numeric method ids `1` through `5` and stable symbolic names so old - benchmark decks can stay compact while user-facing decks remain readable. - - [x] If the keyword is omitted, use method `1` as the default production - algorithm. - - [x] Reject unknown method ids/names at input validation time; do not silently - fall back to a different nonlinear path. - - [x] Record the selected method in nonlinear diagnostics, path CSV files and - VTK/run summaries where applicable. - - Completion evidence: - - Added `NLC_*` continuation method enums and `nonlinear_continuation_method` - default control state. - - Added INP reader support for `*NONLINEAR CONTINUATION, METHOD=value`. - - Added `tests/data/c3d4_static_nonlinear_continuation.inp` and - `implicit_inp` coverage for default method 1, ids `1..5`, symbolic names, - invalid values and state preservation on parse failure. - - Added continuation method diagnostics to strengthReduction nonlinear - chain/cloud/progress CSV output and checker validation. - - Targeted CTest command passed: - `ctest --test-dir build-win-gcc-16 -C Release -R "implicit_inp|example_strength_reduction_benchmark" --output-on-failure`. + - `docs/v5.3_development_plan.md` section 4.5, CT-3. - Implementation: - - [x] Keep V5 delivery at the FOS-curve and diagnostic-schema level for - `examples/strengthReduction`; do not require the full critical-instability - displacement/eqps cloud as release evidence. - - [x] Audit and document the Mohr-Coulomb engineering tangent in structural - solves through convergence status, continuation diagnostics and substep + - [x] Add separate stick tangent audit metrics. + - [x] Add separate slip tangent audit metrics. + - [x] Preserve energy probe and non-symmetry diagnostics. + - [x] Report tangent error, rigid residual and energy residual as distinct + quantities. +- Tests: + - [x] Extend `contact_mortar_tangent` to cover both stick and slip audit + branches. +- Acceptance: + - [x] Friction tangent audit can say whether failure comes from stick branch, + slip branch, rigid residual or energy probe. + - Evidence: `ctest --test-dir build-codex-gcc -R "^contact_mortar_tangent$" --output-on-failure` passed. + +### [x] TODO 0.5.3-9: Strengthen OpenMP contact path consistency + +- Source: + - `docs/v5.3_development_plan.md` section 4.6, CT-4. +- Implementation: + - [x] Extend `perf_contact_pair` or its checker to compare force path, tangent + path, candidate cache path and multi-step active-set statistics. + - [x] Compare contact state counts and gap/slip diagnostics across thread counts. - - Defer structure-level automatic trial re-solve and nonlinear instability - criteria for full critical-instability cloud workflows to a later version. - - Implement method `1` / `TWO_STAGE_LOAD_STRENGTH` as the default route: - first converge the real gravity/load state at strength factor `F=1.0`, - then keep the external load fixed and continue the material strength - reduction factor from `1.0` to the target factor. - - [x] Add production nonlinear static control `static_ramp_load` so the - implicit static solver can either ramp external loads by pseudo-time or - hold the assembled external load factor fixed. - - [x] Route `strength_reduction_benchmark --nonlinear-chain` through the - method-1 two-stage solve when `nonlinear_continuation_method == 1`. - - [x] Route `--nl-write-cloud` through the same two-stage method-1 - workflow, with the progress CSV tracking the fixed-load strength-factor - stage. - - [x] Keep default `*NONLINEAR CONTINUATION` behavior as method `1` and - continue writing the selected method id to nonlinear chain/cloud outputs. - - [x] Do not treat reducing method-1 cost enough for the full 0.75 m - critical-instability cloud as a V5 requirement; keep the route as an - optional diagnostic and defer full longrun validation. - - [x] Implement method `2` / `ADAPTIVE_TARGET_NEWTON` as a production - nonlinear static step-size controller that targets a bounded Newton - iteration count, grows after cheap accepted steps and shrinks after - expensive accepted steps, cutbacks or failed convergence. - - [x] Add INP controls `TARGET_NEWTON`, `GROWTH`/`GROWTH_FACTOR` and - `SHRINK`/`SHRINK_FACTOR`, with validation before state mutation. - - [x] Add production diagnostics for target increment, accepted - increment, next target increment, accepted Newton count and adjustment - reason. - - [x] Write method-2 diagnostics to strength-reduction nonlinear - chain/cloud/progress CSV files and validate them in the example checker. - - [x] Add module tests for production adaptive stepping and INP parsing, - including invalid-control preservation. - - [x] Implement method `3` / `TRUST_REGION_DAMPED_NEWTON` as a safeguarded - Newton path with correction-size limits and residual-merit damping for - high-load nonlinear segments. - - [x] Add INP controls `TRUST_RADIUS`, `TRUST_MIN_RADIUS`, - `TRUST_MAX_RADIUS`, `TRUST_GROWTH`, `TRUST_SHRINK`, - `TRUST_ACCEPT_RATIO` and `TRUST_GOOD_RATIO`. - - [x] Clip Newton corrections by the active trust radius before the - residual-merit line search. - - [x] Reject residual-increasing damped corrections with a reproducible - solver error, allowing the existing cutback/rollback path to respond. - - [x] Update the trust radius from residual merit reduction, damping and - line-search rejection count. - - [x] Record trust radius, next radius, damping factor, merit ratio, - rejection count and trust adjustment in production diagnostics and - strength-reduction CSV/summary output. - - [x] Implement method `4` / `ARC_LENGTH_OR_DISPLACEMENT_CONTROL` for - limit-point paths where pure load or strength-factor continuation cannot - pass snapback or localization events. - - [x] Add production accepted-increment path storage in `fem_control`, - including control parameter, controlled DOF count, prescribed/actual - displacement norms, constraint residual, reaction path, generalized work, - Newton iteration and convergence status. - - [x] Record direct prescribed-displacement continuation in - `implicit_solve_nonlinear_static` for `METHOD=4`, using the same - `load_factor * amplitude` boundary value that the solver enforces. - - [x] Expose the path through `fem_get_continuation_path_count`, - `fem_get_continuation_path_row` and `continuation_path.csv`. - - [x] Add low-level solver and INP/API regression coverage for accepted - increments, reaction output and zero constraint residual. - - [x] Add production Riks/arc-length controls `ARC_LENGTH`/`ARC_RADIUS` and - `ARC_LOAD_SCALE`/`RIKS_LOAD_SCALE`, with validation before mutating the - previous valid control state. - - [x] Implement the load-proportional Riks augmented equation in - `implicit_solve_nonlinear_static`: extended unknowns are displacement and - global `load_factor`; the reference load vector is computed as - `dF_ext/dlambda`; each Newton iteration solves residual and load - directions with the same constrained tangent and enforces the spherical - arc constraint. - - [x] Remove the old simplified interpretation for load-controlled method 4 - cases: load-type problems no longer use ordinary Newton plus accepted-path - recording as Riks evidence. The direct path is retained only for explicit - nonzero prescribed-displacement control, and cases with neither a - proportional load nor nonzero prescribed displacement now fail instead of - using a simplified fallback. - - [x] Prove method 4 direct displacement-control path on a real - nonmonotonic structure case: the bounded Shell-4 spherical-cap nonlinear - checker uses `ARC_LENGTH_OR_DISPLACEMENT_CONTROL`, writes - `continuation_path.csv`, verifies zero displacement constraint residual, - samples generalized reaction, and rejects monotone/small-strain curves by - requiring a post-peak load drop. - - [x] Prove the load-type Riks branch of method 4 on a real structure - limit-point neighborhood: `FEMLITE_SPHERICAL_CAP_RIKS=1` converts the - Shell-4 spherical-cap target to proportional crown `CLOAD`, runs the - production Riks augmented equation, writes `spherical_cap_riks_load_path.csv` - and verifies an interior load-parameter peak followed by a load drop while - displacement continues to grow. - - [x] Improve load-type Riks branch following beyond the local limit-point - neighborhood. The Riks predictor now keeps a saved accepted augmented - direction and chooses the next predictor sign to continue that direction, - removing the local two-state oscillation on the Shell-4 spherical-cap - route and advancing down a post-limit branch segment. - - [x] Defer broader load-type Riks branch-following generalization to the - next-version backlog instead of blocking the current V5.12 checkpoint. - A pinched-hemisphere screening probe remained monotonic through the - accepted range, while the remaining block-on-arch route would couple the - continuation question with contact snap-through. Current evidence is - therefore scoped to the spherical-cap real shell limit point and - post-limit branch segment. - - [x] Implement method `5` / `MC_SUBSTEPPING_SEMISMOOTH` for local - Mohr-Coulomb material stability, including stress-point substepping, - active-set diagnostics and semismooth branch handling around corners. - - [x] Add INP controls `MC_MIN_SUBSTEPS`, `MC_MAX_SUBSTEPS`, - `MC_TARGET_STRAIN`, `MC_YIELD_TOL` and `MC_PLASTIC_LIMIT`, with - validation before mutating the previous valid control state. - - [x] Route production `MOHR_COULOMB` material updates through - `fem_material_mc_driver` when `METHOD=MC_SUBSTEPPING_SEMISMOOTH`. - - [x] Store material-point aggregate diagnostics in `statev(27:32)`: - accepted substeps, requested substeps, driver status, branch mask, - maximum yield residual and maximum plastic increment. - - [x] Keep the default and other continuation methods on the direct - single-step Mohr-Coulomb update, while writing consistent single-step - diagnostics. - - [x] Add structure-level aggregation of MC substep/branch diagnostics to - strengthReduction nonlinear chain/cloud output. - - [x] Do not require a 0.75 m critical-instability cloud longrun proof for - NC-5 in V5. NC-5 is accepted here as material-point and structure-level - diagnostic hardening; full cloud-effect proof is deferred. - - Keep the first production implementation mutually exclusive through the - `METHOD=` selector; if later evidence shows the strongest path is a - composition such as `1+2+5`, add explicit secondary flags instead of - overloading the primary method id. + - [x] Prefer 1/2/4 thread coverage if practical; otherwise keep 1/4 coverage + and add the new state/residual fields. + - [x] Keep timing data non-blocking; compare deterministic/non-timing fields. - Tests: - - [x] Add INP parser tests proving omitted keyword selects method `1`, all ids - `1..5` and symbolic names are accepted, and invalid values fail before - solving. - - [x] Add solver diagnostics tests proving the selected method is reported and - that method `1` does not regress the existing nonlinear static path. - - [x] Add checker coverage for displacement cloud scale in optional - nonlinear cloud summaries. - - Defer checker coverage for full-cloud equivalent plastic strain behavior - until the later critical-instability validation track. - - [x] Reject linear-static VTK displacement output as reference evidence. + - [x] Update `perf_contact_pair_omp_consistency` and + `tools/testing/check_perf_contact_pair_omp.py`. - Acceptance: - - `examples/strengthReduction` can choose any planned nonlinear continuation - method from the INP file, and the default deck uses method `1` without a - command-line override. - - Method `1` target-cloud probes report reproducible nonlinear/material - status instead of ambiguous partial results when optional diagnostics are - requested. - - Strength reduction remains a documented Mohr-Coulomb FOS benchmark in V5, - with optional nonlinear structural diagnostics; full critical-instability - displacement/plasticity evidence is not part of this version's delivery - claim. -- Partial completion evidence for method `1`: - - `cmake --build build-win-gcc-16 --config Release --target strength_reduction_benchmark test_implicit_inp` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -C Release -R "implicit_inp|example_strength_reduction_benchmark" --output-on-failure` - passed on 2026-06-27. - - Path smoke passed: - `build-win-gcc-16\strength_reduction_benchmark.exe examples\strengthReduction\strength_reduction_slope_static.inp build-win-gcc-16\strength_reduction_twostage_smoke --nonlinear-chain --nl-max-trials 1 --nl-increments 2 --nl-max-newton 3 --nl-linear-iter 100 --nl-tol 1.0e-3`. - - Cloud smoke passed: - `build-win-gcc-16\strength_reduction_benchmark.exe examples\strengthReduction\strength_reduction_slope_static.inp build-win-gcc-16\strength_reduction_twostage_cloud_smoke --nl-write-cloud --nl-cloud-factor 1.525 --nl-cloud-step 1525 --nl-increments 2 --nl-max-newton 3 --nl-linear-iter 100 --nl-tol 1.0e-3`. - - Cloud summary/checker now records and validates a `0.3 m` reference - displacement scale plus `max_displacement / 0.3 m` scale ratio, so - optional probes cannot be mistaken for accepted critical-instability cloud - matches without a quantitative displacement-scale field. - - 2026-07-01 verification: - `build-codex-gcc\strength_reduction_benchmark.exe examples\strengthReduction\strength_reduction_slope_static.inp build-codex-gcc\strength_reduction_v5123_cloud_scale_smoke --nl-write-cloud --nl-cloud-factor 1.525 --nl-cloud-step 1525 --nl-increments 2 --nl-max-newton 3 --nl-linear-iter 100 --nl-tol 1.0e-3` - generated `strength_reduction_cloud_summary.csv` with - `reference_displacement_scale=0.3`, `displacement_scale_ratio=0.0`, - `nodes=13776` and `elements=6645`; the optional cloud checker accepted - the diagnostic `FAILED` summary as a reproducible non-ambiguous trial. - - The strengthReduction checker now rejects stale `result_00000001.vtk` - files, so the old linear-static gravity precheck output cannot be used as - nonlinear cloud evidence. - - 2026-07-01 negative smoke: - `python examples\strengthReduction\check_strength_reduction_results.py build-codex-gcc\strength_reduction_linear_vtk_reject_smoke` - failed as expected with `linear-static result_00000001.vtk is not valid - nonlinear-cloud evidence`. - - Medium 0.75 m method-1 cloud probe with `--nl-increments 10 --nl-max-newton - 20 --nl-linear-iter 1000 --nl-tol 1.0e-3 --nl-preconditioner ilu0` exceeded - 120 s and was stopped; the full critical-instability cloud is deferred - outside V5 instead of being treated as a release blocker. -- Completion evidence for method `5` material-point and structure-level - diagnostics: - - `METHOD=MC_SUBSTEPPING_SEMISMOOTH` routes production `MOHR_COULOMB` - updates through `fem_material_mc_driver` and writes `statev(27:32)`. - - `strength_reduction_benchmark` now aggregates MC point count, updated - points, accepted/requested substeps, limited points, branch mask, maximum - yield residual and maximum plastic step into nonlinear chain/cloud/progress - rows and summary CSV output. - - `examples/strengthReduction/check_strength_reduction_results.py` rejects - missing or invalid MC row/summary diagnostics. - - `cmake --build build-win-gcc-16 --config Release --target strength_reduction_benchmark` - passed on 2026-06-27. - - Nonlinear chain/cloud smoke output under - `build-win-gcc-16\strength_reduction_mc_diag_smoke` passed - `examples\strengthReduction\check_strength_reduction_results.py`, including - optional MC chain/cloud/progress diagnostics. - - `ctest --test-dir build-win-gcc-16 -C Release -R "material_mohr_coulomb|implicit_inp|example_strength_reduction_benchmark" --output-on-failure` - passed on 2026-06-27. -- Completion evidence for method `2`: - - `cmake --build build-win-gcc-16 --config Release --target test_solver_implicit test_implicit_inp strength_reduction_benchmark` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -C Release -R "solver_implicit|implicit_inp|example_strength_reduction_benchmark" --output-on-failure` - passed on 2026-06-27. - - `solver_implicit` now verifies adaptive growth reaches the final static - time with fewer accepted increments than the fixed initial step would use. - - `implicit_inp` verifies `METHOD=ADAPTIVE_TARGET_NEWTON`, - `TARGET_NEWTON`, `GROWTH` and `SHRINK`, including failure without changing - previous valid settings. - - `examples/strengthReduction/check_strength_reduction_results.py` now - rejects malformed nonlinear chain/cloud diagnostics for target increment, - accepted increment, next target increment and adjustment reason. -- Completion evidence for method `3`: - - `cmake --build build-win-gcc-16 --config Release --target test_solver_implicit test_implicit_inp strength_reduction_benchmark` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -C Release -R "solver_implicit|implicit_inp|example_strength_reduction_benchmark" --output-on-failure` - passed on 2026-06-27. - - `solver_implicit` now verifies that `METHOD=TRUST_REGION_DAMPED_NEWTON` - limits the applied correction norm, converges through multiple damped - Newton iterations, updates trust diagnostics and preserves the expected - displacement solution. - - `implicit_inp` verifies all trust-region control parameters and confirms - invalid trust radius bounds fail without mutating previous valid settings. - - `examples/strengthReduction/check_strength_reduction_results.py` now - rejects missing or invalid trust-radius, damping, merit-ratio and - rejection-count diagnostics in nonlinear chain/cloud/progress output. -- Partial completion evidence for method `4`: - - `fem_control` now owns a dynamically sized accepted-increment continuation - path table; `fem_solver_implicit` records direct displacement-control rows - after nonlinear static increments converge, while the active load factor is - still the one used by the solved increment. - - `fem_control` also stores `nlc_arc_length_radius`, - `nlc_arc_load_scale`, `nlc_last_arc_constraint`, - `nlc_last_arc_lambda` and `nlc_last_arc_length`. - - `fem_inp_nlc` parses `ARC_LENGTH`/`ARC_RADIUS` and - `ARC_LOAD_SCALE`/`RIKS_LOAD_SCALE` for - `METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL`. - - `fem_solver_implicit` now routes load-type method 4 cases to a Riks - augmented equation with displacement plus `load_factor` unknowns and keeps - direct displacement-control path recording separate from Riks evidence. - Method 4 inputs with neither proportional load nor nonzero prescribed - displacement return a solver error instead of falling back to ordinary - Newton path recording. - - The bounded Shell-4 spherical-cap nonlinear checker now provides the first - real nonmonotonic structure evidence for the direct displacement-control - branch: `FEMLITE_SPHERICAL_CAP_NONLINEAR=1` runs the finite-strain S4 deck - to `uz=-3.24 m`, writes `continuation_path.csv` and - `spherical_cap_load_displacement.csv`, verifies the accepted displacement - path and requires a post-peak generalized-reaction load drop. This closes - the bounded direct-displacement evidence, while the load-type Riks evidence - is tracked separately below. - - The same checker now has an optional load-control Riks route via - `FEMLITE_SPHERICAL_CAP_RIKS=1`. On 2026-06-30 it passed with 80 accepted - increments, `peak_lambda=0.6909629`, `final_lambda=0.6017746` and final - displacement magnitude `1.3973472 m`, proving a real finite-strain S4 - limit-point and post-limit branch segment after adding predictor direction - memory. Broader branch-following generalization on a second independent - nonmonotonic structure is explicitly deferred to the next-version backlog. - - `fem_api` exposes row-by-row continuation path access and - `fem_output_csv` writes `continuation_path.csv` when path data exists. - - `tests/data/c3d4_static_arc_disp_continuation.inp` selects - `METHOD=ARC_LENGTH_OR_DISPLACEMENT_CONTROL`; `implicit_inp` verifies the - API path rows and `solver_implicit` verifies the in-memory direct - displacement path, the load-type Riks path and the no-control rejection. - - `cmake --build build-win-gcc-16 --config Release --target test_solver_implicit test_implicit_inp` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -C Release -R "solver_implicit|implicit_inp" --output-on-failure` - passed on 2026-06-27. -- Partial completion evidence for method `5`: - - `src/base/fem_control.f90` now stores MC substep controls and - `src/input/fem_inp_nlc.f90` parses/validates them from - `*NONLINEAR CONTINUATION`. - - `src/material/fem_material_j2.f90` now dispatches production - `MOHR_COULOMB` updates to `fem_material_mc_driver` only when - `METHOD=MC_SUBSTEPPING_SEMISMOOTH`. - - `src/material/fem_material_mohr_coulomb.f90` now writes consistent - single-step state diagnostics and reserves `statev(27:32)` for MC - substep aggregates. - - `cmake --build build-win-gcc-16 --config Release --target test_material_mohr_coulomb test_implicit_inp` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -C Release -R "material_mohr_coulomb|implicit_inp" --output-on-failure` - passed on 2026-06-27. + - [x] OpenMP contact checks verify state, force, active set, cache and + residual diagnostics, not only basic force/tangent totals. + - Evidence: `ctest --test-dir build-codex-gcc -R "^perf_contact_pair_omp_consistency$" --output-on-failure` passed. -### [x] DONE V5.12-4: Move bounded buckling and cyclic symmetry into the main solver path +### [x] TODO 0.5.3-10: Add nonlinear residual breakdown storage - Source: - - V5.5 and `examples/buckling_corrugated_shell` remain `PARTIAL` by design: - V5 now delivers a bounded production subset and defers the large shell / - harmonic-wave / high-fidelity expansion to the next version line. + - `docs/v5.3_development_plan.md` section 4.2, NL-2. - Implementation: - - [x] Add a main-solver Euler column buckling workflow through - `femlite --buckling` and the dedicated `*BUCKLING COLUMN` input block. - - [x] Move Euler column input, assembly, dense buckling solve and CSV output - into production `src/solver/fem_buckling_column.f90`. - - [x] Delete the old duplicate Euler helper-side assembly/solve algorithm - from `tools/benchmarks/euler_column_buckling_benchmark.f90`; keep only a - compatibility wrapper around the production module. - - [x] Add a main INP parser guard for generic `*BUCKLING`: the parser records - a buckling analysis type and no longer falls through to static or dynamic - analysis. - - [x] Add a small-scale dense generic `*BUCKLING` main-solver path for - already assembled linear elastic `K` plus the limited - `*BUCKLING GEOMETRIC LINE` truss-style `K_G` subset. - - [x] Add the first static-preload-to-buckling main-solver bridge: when a - `*STATIC` step precedes `*BUCKLING`, run a linear static preload, update - element stress/internal force state, then solve the current dense buckling - subset. - - [x] Add the first preload-derived geometric stiffness subset: - `*BUCKLING GEOMETRIC LINE, PRELOAD` projects host solid element stress onto - the line direction, multiplies by the supplied area and assembles the - truss-style `K_G`. - - [x] Add the first production element preload geometric stiffness subset: - when `*STATIC` precedes `*BUCKLING` and no explicit geometric line is - supplied, assemble C3D4/C3D8 solid initial-stress `K_G` from the preloaded - element stress state. - - [x] Defer full preload-to-buckling `*BUCKLING` for shell production models - and higher-order solid elements to post-V5. V5 delivery is bounded to - explicit geometric lines, preload-derived line `K_G`, and C3D4/C3D8 solid - initial-stress `K_G`. - - [x] Defer shell geometric stiffness and higher-order solid geometric - stiffness after static preload to post-V5. - - [x] Integrate generic buckling modal output with the normal output workflow. - - [x] Bring the first cyclic sector constraint subset into the main solve - path: `*CYCLIC SYMMETRY` accepts explicit master/slave node pairs and - expands WAVE=0 sector rotation into MPC equations for 3-DOF solid nodes and - 6-DOF shell nodes, including shell rotational DOF mapping. - - [x] Defer automatic cyclic boundary node pairing and nonzero harmonic-wave - main-solver semantics to post-V5. - - [x] Defer full shell FE preload-buckling high-fidelity corrugated-shell - coverage to post-V5. + - [x] Add storage for total residual, force residual, contact residual, + constraint residual, arc residual and material local failure count. + - [x] Populate the fields in nonlinear static paths where data already exists. + - [x] Populate the fields in nonlinear Newmark paths for the available subset. + - [x] Preserve existing scalar residual fields for backward compatibility. - Tests: - - [x] Add module coverage for Euler column parsing, validation, solve - diagnostics, output writing and mode boundary conditions. - - [x] Update `examples/euler_column_buckling` checker and double-click script - so the regression runs `femlite --buckling`, not the benchmark helper. - - [x] Run targeted CLI regression after adding the new analysis mode. - - [x] Add general input-level `*BUCKLING` parser and small dense CLI solve - tests. - - [x] Add static-preload-to-dense-buckling CLI smoke coverage. - - [x] Add static-preload-to-dense-buckling tests and cyclic sector shell/solid - mapping tests. - - [x] Add C3D4 solid initial-stress preload-to-buckling CLI smoke coverage. - - [x] Defer full shell and higher-order solid preload-to-buckling tests to - post-V5 with the corresponding algorithms. - - [x] Keep Euler column benchmark as regression coverage through CTest. - - [x] Keep compact corrugated benchmark as regression coverage while adding - main-solver cyclic/preload coverage. + - [x] Extend `solver_implicit` to check residual breakdown values or presence + in static and Newmark-Newton paths. - Acceptance: - - [x] Users can run the Euler column buckling workflow through - `femlite --buckling`, not only through benchmark helper tools. - - [x] Users can run a small dense generic `*BUCKLING` workflow through normal - INP input when `K_G` is supplied by `*BUCKLING GEOMETRIC LINE`. - - [x] Users can run a linear static preload immediately before the small dense - generic buckling subset. - - [x] Users can run a small C3D4/C3D8 solid preload-to-buckling workflow - without manually supplying `*BUCKLING GEOMETRIC LINE`. - - [x] Defer general shell preload-to-buckling workflow through normal INP to - post-V5; V5 explicitly supports the bounded solid/line subsets above. - - [x] WAVE=0 cyclic sector constraints work through the main solver path for - explicit solid and shell node pairs. -- Completion evidence: - - `build-win-gcc-16\femlite.exe examples\euler_column_buckling\euler_column_buckling.inp --buckling --output-dir build-win-gcc-16\app_buckling` - passed on 2026-06-27 with first mode `1.84239E+06`, Euler reference - `1.84233E+06`, residual `1.50015E-11` and relative error `3.27661E-05`. - - `ctest --test-dir build-win-gcc-16 -R "^(buckling_support|example_euler_column_buckling_benchmark|smoke)$" --output-on-failure` - passed on 2026-06-27. - - `ctest --test-dir build-win-gcc-16 -R "^(cli_implicit_linear|cli_static_linear|cli_static_nonlinear|cli_implicit_newmark|cli_implicit_newmark_nonlinear)$" --output-on-failure` - passed on 2026-06-27. - - 2026-07-01 small dense generic buckling evidence: - `ctest --test-dir build-codex-gcc -R "^(implicit_inp|cli_buckling_generic_dense|cli_buckling_static_preload_dense|buckling_support|example_euler_column_buckling_benchmark)$" --output-on-failure` - passed 5/5. `cli_buckling_generic_dense` now runs through a nested - `--output-dir` and verifies `buckling_summary.csv` plus - `buckling_modes.csv` are written by the normal output-directory workflow. - `femlite tests\data\c3d4_buckling_static_preload.inp --output-dir - build-codex-gcc\manual_buckling_static_preload` completed the preload - bridge with first load factor `3.33333E-01` and residual - `2.22045E-16`. - - 2026-07-01 corrugated benchmark regression evidence: - `ctest --test-dir build-codex-gcc -R "^example_buckling_corrugated_shell_benchmark$" --output-on-failure` - passed 1/1 and remains labeled `v5_acceptance`. - - 2026-07-01 cyclic main-solver evidence: - `ctest --test-dir build-codex-gcc -R "^(implicit_inp|cyclic_symmetry|cli_buckling_generic_dense|cli_buckling_static_preload_dense|buckling_support|example_euler_column_buckling_benchmark|example_buckling_corrugated_shell_benchmark)$" --output-on-failure` - passed 7/7. `implicit_inp` covers `*CYCLIC SYMMETRY` expansion into MPC - equations for a C3D4 3-DOF solid pair and an S4 6-DOF shell pair. - - 2026-07-01 solid initial-stress buckling evidence: - `ctest --test-dir build-codex-gcc -R "^(implicit_inp|cyclic_symmetry|cli_buckling_generic_dense|cli_buckling_static_preload_dense|cli_buckling_solid_preload_dense|buckling_support|example_euler_column_buckling_benchmark|example_buckling_corrugated_shell_benchmark)$" --output-on-failure` - passed 8/8. `femlite tests\data\c3d4_buckling_solid_preload.inp - --output-dir build-codex-gcc\manual_buckling_solid_preload` completed with - first load factor `1.66667E+00`, preload residual `0.00000E+00` and modal - residual `0.00000E+00`. + - [x] Nonlinear diagnostics can report at least total, contact and constraint + residual categories without breaking existing residual queries. + - Evidence: `ctest --test-dir build-codex-gcc -R "^solver_implicit$" --output-on-failure` passed. -### [x] DEFERRED V5.12-5: Promote roll forming from benchmark helpers to production workflow +### [x] TODO 0.5.3-11: Write residual breakdown to CSV/report outputs - Source: - - V5.6 and `examples/roll_forming` remain `PARTIAL`. -- V5 decision: - - Defer the production roll-forming workflow to post-V5. - - Keep roller kinematics and compact J2 springback benchmarks as regression - evidence only. - - Do not claim full 3D workpiece rolling, restart-driven multi-step forming, - unloading/springback production workflow, or longrun stability in V5. -- Rationale: - - This is an independent manufacturing process workflow with rigid roller - kinematics, contact/friction, plastic forming, restart staging and longrun - validation. It is too large to add safely during V5 close-out. - -### [x] DEFERRED V5.12-6: Integrate cohesive contact into the main contact workflow - -- Source: - - V5.7 and `examples/ball_adhesion_decohesion` remain `PARTIAL`. -- V5 decision: - - Defer production cohesive-contact integration to post-V5. - - Keep cohesive law/state/metrics tests and the compact ball-adhesion - benchmark as bounded regression evidence only. - - Do not claim ordinary-contact/cohesive switching, cohesive contact tangent, - full restart history integration, or full ball-membrane FE cohesive long - path in V5. -- Rationale: - - This changes the main contact workflow, tangent assembly and restart - persistence. It should be developed with a dedicated contact-integration - plan rather than added during V5 close-out. - -### [x] DEFERRED V5.12-7: Upgrade deferred and partial high-fidelity examples - -- Source: - - `docs/v5_development_plan.md` lists several example directories as - `DEFERRED` or `PARTIAL`. -- V5 decision: - - Defer high-fidelity upgrades for `shell_solid_connection`, - `buckling_corrugated_shell`, `roll_forming`, `ball_adhesion_decohesion` and - larger particle-container longruns to post-V5. - - Keep current compact benchmarks and smoke tests only as regression coverage. - - Do not list compact surrogate, fallback or smoke-only examples as V5 PASS. -- Rationale: - - These examples depend on the larger deferred algorithms above. Upgrading the - examples before the production algorithms would create misleading - acceptance evidence. - -### [x] DEFERRED V5.12-8: Complete longrun and performance close-out - -- Source: - - V5.9/V5.10 remain `PARTIAL` in the development plan because larger - longrun and full performance close-out remain recommended. -- V5 decision: - - Defer the larger longrun matrix, full performance matrix and multi-platform - longrun records to post-V5. - - Keep the completed source-size governance and targeted behavior regression - as V5 close-out evidence. - - Do not keep broad longrun/performance expansion on the V5 must-complete - list. + - `docs/v5.3_development_plan.md` sections 4.2 and 6. - Implementation: - - [x] Defer longrun tiers for contact, Mohr-Coulomb, buckling, roll forming, - cohesive contact and particle-container coupling to post-V5. - - [x] Defer memory, iteration, residual, timing and platform stability metric - collection for broad longruns to post-V5. - - [x] Update `docs/v5_benchmark_matrix.md` only when new - longrun/performance tests are formalized after V5. - - [x] Restore `source_size` governance after the Riks/NLC and buckling work: - split `*NONLINEAR CONTINUATION` parsing into production - `src/input/fem_inp_nlc.f90`, keep `fem_inp_helpers` as generic keyword/data - helpers, shorten the dense solver, CG solver, S4 stiffness and NLC parser - test routines below the hard routine threshold, and document remaining - structural exceptions with explicit split reasons in - `tests/source_size_exceptions.txt`. - - [x] Split implicit constraint/tangent application out of - `fem_solver_implicit`: added production - `src/solver/fem_implicit_constraints.f90` for Dirichlet, Robin, MPC, - follower-load tangent and contact tangent application, removed the old - private duplicate routines from the main implicit solver, and kept the - nonlinear/static/Newmark behavior covered by targeted regression. - - [x] Split database lifecycle cleanup out of `fem_database`: added - production `src/mesh/fem_database_lifecycle.f90`, kept - `database_finalize(ierr)` as the stable public wrapper, removed stale - contact/free helper wrappers, and removed the now-stale hard file exception - for `src/mesh/fem_database.f90` after the file dropped below 2000 lines. - `database_finalize_storage` is now split into private model-array, - material-array and step/load-array release helpers, so - `fem_database_lifecycle.f90` no longer appears in the source-size - routine review-warning list. - - [x] Split stable time-step support out of the public API facade: added - production `src/base/fem_api_stable_dt.f90` for material wave speed, - element characteristic length and current-position helper logic, kept - `fem_estimate_stable_dt` as the stable public API wrapper, and removed the - now-stale hard file exception for `src/base/fem_api.f90` after the file - dropped below 2000 lines. - - [x] Split the strengthReduction benchmark orchestration outside `src`: - added `tools/benchmarks/strength_reduction_benchmark_cli.f90` for CLI and - nonlinear-chain option parsing, added - `tools/benchmarks/strength_reduction_benchmark_report.f90` for CSV/summary - naming and report formatting, and split cloud/two-stage progress helpers - inside the benchmark driver so all benchmark routines are below the hard - 128-line threshold. - - [x] Split the hard routine-size exceptions in `fem_solver_implicit`: - `implicit_solve_nonlinear_static` is now a thin dispatcher over begin, - fixed/adaptive scheduling and arc driver helpers; Riks/arc-length - initialization, predictor and constraint-measure updates are separated from - `static_arc_increment`; nonlinear static Newton correction, line search and - trust-region update are separated from `nonlinear_static_increment`. All - routine entries were removed from `tests/source_size_exceptions.txt`. - - [x] Clear the remaining file-level `source_size` exception for - `fem_solver_implicit`: added production - `src/solver/fem_solver_implicit_support.f90` for shared convergence, - nonlinear linear-solver fallback, stiffness/external assembly, CSR/mass and - trust-region helpers; added production `src/solver/fem_solver_newmark.f90` - for linear and nonlinear Newmark integration; kept the public Newmark - entry points re-exported by `fem_solver_implicit`. The active entries in - `tests/source_size_exceptions.txt` are now empty. - - [x] Continue review-threshold cleanup for the current implicit solver split: - arc driver initialization, Riks iteration evaluation/correction and - Newmark nonlinear initialization/correction/success/failure handling were - moved into helpers. `implicit_solve_static_arc`, - `static_arc_increment` and `implicit_newmark_nonlinear_step` no longer - appear in the `source_size` review-warning list. - - [x] Continue file-level review-target cleanup for `fem_solver_implicit`: - added production `src/solver/fem_solver_static_nonlinear.f90` for - nonlinear static fixed/adaptive scheduling, static predictor history, - direct displacement-control path recording, load-type Riks/arc-length and - nonlinear static Newton increments. `fem_solver_implicit` now keeps linear - static plus dispatcher/public-entry ownership and no longer appears in the - source-size review-warning list. - - [x] Defer any further review-target cleanup on other large production modules - where it clarifies ownership and preserves full algorithms, especially - `fem_element_internal` and benchmark tool files, to the next normal - engineering cycle; do not keep it as a V5 release blocker. - - [x] `fem_api`: extracted shared Newmark run preparation for implicit and - nonlinear Newmark API runs; `fem_run_newmark_nonlinear` no longer appears - in the source-size routine warning list. - - [x] `fem_api`: split the public API facade into production support modules: - `fem_api_state` owns the initialized flag, `fem_api_coupling` owns - SPH/contact/surface/facet API routines, `fem_api_diagnostics` owns - convergence/continuation/linear-solver/shell-stability API routines, and - `fem_api_state_access` owns node/element state query API routines. The - original `fem_api` module keeps initialization, model I/O, solve/output - orchestration and re-exports the moved public entries; `fem_api.f90` no - longer appears in the source-size file-level review-warning list. - - [x] `fem_control`: split `control_set_defaults` into private grouped - reset helpers for time/nonlinear controls, solver controls, diagnostics - and feature flags. The public default-reset entry remains unchanged, and - `control_set_defaults` no longer appears in the source-size routine - review-warning list. - - [x] `fem_material_j2`: split J2 plastic state update into - `update_j2_plastic_state`, keeping the return-mapping algorithm intact; - changed `stress_dependent_modulus` to preserve the caller-provided Young's - modulus value on error returns. `material_update_j2` no longer appears in - the source-size routine review-warning list, and the Windows GCC - maybe-uninitialized warning for SDE Young's modulus is gone. - - [x] `fem_database`: moved database initialization storage reset into - `database_initialize_storage` in `fem_database_lifecycle`, keeping the - public `database_initialize(ierr)` wrapper stable; added production - `fem_database_lookup` for ID/name queries and surface face helpers, added - production `fem_database_validation` for full model validation, and kept - `database_validate_model(ierr)` as a stable wrapper. `fem_database.f90`, - `database_initialize`, `validate_materials` and `validate_contact_data` - no longer appear in the source-size review-warning list. - - [x] `fem_material_mohr_coulomb`: initialized MC parameter and Lame - parameter outputs on all error paths, clearing the Windows GCC - maybe-uninitialized warnings for tension, lambda and shear without - changing the return-mapping or tangent algorithms. - - [x] `fem_linear_solver_dense`: split dense CSR copy, partial-pivot - elimination/back-substitution, pivot selection and residual calculation - into private helpers while preserving the internal dense pivoting fallback - algorithm. `linear_dense_solve` no longer appears in the source-size - routine review-warning list. - - [x] `fem_linear_solver_iterative`: split CG preconditioner/initialization - setup, BiCGSTAB initialization and omega correction, and GMRES - initialization into private helpers while preserving the production - iteration formulas and internal preconditioner dispatch. `linear_cg_solve`, - `linear_bicgstab_solve` and `linear_gmres_solve` no longer appear in the - source-size routine review-warning list. - - [x] `fem_assembly_csr`: split CSR pattern row counting and row-column - population into private helpers while preserving element/MPC/contact - sparsity insertion and row sorting. `assembly_build_csr_pattern` no - longer appears in the source-size routine review-warning list. - - [x] `fem_inp_helpers`: moved Mohr-Coulomb material line parsing into - production `fem_inp_material_parser`, moved contact pair/property/friction - parsing into production `fem_inp_contact_parser`, and kept - `fem_inp_helpers` focused on generic token/keyword helpers and shared INP - utilities. `parse_mc_line`, `parse_contact_pair_header` and the - file-level `fem_inp_helpers.f90` warning no longer appear in the - source-size review-warning list. - - [x] `fem_inp_reader`: split count-model state reset and node/element - total validation out of the first-pass INP counting routine. The - first-pass keyword/data counting behavior remains unchanged, and - `inp_count_model` no longer appears in the source-size routine - review-warning list. - - [x] `fem_output_csv`: split contact CSV header, summary row and pair row - writing into private helpers while preserving the existing CSV schema and - contact diagnostics fields. `output_csv_write_contact` no longer appears - in the source-size routine review-warning list. - - [x] `fem_particle_config_check`: split particle check limit parsing into - `pcheck_parse_limits`, keeping line cleaning, CHECK data-line handling and - final validation unchanged. `pcheck_parse_line` no longer appears in the - source-size routine review-warning list. + - [x] Add residual breakdown columns to `continuation_path.csv` or the + appropriate nonlinear/contact summary output. + - [x] Ensure missing data is represented consistently for paths that do not + have a category. + - [x] Update output headers and schema comments in code/docs. + - [x] Keep old output columns stable where existing checkers depend on them. - Tests: - - [x] Defer documented extended commands for broad longrun/performance suites - until those suites are formalized after V5. - - [x] Re-run relevant Windows GCC, Windows Intel/MSVC and WSL GNU subsets when - longrun coverage changes after V5. - - [x] Run targeted source-size and behavior regression after the parser/solver - cleanup. - Completion evidence on 2026-06-27: - `ctest --test-dir build-win-gcc-16 -R "^(implicit_inp|linear_solver_cg|shell_internal|source_size)$" --output-on-failure` - and - `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|linear_solver_cg|shell_internal|buckling_support|example_euler_column_buckling_benchmark|cli_implicit_linear|cli_static_linear|cli_static_nonlinear|cli_implicit_newmark|cli_implicit_newmark_nonlinear)$" --output-on-failure` - both passed. - - [x] Run targeted regression after splitting implicit constraint helpers. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - and - `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - both passed. - - [x] Run targeted build and source-size cleanup after splitting database - lifecycle. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_implicit_inp test_solver_implicit -j 4` - passed; source-size was rerun and exposed the stale - `src/mesh/fem_database.f90` file exception, which was removed; rerun - `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed. - - [x] Run targeted build and source-size cleanup after splitting API stable - time-step support. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_implicit_inp test_solver_implicit -j 4` - passed; source-size was rerun and exposed the stale - `src/base/fem_api.f90` file exception, which was removed; rerun - `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed. - - [x] Run targeted build and source-size cleanup after splitting - strengthReduction benchmark CLI/report/cloud helpers. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target strength_reduction_benchmark -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(source_size|example_strength_reduction_benchmark)$" --output-on-failure` - passed after removing stale benchmark routine exceptions. - - [x] Run targeted build and source-size cleanup after splitting - `fem_solver_implicit` nonlinear static and Riks routine helpers. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed after removing stale `implicit_solve_nonlinear_static`, - `static_arc_increment` and `nonlinear_static_increment` routine exceptions. - - [x] Run targeted build and source-size cleanup after splitting implicit - support and Newmark into focused production modules. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed after removing the stale `src/solver/fem_solver_implicit.f90` file - exception. `tests/source_size_exceptions.txt` now contains no active - exceptions. - - [x] Run targeted build and source-size cleanup after reducing the current - implicit solver review-size routines. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed after `implicit_solve_static_arc`, `static_arc_increment` and - `implicit_newmark_nonlinear_step` disappeared from the source-size warning - list. - - [x] Run targeted build and source-size cleanup after moving nonlinear static - scheduling, Riks/arc-length and static Newton increments into - `fem_solver_static_nonlinear`. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed, and `fem_solver_implicit.f90` no longer appears in the - `source_size` warning list. - - [x] Run targeted build and API/source-size cleanup after extracting shared - Newmark run preparation inside `fem_api`. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(solver_implicit|implicit_inp|source_size|c_api)$" --output-on-failure` - passed, and `fem_run_newmark_nonlinear` no longer appears in the - `source_size` routine warning list. - - [x] Run targeted build and API facade/source-size cleanup after splitting - coupling, diagnostics and state-access API routines out of `fem_api`. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_c_api test_smoke test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(smoke|c_api|solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed, and `fem_api.f90` no longer appears in the `source_size` - file-level review-warning list. - - [x] Run targeted build and source-size cleanup after splitting database - lifecycle release categories. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_smoke test_restart test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(smoke|restart|implicit_inp|source_size)$" --output-on-failure` - passed, and `database_finalize_storage` no longer appears in the - `source_size` routine review-warning list. - - [x] Run targeted build and source-size cleanup after splitting - `control_set_defaults`. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_implicit_inp test_solver_implicit test_element_stiffness test_linear_solver_cg -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(implicit_inp|solver_implicit|element_stiffness|linear_solver_cg|source_size)$" --output-on-failure` - passed, and `control_set_defaults` no longer appears in the `source_size` - routine review-warning list. - - [x] Run targeted build and source-size cleanup after splitting J2 plastic - state update and clearing the SDE Young's modulus warning. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_material_j2 test_material_mohr_coulomb test_implicit_inp -j 4` - passed without the previous `young may be used uninitialized` warning; - `ctest --test-dir build-win-gcc-16 -R "^(material_j2|material_mohr_coulomb|implicit_inp|source_size)$" --output-on-failure` - passed, and `fem_material_j2.f90` no longer appears in the `source_size` - warning list. - - [x] Run targeted build and source-size cleanup after moving database - initialization into lifecycle storage helpers and splitting database - validation routines. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_database_topology test_smoke test_restart test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(database_topology|smoke|restart|implicit_inp|source_size)$" --output-on-failure` - passed, and `database_initialize` no longer appears in the `source_size` - warning list. After splitting validation helpers and clearing MC - maybe-uninitialized warnings, - `cmake --build build-win-gcc-16 --target test_material_mohr_coulomb test_database_topology test_implicit_inp -j 4` - passed without the previous MC warnings, and - `ctest --test-dir build-win-gcc-16 -R "^(material_mohr_coulomb|database_topology|implicit_inp|source_size)$" --output-on-failure` - passed. - - [x] Run targeted build and source-size cleanup after moving database lookup - and validation into dedicated production modules. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_database_topology test_smoke test_implicit_inp test_contact -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(database_topology|smoke|implicit_inp|contact|source_size)$" --output-on-failure` - passed. Direct `check_source_size.py` output no longer lists - `src/mesh/fem_database.f90` or its validation routines. - - [x] Run targeted build and source-size cleanup after splitting the dense - solver fallback. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_linear_solver_cg test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(linear_solver_cg|solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed, and direct `check_source_size.py` output no longer lists - `linear_dense_solve`. - - [x] Run targeted build and source-size cleanup after splitting the - iterative CG/BiCGSTAB/GMRES solver routines. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_linear_solver_cg test_solver_implicit -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(linear_solver_cg|solver_implicit|source_size)$" --output-on-failure` - passed. Direct `check_source_size.py` output no longer lists - `linear_cg_solve`, `linear_bicgstab_solve` or `linear_gmres_solve`. - - [x] Run targeted build and source-size cleanup after splitting CSR assembly - pattern helpers. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_assembly_csr test_solver_implicit test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(assembly_csr|solver_implicit|implicit_inp|source_size)$" --output-on-failure` - passed, and direct `check_source_size.py` output no longer lists - `assembly_build_csr_pattern`. - - [x] Run targeted build and source-size cleanup after moving material/contact - INP parsing out of `fem_inp_helpers`. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_implicit_inp test_contact test_material_mohr_coulomb -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(implicit_inp|contact|material_mohr_coulomb|source_size)$" --output-on-failure` - passed. Direct `check_source_size.py` output no longer lists - `src/input/fem_inp_helpers.f90`, `parse_mc_line` or - `parse_contact_pair_header`. - - [x] Run targeted build and source-size cleanup after splitting the INP - first-pass counter. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(implicit_inp|source_size)$" --output-on-failure` - passed, and direct `check_source_size.py` output no longer lists - `inp_count_model`. - - [x] Run targeted build and source-size cleanup after splitting contact CSV - output helpers. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_vtk_output test_contact test_implicit_inp -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(vtk_output|contact|implicit_inp|source_size)$" --output-on-failure` - passed, and direct `check_source_size.py` output no longer lists - `output_csv_write_contact`. - - [x] Run targeted build and source-size cleanup after splitting particle - check parsing. - Completion evidence on 2026-06-27: - `cmake --build build-win-gcc-16 --target test_particle_config_check test_particle_config_suite -j 4` - passed; `ctest --test-dir build-win-gcc-16 -R "^(particle_config_check|particle_config_suite|source_size)$" --output-on-failure` - passed, and direct `check_source_size.py` output no longer lists - `pcheck_parse_line`. - - [x] Run V5 close-out regression for the completed subset. - Completion evidence on 2026-07-01: - `ctest --test-dir build-codex-gcc -R "^(implicit_inp|cyclic_symmetry|cli_buckling_generic_dense|cli_buckling_static_preload_dense|cli_buckling_solid_preload_dense|buckling_support|example_euler_column_buckling_benchmark|example_buckling_corrugated_shell_benchmark)$" --output-on-failure` - passed 8/8, and - `ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure` - passed 39/39. + - [x] Update spherical-cap or continuation checker to verify residual + breakdown columns exist. + - [x] Update contact checker to verify contact residual columns exist. - Acceptance: - - V5 keeps the current targeted regression and source-size governance as - close-out evidence. - - Broad performance and longrun coverage is explicitly deferred and is not a - V5 must-complete acceptance item. + - [x] Checker failure occurs if required 0.5.3 residual columns are absent. + - Evidence: `ctest --test-dir build-codex-gcc -R "^solver_implicit$" --output-on-failure` passed; `python -m py_compile examples\spherical_cap_with_central_point_load\check_spherical_cap_results.py` passed. + +### [x] TODO 0.5.3-12: Add restart-after-increment audit for contact diagnostics + +- Source: + - `docs/v5.3_development_plan.md` sections 4.3 and 6. +- Implementation: + - [x] Add a restart audit scenario that writes restart after an accepted + contact increment and resumes from it. + - [x] Compare contact state counts, friction history, multiplier diagnostics, + gap/slip diagnostics and residual summaries before and after restart. + - [x] Keep existing restart format compatibility checks intact. +- Tests: + - [x] Extend `restart` module test for the new audit. + - [x] Add or update a compact INP/CLI restart scenario if module coverage is + insufficient. +- Acceptance: + - [x] Contact diagnostics are reproducible across restart, not only contact + forces and displacement state. + - Evidence: `ctest --test-dir build-codex-gcc -R "^restart$" --output-on-failure` passed. + +### [x] TODO 0.5.3-13: Update contact benchmark checkers for explainable diagnostics + +- Source: + - `docs/v5.3_development_plan.md` sections 4.4, 4.6 and 6. +- Implementation: + - [x] Update `examples/contact_two_blocks_compression` checker for gap, + penetration, state count and multiplier diagnostics. + - [x] Update `examples/contact_block_sliding` checker for slip/friction + diagnostics and state counts. + - [x] Update shell-shell and shell-solid checkers where shared contact summary + fields are available. + - [x] Keep numerical tolerances focused on existence, sign, nonnegativity, + boundedness and consistency; avoid overfitting complex nonlinear values. +- Tests: + - [x] Run the four contact benchmark CTest entries after checker updates. +- Acceptance: + - [x] Contact benchmark failures point to a missing/invalid diagnostic field + or a clear contact residual category. + - Evidence: `ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure` passed. + +### [x] TODO 0.5.3-14: Synchronize documentation and API descriptions + +- Source: + - `docs/v5.3_development_plan.md` section 4.8, DOC-1. +- Implementation: + - [x] Update mathematical/algorithm documentation for failure reasons, + residual breakdown and contact state/residual diagnostics. + - [x] Update interface documentation for any new API/query/output fields. + - [x] Update test plan with new 0.5.3 regression commands and acceptance + criteria. + - [x] Update user/developer manuals with the 0.5.3 diagnostic boundary. + - [x] Update contact example README files with new output fields. +- Tests: + - [x] Run `rg` checks to ensure old wording does not claim 0.5.3 delivers full + industrial AL/mortar consistent tangent. +- Acceptance: + - [x] Documentation states that 0.5.3 improves explainability and diagnostics + while deferring complete AL/mortar tangent rewrite. + - Evidence: documentation addenda added to design, algorithm, interface, + test plan, user/developer manuals and four contact example READMEs; wording + `rg` check found only explicit non-delivery boundary statements. + +### [x] TODO 0.5.3-15: Update V5 matrix, acceptance report and version close-out + +- Source: + - `docs/v5.3_development_plan.md` sections 6 and 8. +- Implementation: + - [x] Update `docs/v5_benchmark_matrix.md` with 0.5.3 tests and diagnostic + evidence. + - [x] Update `docs/v5_acceptance_report.md` with 0.5.3 scope, commands and + limitations. + - [x] Update `docs/v5_development_plan.md` status lines if 0.5.3 changes V5.3 + contact status or evidence. + - [x] Raise project version only when 0.5.3 implementation is ready to close. +- Tests: + - [x] Run the planned 0.5.3 targeted regression command. + - [x] Run `ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure`. + - [x] Run `git diff --check`. +- Acceptance: + - [x] 0.5.3 closes with green targeted tests, green V5 acceptance subset and + documented deferred boundaries. + - Evidence: `cmake --build build-codex-gcc --parallel` passed; + 0.5.3 targeted nonlinear/contact diagnostics passed 8/8; contact benchmark + diagnostic checker subset passed 4/4; V5 acceptance passed 39/39; + `git diff --check` passed with line-ending warnings only. + +## Suggested 0.5.3 Regression Commands + +```powershell +cmake --build build-codex-gcc --parallel +ctest --test-dir build-codex-gcc -R "^(solver_implicit|implicit_inp|linear_solver_cg|restart|contact_mortar_report|contact_mortar_tangent|contact_multiplier_report|perf_contact_pair_omp_consistency)$" --output-on-failure +ctest --test-dir build-codex-gcc -R "^(example_contact_two_blocks_compression_benchmark|example_contact_block_sliding_benchmark|example_shell_shell_contact_benchmark|example_shell_solid_contact_benchmark)$" --output-on-failure +ctest --test-dir build-codex-gcc -L v5_acceptance --output-on-failure +``` diff --git a/tools/testing/check_perf_contact_pair_omp.py b/tools/testing/check_perf_contact_pair_omp.py index f690ac1..872c6c1 100644 --- a/tools/testing/check_perf_contact_pair_omp.py +++ b/tools/testing/check_perf_contact_pair_omp.py @@ -10,22 +10,44 @@ import sys from pathlib import Path -METRICS = ( +INT_METRICS = ( "path_steps", "path_active", + "path_activated", + "path_released", "path_bvh_nodes", "path_cache_used", + "path_cache_over", "active_count", + "state_open", + "state_activated", + "state_maintained", + "state_released", + "activation_count", + "release_count", "search_facets", "search_masters", "search_broad", "search_active", "bvh_nodes", "cache_used", + "cache_overflow", +) + +FLOAT_METRICS = ( + "path_force_sum", + "path_tan_mat_sum", + "path_tan_f_sum", + "path_gap_sum", + "path_slip_sum", + "force_sum", + "tan_force_sum", + "gap_sum", + "slip_sum", ) -def run_case(source_root: Path, executable: Path, threads: int) -> dict[str, int]: +def run_case(source_root: Path, executable: Path, threads: int) -> dict[str, float]: env = os.environ.copy() env["OMP_NUM_THREADS"] = str(threads) proc = subprocess.run( @@ -46,14 +68,23 @@ def run_case(source_root: Path, executable: Path, threads: int) -> dict[str, int return parse_metrics(proc.stdout, threads) -def parse_metrics(output: str, threads: int) -> dict[str, int]: - values: dict[str, int] = {} +def parse_metrics(output: str, threads: int) -> dict[str, float]: + values: dict[str, float] = {} for line in output.splitlines(): - match = re.match(r"\s*([A-Za-z_]+):\s+([-+]?\d+)\s*$", line) - if match and match.group(1) in METRICS: - values[match.group(1)] = int(match.group(2)) + match = re.match( + r"\s*([A-Za-z_]+):\s+([-+]?\d+(?:\.\d*)?(?:[Ee][-+]?\d+)?)\s*$", + line, + ) + if not match: + continue + name = match.group(1) + if name in INT_METRICS: + values[name] = int(float(match.group(2))) + elif name in FLOAT_METRICS: + values[name] = float(match.group(2)) - missing = [metric for metric in METRICS if metric not in values] + expected = INT_METRICS + FLOAT_METRICS + missing = [metric for metric in expected if metric not in values] if missing: print(output, end="") raise SystemExit( @@ -74,9 +105,26 @@ def parse_metrics(output: str, threads: int) -> dict[str, int]: ) if values["cache_used"] <= 0: raise SystemExit(f"no BVH cache use for OMP_NUM_THREADS={threads}") + if values["cache_overflow"] != 0 or values["path_cache_over"] != 0: + raise SystemExit(f"unexpected cache overflow for OMP_NUM_THREADS={threads}") + if values["path_force_sum"] <= 0.0 or values["force_sum"] <= 0.0: + raise SystemExit(f"missing force checksum for OMP_NUM_THREADS={threads}") + if values["path_tan_mat_sum"] <= 0.0: + raise SystemExit(f"missing tangent checksum for OMP_NUM_THREADS={threads}") + if values["path_gap_sum"] <= 0.0 or values["gap_sum"] <= 0.0: + raise SystemExit(f"missing gap checksum for OMP_NUM_THREADS={threads}") + if values["state_maintained"] <= 0: + raise SystemExit(f"missing maintained state for OMP_NUM_THREADS={threads}") + if values["activation_count"] <= 0: + raise SystemExit(f"missing activation count for OMP_NUM_THREADS={threads}") return values +def close_enough(left: float, right: float) -> bool: + scale = max(1.0, abs(left), abs(right)) + return abs(left - right) <= 1.0e-9 * scale + + def main(argv: list[str]) -> int: if len(argv) != 3: print( @@ -87,26 +135,45 @@ def main(argv: list[str]) -> int: source_root = Path(argv[1]).resolve() executable = Path(argv[2]).resolve() - serial = run_case(source_root, executable, 1) - parallel = run_case(source_root, executable, 4) + cases = { + threads: run_case(source_root, executable, threads) + for threads in (1, 2, 4) + } + serial = cases[1] mismatches = [ - metric - for metric in METRICS - if serial[metric] != parallel[metric] + (threads, metric) + for threads, values in cases.items() + if threads != 1 + for metric in INT_METRICS + if serial[metric] != values[metric] ] - if mismatches: + float_mismatches = [ + (threads, metric) + for threads, values in cases.items() + if threads != 1 + for metric in FLOAT_METRICS + if not close_enough(serial[metric], values[metric]) + ] + if mismatches or float_mismatches: print("OpenMP contact performance statistics differ:") - for metric in mismatches: + for threads, metric in mismatches: print( f" {metric}: OMP=1 {serial[metric]}, " - f"OMP=4 {parallel[metric]}" + f"OMP={threads} {cases[threads][metric]}" + ) + for threads, metric in float_mismatches: + print( + f" {metric}: OMP=1 {serial[metric]:.12e}, " + f"OMP={threads} {cases[threads][metric]:.12e}" ) return 1 print("perf_contact_pair path OpenMP consistency: PASS") - for metric in METRICS: + for metric in INT_METRICS: print(f" {metric}: {serial[metric]}") + for metric in FLOAT_METRICS: + print(f" {metric}: {serial[metric]:.12e}") return 0