# 边界重构的输入与运行绑定

本轮改变 IO、配置类型与边界接线，属于“如何离散”的选择。外边界条件来自 `fields/boundaries.yaml`，Ghost 壁面条件来自 `IBM.wallClosure`。两者用 `boundaryReconstruction` 选择各自构造边界数据的算法。`convection.reconstruction` 继续选择面对流重构变量，`IBM.nearWallFlux` 继续控制近壁面对流。

## 迁移键与规范名

| 旧输入情形 | 当前输入 |
| --- | --- |
| 外边界独立 `solvers/ILW.yaml` 关闭或历史有效阶为零 | 注销该文件，将 `boundaryReconstruction: {method: Linear}` 写入已注册的 `solvers/numerics.yaml`，或者省略并使用缺省 Linear |
| 独立外边界 ILW 开启，精度为正 | 同一 numerics 文件中写 `boundaryReconstruction: {method: ILW, order: N}`，保留有效精度 |
| `IBM.eulerILW: {order: N}` | `IBM.boundaryReconstruction: {method: EulerILW, order: N}`，保留 `wallClosure: eulerSlip` |
| `stationaryNoSlipAdiabatic` 与 `LowOrder` | 增加 `IBM.boundaryReconstruction: {method: ConstrainedPolynomial}` |
| `eulerSlip` 与 `LowOrder` | 增加 `IBM.boundaryReconstruction: {method: SlipReflection}` |

方法名在读取边界对大小写、空白和常见连字符归一。外边界 `Linear` 接受 `linear`、`linearReconstruction` 和 `default`，`ILW` 接受 `ilw` 和 `Inverse Lax–Wendroff`。IBM 可用 `ilw` 简写 `EulerILW`，`ConstrainedPolynomial` 和 `SlipReflection` 使用各自规范名。没有 `reconstruction` 同义键。当前没有 `NavierStokesILW` 或 `NS ILW` 的执行实现，它们会报告不支持。`ConstrainedTaylor` 可用来描述外边界 ILW 内部的约束 Taylor 步骤，不是解析方法名。

外边界缺省来源记为 `default exterior boundary: Linear`。显式块记录已注册 numerics 文件的实际来源。`Linear`、`ConstrainedPolynomial` 和 `SlipReflection` 均拒绝 `order`。两种 ILW 都要求整数精度 3、5、7、9，内核导数阶依次为 2、4、6、8。显式高阶按原支撑和求值规则处理失败。

| 活动 Ghost 壁面条件 | 重构规范名 | 近壁面对流 |
| --- | --- | --- |
| `stationaryNoSlipAdiabatic` | `ConstrainedPolynomial` | 显式 `nearWallFlux: LowOrder`，取已编译对流通量的一阶实现 |
| `eulerSlip` | `SlipReflection` | 显式 `nearWallFlux: LowOrder`，Ghost 更新使用原一阶法向速度镜像 |
| `eulerSlip` | `EulerILW` | 由预计算的 Ghost Taylor 计划闭合完整高阶 stencil，与显式 `LowOrder` 冲突 |

关闭的 IBM 与 forcing 可以省略 Ghost 选择。活动 Ghost 必须写出重构方法，组合不匹配时报错。旧 solver ILW 注册、numerics 中的旧 ILW 键以及 `IBM.eulerILW` 都给出迁移位置。如果使用外层 `IBM:` 包装，则重构和近壁通量只能在包装内设置。CaseIO 仍只读 registry 引用的文件，未注册的历史文件不会覆盖选择。

## 外边界 ILW 与无滑移 Ghost 共存

以下是从 `test/IBM/cylinderFlowGhost` 现有注册出发的完整数值和模型片段。现役圆柱的外边界仍迁移成 Linear，下例显式改选外边界 ILW 3。注册的 thermoDynamics、fields、mesh、时间与方程文件继续由案例提供。IBM 需要原五分量守恒 backing、正分子黏性及现有固定单 patch 能力。

```yaml
# solvers/numerics.yaml
SonicFile: {object: solver, type: numerics}
time: {default: classicalRK4}
convection:
  default: WENO5
  formulation: conservativeFluxDifference
  reconstruction: characteristic
  flux: LaxFriedrichs
  interfaceFlux: shared
diffusion: {default: CENTRAL2}
boundaryReconstruction: {method: ILW, order: 3}
```

```yaml
# models/IBM.yaml
SonicFile: {object: models, type: IBM}
IBM:
  enabled: true
  type: ghost
  wallClosure: stationaryNoSlipAdiabatic
  boundaryReconstruction: {method: ConstrainedPolynomial}
  nearWallFlux: LowOrder
  normalSearch: {angle: 32, minLayers: 8, maxLayers: 32, targetCandidates: 512, keepSamples: 256}
  geometryFiles: [mesh/geometry/cylinder.STL]
```

母 registry 继续用 `numerics: {type: numerics, file: solvers/numerics.yaml}` 和 `IBM: {type: IBM, file: models/IBM.yaml}`，删除独立 `ILW` 母键。外边界条件继续在原字段文件中声明。两种边界读取本阶段各自合法的样本，具体网格须满足外边界 ILW 与 Ghost 的原模板要求。此组合已在源码中可表达，尚未运行。

## Reader、writer 和生产执行

| 环节 | 现役入口与所有权 |
| --- | --- |
| 注册与读取 | [SF_ruler.cpp](../src/infrastructure/io/case/SF_ruler.cpp) 保留文档身份检查，并在旧 solver ILW 条目给出迁移错误。[SF_binding.cpp](../src/app/application/model/SF_binding.cpp) 将正文和来源交给 [SF_whichConfig.cpp](../src/app/application/model/compatibility/SF_whichConfig.cpp) 的 numerics reader 和 [SF_ibmConfig.cpp](../src/app/application/model/compatibility/SF_ibmConfig.cpp) 的模型 reader。名称与整数精度由共同输入函数解析一次。 [SF_boundaryInput.h](../src/infrastructure/io/case/SF_boundaryInput.h) |
| 冻结与写出 | 外边界选择存于 `BoundaryConfig`，Ghost 选择存于 `IBMConfig`，近壁通量保持独立。 [SF_numericalCompiler.cpp](../src/solver/system/SF_numericalCompiler.cpp) 冻结实际使用的外边界条件、Ghost 重构和面对流策略。[SF_write.cpp](../src/infrastructure/io/case/SF_write.cpp) 通过同一输入规则写出规范名及高阶精度，并对缺省写出 Linear。CLI 初始化模板、GUI 的 numerics 草稿、IBM 草稿和默认设置保存均已同步。GUI 填写默认项时保留显式重构选择。 |
| 普通结构边界 | 单 patch 与多 patch 守恒入口用冻结的 `exteriorBoundary` 建立 [Applicator](../src/solver/boundary/SF_applicator.h)，按原顺序处理密度、速度、压力及热边界。标量／向量由 [SF_boundary.h](../src/solver/boundary/SF_boundary.h) 转为边界定律，再由 [Reconstruction](../src/solver/boundary/reconstruction/SF_reconstruction.cpp) 调用原 Algebraic 或 ILW 函数。压力和热边界直接消费同一 typed 选择，仍通过绑定的 EOS 写能量。 |
| 辅助标量 | [SF_scalarTransport.h](../src/methods/numerics/scalar/SF_scalarTransport.h) 接收同一个外边界类型。现役独立热输运沿用现有 WHICH 方法参数传递和覆盖规则，`metricOptions` 编译后只保存 typed 选择。既有多相标量转发迁移到同类型。未接入此选择的专用边界算法继续使用自己的契约。 |
| IBM 几何与写入 | [SF_runtimeConfig.cpp](../src/app/application/model/SF_runtimeConfig.cpp) 从活动选择计算网格所需 halo，IBM 分类深度继续按空间及 Ghost 自己的要求计算。IBM owner 持有 STL、分类、搜索和计划。[WeightBuilder](../src/models/ibm/method/ghost/SF_weightBuilder.h) 为所选方法准备支撑，[GhostCellIBM::apply](../src/models/ibm/method/ghost/SF_ghostCell.h) 将现有二次拟合、Euler ILW 或镜像算出的守恒量写入 \(Q_{ghost}\)。 |
| 实际消费者 | [SF_WENO.h](../src/solver/discretization/convection/SF_WENO.h) 消费已编译的一阶或完整模板策略。 [SF_systemPrinter.cpp](../src/solver/system/SF_systemPrinter.cpp) 分别打印外边界条件、重构请求及来源、IBM 壁面与重构、实际通量。Explain 说明实际守恒边界，压力基专用边界仍沿原接口。 |

退役了独立 solver ILW 的角色、默认路径、sections 槽、`SF_ilwConfig.cpp` 和 CMake 源项。移除了边界执行中的 `fromILWSetting` 及重复的 bool/order 组合、无消费者的外边界重构枚举值和手写包装。模型、管线、方程与 workspace 的 owner 未改变。外边界、halo、Ghost 写入、发布、RHS、RK 推进和唯一 clock 的执行顺序沿用原计划。Taylor、约束二次拟合、镜像、曲率压力项、近壁通量核及 MPI COPY/SUM 算术保持原实现。

## 迁移和构建证据

在 `test/IBM/` 迁移 27 个现役 solver registry，删除对应的 27 个旧 ILW 输入。23 个算例保留外边界 ILW 3，4 个保留 Linear。4 个现役活动 Ghost 均保持无滑移二次拟合和 LowOrder。当前样例中没有活动 Euler ILW 或滑移 LowOrder 要迁移，其入口由模型 reader、typed 校验与原执行链保留。已有 `mixtureCase` 工作树删除、其他用户改动和历史冻结证据保留。`tools/check_viscous_immersed_wall.py` 的负例生成已适配新语法，未运行。

相对本轮工作树起点，边界 IO 相关生产、构建及 GUI 接线共 54 个文件变化，增加 422 行、删除 372 行。该统计排除同期 GUI 几何编辑、输入迁移、文档和诊断脚本。

生产构建使用 `caffeinate -i env DEVELOPER_DIR=/Library/Developer/CommandLineTools cmake --build build --target sonicSolver -j 6`。编译过程中修复了 C++17 对字符串前缀 API 的兼容性及 IBM reader 局部变量重名，最终编译链接成功。中间构建仍出现原有枚举覆盖和 JSON pointer 弃用警告。 [首次日志](../test/boundary-io/evidence/sonicSolver.log) · [第二次日志](../test/boundary-io/evidence/sonicSolver-attempt-2.log) · [最终日志](../test/boundary-io/evidence/sonicSolver-final.log)

本轮只核对源码与生产构建。未运行算例、测试、回归、诊断、Explain 或 GUI，未进行数值验收。别名写回、外边界与无滑移组合、Euler ILW 及 MPI 入口的运行验收均待授权。曲壁误差、守恒预算和上一轮的 Euler 曲率符号问题继续按 [ghost-ilw.md](ghost-ilw.md) 留作独立验收。
