This commit is contained in:
@@ -780,10 +780,32 @@ subroutine fem_solve_static_nonlinear(max_increment, max_iter, tol, &
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
|
||||
subroutine fem_get_static_convergence(nincrement, niter, residual, ierr)
|
||||
integer, intent(out) :: nincrement
|
||||
integer, intent(out) :: niter
|
||||
real(rk), intent(out) :: residual
|
||||
subroutine fem_get_convergence_status(increment, iteration, residual_norm, &
|
||||
correction_norm, converged, ierr)
|
||||
integer, intent(out) :: increment
|
||||
integer, intent(out) :: iteration
|
||||
real(rk), intent(out) :: residual_norm
|
||||
real(rk), intent(out) :: correction_norm
|
||||
logical, intent(out) :: converged
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
|
||||
subroutine fem_get_convergence_metrics(relative_residual_norm, &
|
||||
contact_gap_norm, combined_norm, ierr)
|
||||
real(rk), intent(out) :: relative_residual_norm
|
||||
real(rk), intent(out) :: contact_gap_norm
|
||||
real(rk), intent(out) :: combined_norm
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
|
||||
subroutine fem_get_convergence_diagnostics(cutback_count, last_dt, &
|
||||
last_accepted_time, status_code, &
|
||||
failure_code, ierr)
|
||||
integer, intent(out) :: cutback_count
|
||||
real(rk), intent(out) :: last_dt
|
||||
real(rk), intent(out) :: last_accepted_time
|
||||
integer, intent(out) :: status_code
|
||||
integer, intent(out) :: failure_code
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
```
|
||||
@@ -839,6 +861,7 @@ end subroutine
|
||||
- 每个非线性增量保存材料状态和单元状态备份,迭代试算前恢复,收敛后提交,失败后回滚。
|
||||
- Robin、MPC、刚性平面 penalty contact 和面-面 contact pair 的切线进入 Newton 有效刚度。
|
||||
- 静力和非线性 Newmark 均支持线搜索;可选步长缩减在失败时恢复增量起点状态后重试。
|
||||
- V4.5 起,`fem_control` 保存最近一次求解收敛快照、relative residual、contact gap residual、combined norm、cutback 诊断、最后有效时间和失败原因码,供 Fortran API、C ABI 和测试直接查询。
|
||||
|
||||
## 17. 稀疏矩阵模块
|
||||
|
||||
|
||||
@@ -758,6 +758,17 @@ K_eff Delta_u = R
|
||||
|
||||
当前实现中 `K_eff` 使用当前实体材料算法切线、壳 section 塑性算法切线、集中质量矩阵、Rayleigh 阻尼和外部约束/接触切线形成。收敛判据使用绝对力残差和相对力残差,Dirichlet 约束自由度的位移增量残差置零。非线性 Newmark 支持线搜索;可选步长缩减在单步失败时恢复运动学量和材料 trial 状态后重试。
|
||||
|
||||
V4.5 起,静力和隐式求解共享最近一次收敛诊断状态:
|
||||
|
||||
- `increment / iteration` 记录当前增量和 Newton 迭代。
|
||||
- `residual_norm / relative_residual_norm / correction_norm` 记录最近一次绝对力残差、相对力残差和位移修正范数。
|
||||
- `contact_gap_norm` 记录最近一次接触力评估中的最大 contact gap residual;面-面 contact pair 当前使用已有 gap residual/mortar 权重诊断源。
|
||||
- `combined_norm` 取相对力残差、位移修正范数和 contact gap residual 的最大值,作为统一多准则诊断量。
|
||||
- `cutback_count / last_dt / last_accepted_time` 记录累计步长缩减次数、最后尝试步长和最后有效求解时间。
|
||||
- `status_code` 区分 idle、iterating、converged、cutback 和 failed。
|
||||
- `failure_code` 区分无失败、Newton 不收敛、cutback 耗尽和运行未到终点。
|
||||
- 当前硬停止条件仍使用绝对/相对力残差;contact gap residual 先进入 diagnostics 和测试覆盖,后续可在接触算例标定后升级为可选硬准则。
|
||||
|
||||
当前限制:
|
||||
|
||||
- Rayleigh 阻尼已在线性 Newmark 和非线性 Newmark-Newton 骨架中接入。
|
||||
|
||||
@@ -543,6 +543,25 @@ subroutine fem_get_convergence_status(increment, iteration, residual_norm, &
|
||||
logical, intent(out) :: converged
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
|
||||
subroutine fem_get_convergence_metrics(relative_residual_norm, &
|
||||
contact_gap_norm, combined_norm, ierr)
|
||||
real(rk), intent(out) :: relative_residual_norm
|
||||
real(rk), intent(out) :: contact_gap_norm
|
||||
real(rk), intent(out) :: combined_norm
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
|
||||
subroutine fem_get_convergence_diagnostics(cutback_count, last_dt, &
|
||||
last_accepted_time, status_code, &
|
||||
failure_code, ierr)
|
||||
integer, intent(out) :: cutback_count
|
||||
real(rk), intent(out) :: last_dt
|
||||
real(rk), intent(out) :: last_accepted_time
|
||||
integer, intent(out) :: status_code
|
||||
integer, intent(out) :: failure_code
|
||||
integer, intent(out) :: ierr
|
||||
end subroutine
|
||||
```
|
||||
|
||||
说明:
|
||||
@@ -552,7 +571,15 @@ end subroutine
|
||||
- `residual_norm` 为最近一次力残差范数。
|
||||
- `correction_norm` 为最近一次位移修正范数;线性路径或尚未形成修正时为 0。
|
||||
- `converged` 表示最近一次记录的增量是否已满足收敛准则。
|
||||
- V4.5 起,非线性静力 Newton 迭代会实时更新该状态;后续 cutback 和多准则收敛诊断沿用同一查询口径。
|
||||
- `relative_residual_norm` 为力残差相对参考外力范数的比值。
|
||||
- `contact_gap_norm` 为最近一次接触力评估中的最大 contact gap residual。
|
||||
- `combined_norm` 为相对力残差、位移修正范数和 contact gap residual 的最大值,用于统一诊断多准则收敛状态。
|
||||
- `cutback_count` 为最近一次静力/非线性 Newmark 运行累计触发的步长缩减次数。
|
||||
- `last_dt` 为最近一次记录的静力增量长度或 Newmark 时间步长。
|
||||
- `last_accepted_time` 为最近一次已提交成功的求解时间;失败并回滚时保持为最后有效时间。
|
||||
- `status_code` 使用 `CONVERGENCE_STATUS_IDLE=0`、`ITERATING=1`、`CONVERGED=2`、`CUTBACK=3`、`FAILED=-1`。
|
||||
- `failure_code` 使用 `CONV_FAIL_NONE=0`、`CONV_FAIL_NONCONVERGENCE=1`、`CONV_FAIL_CUTBACK_LIMIT=2`、`CONV_FAIL_STOPPED=3`。
|
||||
- V4.5 起,非线性静力 Newton 迭代、静力 cutback 失败路径、非线性 Newmark cutback 运行和接触力评估会更新该状态;contact gap/mortar residual 当前作为 diagnostics 进入多准则统计,硬收敛判据仍以力残差为主。
|
||||
|
||||
### 12.6 接触状态
|
||||
|
||||
@@ -914,4 +941,6 @@ fem_finalize
|
||||
- C ABI 追加 `femlite_get_contact_perf_stats`,返回 contact search/force/tangent CPU 时间统计。
|
||||
- C ABI 追加 `femlite_get_contact_cache_stats`,返回 BVH 候选缓存使用和溢出统计。
|
||||
- C ABI 暴露 `femlite_get_convergence_status`,其中 `converged` 使用 `int` 返回 0/1。
|
||||
- C ABI 暴露 `femlite_get_convergence_metrics`,返回相对力残差、contact gap residual 和 combined norm。
|
||||
- C ABI 暴露 `femlite_get_convergence_diagnostics`,返回 cutback 次数、最后步长、最后有效时间、收敛状态码和失败原因码。
|
||||
- 上述函数只追加新符号,不改变 `femlite_get_contact_summary` 的签名和含义。
|
||||
|
||||
@@ -251,7 +251,7 @@ SPH总力映射测试 relative tolerance 1.0e-10 to 1.0e-8
|
||||
- 线性静力实体 patch test。
|
||||
- 线性静力壳 patch test。
|
||||
- 非线性静力 Newton 收敛。
|
||||
- 非线性静力收敛状态查询,检查最新增量、迭代号、残差范数、修正范数和收敛标志。
|
||||
- 非线性静力收敛状态查询,检查最新增量、迭代号、残差范数、修正范数、cutback 次数、最后步长、最后有效时间、状态码、失败原因码和收敛标志。
|
||||
- 非线性静力步长缩减。
|
||||
- 非线性静力线搜索和失败回滚测试。
|
||||
- 隐式 Newmark 单步预测校正。
|
||||
@@ -298,7 +298,7 @@ SPH总力映射测试 relative tolerance 1.0e-10 to 1.0e-8
|
||||
- `fem_get_contact_search_stats` 和 C ABI `femlite_get_contact_search_stats` 返回 contact pair 搜索 facet/master/candidate/active/BVH 节点统计。
|
||||
- `fem_get_contact_perf_stats` 和 C ABI `femlite_get_contact_perf_stats` 返回 contact search/force/tangent CPU 时间统计。
|
||||
- `fem_get_contact_cache_stats` 和 C ABI `femlite_get_contact_cache_stats` 返回 BVH 候选缓存使用和溢出统计。
|
||||
- `fem_get_convergence_status` 和 C ABI `femlite_get_convergence_status` 返回最近一次求解的增量、迭代、残差、修正范数和收敛标志;空模型零状态和非线性静力收敛状态均需覆盖。
|
||||
- `fem_get_convergence_status` / `fem_get_convergence_metrics` / `fem_get_convergence_diagnostics` 和 C ABI 对应包装返回最近一次求解的增量、迭代、残差、相对残差、修正范数、contact gap residual、combined norm、cutback 次数、最后步长、最后有效时间、状态码、失败原因码和收敛标志;空模型零状态、非线性静力收敛状态、contact gap 非零状态和 cutback 失败状态均需覆盖。
|
||||
- 删除单元状态可输出。
|
||||
|
||||
示例结果留存策略:
|
||||
|
||||
@@ -16,6 +16,7 @@ FemLite 0.4.3 是船舶接触爆炸结构响应 FEM 软件的第四版接触增
|
||||
- Abaqus inp 输入子集。
|
||||
- element/node/analytical surface 子集、contact property 子集、刚性平面接触和面-面 contact pair 阶段能力。
|
||||
- contact pair active set、gap residual 和 augmented penalty 诊断输出。
|
||||
- 静力/隐式求解的收敛状态和 cutback 诊断查询接口。
|
||||
- CSV、VTK、restart 和 contact CSV 输出。
|
||||
- Fortran95 原生接口、C ABI 子集和 Python 调试脚本。
|
||||
|
||||
@@ -238,6 +239,8 @@ kind,pair_id,active_count,max_penetration,force_norm,work_estimate,cumulative_wo
|
||||
|
||||
`search_*` 字段在 `SUMMARY` 行给出最近一次 contact pair 力评估的全局搜索统计、BVH 候选缓存使用情况和 `cpu_time` 口径秒数;逐 `PAIR` 行给出对应接触对的搜索、缓存和计时统计。`cpu_time` 是轻量趋势诊断,小算例中可能显示为 0。
|
||||
|
||||
Fortran95 API 可通过 `fem_get_convergence_status` 查询最近一次求解的增量、迭代、残差、位移修正范数和收敛标志,通过 `fem_get_convergence_metrics` 查询相对残差、contact gap residual 和 combined norm,通过 `fem_get_convergence_diagnostics` 查询 cutback 次数、最后步长、最后有效时间、状态码和失败原因码。C ABI 提供同名 `femlite_get_*` 包装,`converged` 使用 0/1 整数返回。
|
||||
|
||||
建议把大型结果输出到 `examples/.../results/...` 或独立 `output/` 目录。仓库 `.gitignore` 默认忽略大规模结果文件。
|
||||
|
||||
## 10. 示例算例
|
||||
|
||||
@@ -76,7 +76,7 @@ src/interface C ABI 和 Fortran-C bridge
|
||||
|---|---|
|
||||
| `fem_precision` | 全局精度、维度、版本常量 |
|
||||
| `fem_error` | 错误码和错误消息 |
|
||||
| `fem_control` | 时间步、求解控制、输出控制 |
|
||||
| `fem_control` | 时间步、求解控制、输出控制和 V4.5 收敛/接触 gap 诊断快照 |
|
||||
| `fem_api` | Fortran95 公共 API |
|
||||
| `fem_inp_reader` | 两遍 INP 读取主流程 |
|
||||
| `fem_inp_defs` | INP 模式常量 |
|
||||
|
||||
@@ -676,7 +676,7 @@ FemLite 0.4.x 定位为:
|
||||
|
||||
后续:
|
||||
|
||||
- 将 gap/mortar 残差接入非线性求解统计和收敛准则。
|
||||
- gap/mortar 残差已在 V4.5 接入非线性求解统计;后续继续标定接触穿透硬收敛准则。
|
||||
- 增强 contact tangent 对 active set 状态和增广路径的诊断输出。
|
||||
- 将 pair 级 augmented penalty 乘子推进到 mortar 积分点级历史,并在后续 V4.x 中与摩擦历史统一调试输出。
|
||||
|
||||
@@ -775,24 +775,38 @@ FemLite 0.4.x 定位为:
|
||||
|
||||
## 26. 0.4.5 开发记录
|
||||
|
||||
### V4.5 隐式非线性收敛诊断起步
|
||||
### V4.5 隐式非线性收敛诊断完善
|
||||
|
||||
完成状态:V4.5 起步,新增求解收敛状态查询底座;完整自适应步长、多准则收敛和失败诊断仍继续推进。
|
||||
完成状态:V4.5 收敛诊断和 cutback 失败诊断已形成阶段完善基线;contact gap/mortar residual 已纳入多准则统计,硬接触穿透停止准则保留为后续标定项。
|
||||
|
||||
已完成:
|
||||
|
||||
- `fem_control` 新增最近一次收敛状态快照,记录增量号、Newton 迭代号、力残差范数、位移修正范数和收敛标志。
|
||||
- `fem_control` 新增最近一次收敛状态快照,记录增量号、Newton 迭代号、力残差范数、相对力残差、位移修正范数、contact gap residual、combined norm 和收敛标志。
|
||||
- `fem_control` 新增收敛状态码、失败原因码、累计 cutback 次数、最后尝试步长和最后有效时间诊断。
|
||||
- 非线性静力 Newton 迭代在每次残差评估后更新收敛状态,修正方程求解后同步记录位移修正范数。
|
||||
- 非线性 Newmark 单步在每次残差评估和位移修正后更新同一收敛状态快照。
|
||||
- contact force 评估将 contact pair gap residual 同步到收敛 metrics。
|
||||
- 新增 Fortran API `fem_get_convergence_status`,补齐接口文档中第三版已承诺的静力/隐式收敛状态查询。
|
||||
- 新增 Fortran API `fem_get_convergence_metrics`,查询相对残差、contact gap residual 和 combined norm。
|
||||
- 新增 Fortran API `fem_get_convergence_diagnostics`,查询 cutback 次数、最后步长、最后有效时间、状态码和失败原因码。
|
||||
- C ABI 新增 `femlite_get_convergence_status`,以 `int` 形式返回 `converged` 的 0/1 状态。
|
||||
- C ABI 新增 `femlite_get_convergence_metrics`。
|
||||
- C ABI 新增 `femlite_get_convergence_diagnostics`。
|
||||
- 静力 cutback 成功/失败路径和非线性 Newmark cutback 运行路径更新累计 cutback 诊断。
|
||||
|
||||
已补充测试:
|
||||
|
||||
- `implicit_inp` 回归在非线性静力弹性算例后查询收敛状态,检查最后增量已收敛、残差在容限内并且迭代号有效。
|
||||
- `implicit_inp` 回归检查非线性静力成功路径 cutback 次数为 0、最后步长为 0.25、状态码为 converged。
|
||||
- `implicit_inp` 回归检查非线性静力成功路径相对残差在容限内、contact gap residual 为 0,并且 combined norm 覆盖分项 metrics。
|
||||
- `contact` 回归检查 contact pair active-set 小算例将非零 gap residual 写入 convergence metrics。
|
||||
- `solver_implicit` 回归检查非线性 Newmark 线弹性算例写出非零位移修正范数。
|
||||
- `solver_implicit` 回归检查非线性静力 cutback 失败路径累计 2 次 cutback、最后尝试步长为 0.25、最后有效时间保持为 0、状态码为 failed、失败原因为 cutback limit,且试算状态回滚。
|
||||
- `c_api` 回归检查初始化和建模后、尚未求解时的收敛状态为零值且未收敛。
|
||||
- `c_api` 回归检查初始化和建模后的收敛 diagnostics 为 idle 零值。
|
||||
- `c_api` 回归检查初始化和建模后的 convergence metrics 为零值。
|
||||
|
||||
后续:
|
||||
|
||||
- 将非线性 Newmark Newton 的修正范数和失败状态接入同一查询口径。
|
||||
- 在 cutback 失败路径中补充失败原因、cutback 次数和最后有效时间步诊断。
|
||||
- 将 contact gap/mortar residual 纳入 V4.5 多准则收敛统计。
|
||||
- 标定 contact gap residual 作为可选硬收敛准则时的量纲、容限和默认开关。
|
||||
- 补充更长时间的非线性静力/非线性 Newmark 接触长跑基准。
|
||||
|
||||
Reference in New Issue
Block a user