## Inlet module refactor plan The inlet module should be treated as a source-state generator for west ghost nodes, not as a grab-bag of formulas inside one boundary file. In the current solver, inlet cells are `SOLID | BC_INLET` ghost nodes whose state is later pulled by the first interior column. That semantic should stay explicit in the code structure. ## Current target structure - `boundary/inlet/common` - shared profile logic such as `inlet_target_u(y)` - shared rho-closure helpers for west velocity inlet - helper stating whether a scheme requires post-BC ghost collision - `boundary/inlet/zou_he_local` - local on-site Zou-He source-state reconstruction - D2Q9 and D3Q19 west inlet versions - `boundary/inlet/channel_stabilized` - donor-based stabilized inlet for high blockage or conservative production runs - D2Q9 and D3Q19 west inlet versions - `boundary/inlet/equilibrium` - full `feq` source-state construction from local rho closure and target velocity - D2Q9 and D3Q19 versions - `boundary/inlet/regularized` - local macro state plus damped donor NEQ on incoming directions - D2Q9 and D3Q19 versions - `boundary/outlet/pressure_neq` - pressure outlet and zero-gradient outlet implementations - `boundary/inlet_outlet` - compile-time dispatch only - no long method bodies - streaming-specific donor assembly and method selection ## Design rule for each inlet scheme Each scheme should answer the same question: - given a west ghost node after pull loading, what source state should be stored there for the next interior pull That makes the interface stable even when methods differ in how much donor information they use. ## Scheme meanings | Scheme | Main idea | Best fit | Main caution | |---|---|---|---| | `zou_he_local` | textbook local algebraic closure | MRT, research comparisons, clean local baseline | in ghost-source semantics it requires post-BC ghost collision and can be noisy for high-omega SRT | | `channel_stabilized` | donor-based stabilized inlet | high blockage, production robustness, conservative benchmark work | less pure as a local boundary method | | `equilibrium` | write full `feq` source state | robust SRT baseline, simple ghost-source compatibility | may suppress inlet NEQ too aggressively for some validation targets | | `regularized` | local macro state plus damped incoming donor NEQ | middle ground between `equilibrium` and donor-heavy methods | still an experimental family and may need tuning | ## Collision policy Post-BC ghost collision must be owned by the scheme, not hard-coded as a general inlet rule. Current policy: - `zou_he_local` requires post-BC ghost collision - `channel_stabilized` does not - `equilibrium` does not - `regularized` does not This should remain encoded through a helper such as `inlet_scheme_uses_post_collision_ghost()` rather than scattered `INLET_SCHEME == ...` checks. ## Why this split matters The earlier instability work showed that the main difficulty was not a single formula error. The real issue was mixing methods that assume different node semantics: - local fluid-boundary formulas such as Zou-He - ghost-source node architecture in the solver - different collision-model tolerances, especially SRT versus MRT Keeping each inlet method in its own file makes those assumptions visible and lowers the chance of mixing donor and ghost semantics by accident. ## Next cleanups worth doing later 1. Split outlet schemes into separate files as more outlet variants are added. 2. If inlet junction handling grows, move row-specific or corner-specific logic into dedicated helpers instead of embedding it inside the main schemes. 3. When validation settles, add a small test matrix document mapping recommended schemes to benchmark families and collision models. 4. If the solver later moves away from ghost-source inlet nodes, keep this folder layout but replace the per-scheme internals rather than rebuilding the whole dispatch layer.