CelerisLab/tests/boundary_features.md
2026-05-12 19:08:49 +08:00

259 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Boundary features still needed for cylinder validation
##### [**Undermind**](https://undermind.ai)
---
当前代码已经具备做 2D 通道类圆柱验证的主体能力D2Q9 与 D3Q19SRT 与 TRT 与 MRT`double_buffer` 与 `esopull`,可开关 LES`uniform` 与 `parabolic` 入口,和若干开放出口模式。真正阻塞下一阶段 benchmark 的,不是碰撞模型数量不够,而是少数几个边界功能还没有补齐。它们分别是:南北 free-stream 边界time-dependent 入口幅值,开放来流 family 的更匹配外边界,以及 z 方向 periodic 边界。\[Qu13, Kan99b, Jia21\]
这份说明只回答一个问题:这些功能应如何实现,物理上在做什么,数值上应放在什么位置,以及如何兼容你当前的 SRT 与 TRT 与 MRT、`double_buffer` 与 `esopull`、LES 开关。
## 当前最值得补的功能顺序
| 顺序 | 功能 | 直接解锁的 benchmark | 为什么先做 |
|:---|:---|:---|:---|
| 1 | 南北 free-stream 边界 | \[Qu13\] 2D 开放来流 | 数学最简单,直接解锁 2D 恒定来流主 benchmark |
| 2 | time-dependent inlet amplitude | \[Joh04\] 全定义复现 | 实现代价低,可完善实现检查 |
| 3 | 开放来流 family 的远场与 outlet | \[Kan99b\] 2D 旋转开放来流 | 旋转 benchmark 的关键 |
| 4 | z periodic 边界 | \[Jia21\] 3D 固定圆柱 | 一旦实现即可解锁 3D 主 benchmark |
如果只能先做一个功能,应优先做南北 free-stream 边界。因为它不仅解锁 \[Qu13\],也会让开放来流中的静止圆柱和旋转圆柱不再被 fixed wall 人为污染。\[Qu13, Kan99b\]
## 南北 free-stream 边界
### 物理含义
\[Qu13\] 的上下边界不是物理壁面,而是远场近似。其假设是:圆柱诱导扰动在足够远的横向距离上已经衰减,因此边界上的流动回到自由来流状态。\[Qu13\]
对 2D 开放来流圆柱,这意味着在上边界和下边界施加目标宏观状态
``` math
\mathbf{u}_b = (U_{\infty}, 0)
```
``` math
\rho_b = \rho_0
```
最实用的实现不是发明一套新的边界家族,而是把你已有的 aligned velocity boundary 泛化到 y 方向边界。
### 推荐数值形式
最稳妥的第一版做法是 non-equilibrium extrapolation \[Guo02\]。它的写法是
``` math
f_i(x_b,t+\Delta t)=f_i^{eq}(\rho_b,\mathbf{u}_b)+\left[f_i(x_f,t+\Delta t)-f_i^{eq}(\rho_f,\mathbf{u}_f)\right]
```
这里
- $`x_b`$ 是边界节点
- $`x_f`$ 是相邻内侧流体 donor 节点
- 平衡态由目标自由流状态给出
- 非平衡部分由 donor 节点外推
这个形式有几个好处。
- 与你现有入口边界在代码结构上最接近
- 对 SRT 与 TRT 与 MRT 都能共用同一宏观目标状态
- 比单纯代数型 local closure 更稳,特别适合工程首版 \[Guo02, Lat08\]
### 在当前模式中的兼容方式
| 模块 | 兼容原则 |
|:---|:---|
| SRT | 直接用当前平衡态与 donor nonequilibrium |
| TRT | 同样重构分布,必要时保留现有 `trt_neq_damp` 作为 donor damping |
| MRT | 边界先在分布空间重构,再交给常规 MRT bulk 更新 |
| LES | 层流 benchmark 默认关。若开启边界仍使用相同宏观目标LES 只影响 bulk 局部黏性 |
### 在 `double_buffer` 与 `esopull` 中的放置位置
不论 streaming 路径如何,逻辑上都应保持一致:先得到边界节点的 post-stream 已知分布,再重构未知分布。区别只在索引来源。
| streaming | 实现原则 |
|:---|:---|
| `double_buffer` | 在 pull streaming 之后,对边界节点用 donor 节点和目标状态重构未知分布 |
| `esopull` | 在得到本地 post-stream 视图后,用同一重构公式回填未知方向 |
因此最好把边界实现写成“给定当前节点、方向集合、目标宏观状态、donor 节点”的统一接口,而不要把公式写死在某一种 streaming 路径中。
### 工程建议
第一版不必追求 characteristic far-field。只需先实现 north 与 south 的统一 velocity boundary支持 `uniform` 目标状态,并把 `boundary_type` 与 `velocity_profile` 解耦。这样同一套 y 边界内核就能同时服务:
- 开放来流的 free-stream 侧边界
- 通道中的移动壁之外的其他速度边界
## time-dependent inlet amplitude
### 物理含义
\[Joh04\] 需要的不是新的空间 profile而是已有 parabolic profile 的时间幅值调制。\[Joh04\] 因此它是一个很低成本但高收益的功能。
若把入口 profile 写成模板
``` math
\mathbf{u}_{in}(y,t)=A(t)\,\mathbf{u}_{shape}(y)
```
那么当前已支持的两种 profile 都能自然兼容。
- `uniform` 对应 $`\mathbf{u}_{shape}=(1,0)`$
- `parabolic` 对应 $`\mathbf{u}_{shape}(y)`$ 为固定抛物线形状
\[Joh04\] 的本质就是给 $`A(t)`$ 一个时间函数。\[Joh04\]
### 推荐实现
最简单的工程形式是给 inlet boundary 增加一个可选回调或 schedule。
| 字段 | 含义 |
|:---------------------|:---------------------------|
| `profile` | `uniform``parabolic` |
| `amplitude_mode` | `constant``scheduled` |
| `amplitude_value` | 常数幅值 |
| `amplitude_schedule` | 按时间步返回幅值的函数或表 |
这样不需要新边界核,只需要在每一步把目标边界速度更新后交给现有入口重构。
### 与模式的关系
它与 SRT 与 TRT 与 MRT、`double_buffer` 与 `esopull`、LES 都无直接耦合。因为变的是目标宏观状态,不是边界算法本身。
## 开放来流 family 的远场与 outlet
### 物理含义
\[Qu13\] 的出口使用 convective boundary。
``` math
\frac{\partial u_i}{\partial t}+C\frac{\partial u_i}{\partial x}=0
```
并取 $`C=1`$。\[Qu13\]
\[Kan99b\] 也采用了开放外场,并把外边界分成 inflow 半边和 outflow 半边。\[Kan99b\] 对旋转圆柱而言,只修正圆柱壁面速度是不够的;若外场 family 仍不对,升阻力和频率会被远场反射和壁效应同时污染。
### 对当前工程的建议
当前已有 `neq_extrap`、`zero_gradient` 和 `blended` 三种 outlet。对于通道类验证这已经足够先用。但若要更严格地逼近 \[Qu13\] 或 \[Kan99b\],下一步应考虑增加更接近 convective outlet 的 family。
最简单的第一版不是 characteristic outlet而是直接实现一个宏观量层面的 convective update。之后若高 Re 稳定性成为问题,再考虑 characteristic 或 regularized characteristic family \[Izq08, Wis17\]。
### 推荐路线
| 阶段 | 功能 |
|:-------|:---------------------------------------------|
| 第一版 | north 与 south free-stream velocity boundary |
| 第二版 | x 出口增加 convective family |
| 第三版 | 若高 Re 仍敏感,再加 characteristic outlet |
### 与模式的关系
出口 family 应尽量与 collision model 解耦。也就是说:
- SRT 与 TRT 与 MRT 共享同一个宏观 outlet 目标
- 仅 donor nonequilibrium 的处理上保留与现有 config 一致的 damping 参数
- LES 不应改变 outlet 类型,只改变内域的有效黏性与非平衡强度
## z 方向 periodic 边界
### 物理含义
\[Jia21\] 的 3D 圆柱 benchmark 之所以能被稳定比较,是因为 spanwise 方向采用 periodic从而模拟无限长圆柱的一段重复单元。\[Jia21\] periodic 不代表“边界上再做一次边界重构”,而代表拓扑上把两个 z 面缝合成一个连续方向。
其物理条件是
``` math
\phi(x,y,0,t)=\phi(x,y,L_z,t)
```
对分布函数而言,就是所有跨越 z 边界的 streaming 都直接 wrap 到另一侧。
### 实现原则
periodic 边界不属于 bounce-back也不属于 velocity outlet。它本质上是索引映射。
对任何具有 $`c_{i,z}=+1`$ 的离散方向,若 pull source 超出上边界,就从另一端取值;反之亦然。
### 在两种 streaming 路径中的处理
| streaming | 实现原则 |
|:---|:---|
| `double_buffer` | pull source 的 z 索引越界时做 modulo wrap |
| `esopull` | 针对所有 $`c_{i,z}\neq 0`$ 的方向,读取或写回时做相同 wrap |
这说明 periodic 的最稳实现位置不在边界核,而在 streaming 索引层。只要 streaming 层完成 wrapcollision、curved boundary、sensor、LES 都不需要知道 periodic 的存在。
### 与模式的关系
| 模块 | 关系 |
|:------------------|:-------------------------------------------|
| SRT 与 TRT 与 MRT | 完全无关collision 不变 |
| LES | 完全无关,局部 SGS 仍按正常 stencil 取邻域 |
| 曲壁边界 | 完全无关,圆柱表面仍按现有 kernel 处理 |
因此 z periodic 是一个高价值、低物理风险的功能。它的难点主要是索引实现,而不是物理公式。
## 对当前代码架构的建议
### 先按 boundary family 分层,不要按 case 临时加分支
建议把缺失功能拆成三层接口。
| 层 | 作用 |
|:---|:---|
| `macro target` 层 | 给出边界目标状态,如 $`\rho_b`$ 与 $`\mathbf{u}_b`$ |
| `reconstruction` 层 | 用 Zou-He 或 NEQ extrapolation 等方法重构未知分布 |
| `streaming topology` 层 | 处理 periodic wrap 或 pull source 定位 |
这样做的好处是:
- north 与 south free-stream 只改 `macro target``reconstruction`
- time-dependent inlet 只改 `macro target`
- z periodic 只改 `streaming topology`
### 模式扩展顺序
建议所有新增功能都按同一顺序落地。
1. 先在 `double_buffer` 上实现
2. 先支持 SRT 基线
3. 再验证 TRT 和 MRT
4. 最后再移植到 `esopull`
5. 层流 benchmark 上默认 LES off
这是最省调试成本的路线,因为 `double_buffer + SRT + LES off` 最容易隔离边界错误。
## 最后建议
如果你的目标是尽快把圆柱验证从当前阶段推进到真正可对标的开放来流和 3D family那么最值得优先补的不是新的碰撞模型也不是新的曲壁公式而是
- north 与 south free-stream boundary
- inlet amplitude schedule
- convective 或更匹配的远场 outlet family
- z periodic
其中第一项和第四项收益最高。第一项直接解锁 \[Qu13\],第四项直接解锁 \[Jia21\]。\[Qu13, Jia21\] 对旋转圆柱而言,只有在第一项和第三项具备之后,\[Kan99b\] 才能从 internal regression 升级成真正的 benchmark。\[Kan99b\]
---
## References
\[Qu13\] L. Qu, C. Norberg, L. Davidson, S.-H. Peng, and F. Wang, “Quantitative numerical analysis of flow past a circular cylinder at Reynolds number between 50 and 200,” May 01, 2013. doi: [10.1016/J.JFLUIDSTRUCTS.2013.02.007](https://doi.org/10.1016/J.JFLUIDSTRUCTS.2013.02.007).
\[Kan99b\] S. Kang, H. Choi, and S. Lee, “Laminar flow past a rotating circular cylinder,” Oct. 07, 1999. doi: [10.1063/1.870190](https://doi.org/10.1063/1.870190).
\[Jia21\] H. Jiang and L. Cheng, “Large-eddy simulation of flow past a circular cylinder for Reynolds numbers 400 to 3900,” Mar. 19, 2021. doi: [10.1063/5.0041168](https://doi.org/10.1063/5.0041168).
\[Joh04\] V. John, “Reference values for drag and lift of a twodimensional timedependent flow around a cylinder,” Mar. 10, 2004. doi: [10.1002/FLD.679](https://doi.org/10.1002/FLD.679).
\[Guo02\] Z. Guo, C. Zheng, and B. Shi, “Non-equilibrium extrapolation method for velocity and pressure boundary conditions in the lattice Boltzmann method,” Apr. 01, 2002. doi: [10.1088/1009-1963/11/4/310](https://doi.org/10.1088/1009-1963/11/4/310).
\[Lat08\] J. Latt, B. Chopard, O. Malaspinas, M. Deville, and A. Michler, “Straight velocity boundaries in the lattice Boltzmann method.” *Physical review. E, Statistical, nonlinear, and soft matter physics*, vol. 77 5 Pt 2, pp. 056703, May 2008, doi: [10.1103/physreve.77.056703](https://doi.org/10.1103/physreve.77.056703).
\[Izq08\] S. Izquierdo and N. Fueyo, “Characteristic nonreflecting boundary conditions for open boundaries in lattice Boltzmann methods.” *Physical review. E, Statistical, nonlinear, and soft matter physics*, vol. 78 4 Pt 2, pp. 046707, Oct. 2008, doi: [10.1103/PHYSREVE.78.046707](https://doi.org/10.1103/PHYSREVE.78.046707).
\[Wis17\] G. Wissocq, N. Gourdain, O. Malaspinas, and A. Eyssartier, “Regularized characteristic boundary conditions for the Lattice-Boltzmann methods at high Reynolds number flows,” *J. Comput. Phys.*, vol. 331, pp. 118, Jan. 2017, doi: [10.1016/j.jcp.2016.11.037](https://doi.org/10.1016/j.jcp.2016.11.037).