(bc_moment_based)= # Moment-Based Boundary Conditions In Nassu's RR-BGK solver a boundary node stores hydrodynamic moments, not individual populations (see {ref}`Recursive Regularized-BGK `). A boundary condition is therefore **defined by the moments imposed at the boundary node**: density $\rho$, velocity $u_\alpha$, and rate-of-strain $S_{\alpha\beta}$ (equivalently the non-equilibrium stress $\Pi^{\mathrm{neq}}_{\alpha\beta}$). The populations are not bounced, reflected, or copied direction by direction; they are reconstructed from the imposed moments by the third-order Hermite expansion at the start of the next collision step. This is the regularized, moment-target formulation of {footcite:t}`latt2008straight` and {footcite:t}`Malaspinas2015-1048`, organised on the moment hierarchy following the moment-based boundary conditions of Bennett, Dellar, and Reis {footcite:p}`bennett2010phd,bennett2012lattice,mohammed2017lid,krastins2020moment`. ```{admonition} Principle --- class: important --- A boundary condition imposes macroscopics, not populations. It writes the boundary node's $\{\rho,\ u_\alpha,\ S_{\alpha\beta}\}$; the next bulk collision rebuilds $f_i$ from them. There is no population-level reflection step. ``` ## The moment-group rule The discrete velocity set carries more populations than there are physically meaningful boundary constraints, so the unknown inward populations must be closed by a finite set of macroscopic conditions. The moment-based rule {footcite:p}`bennett2012lattice,mohammed2017lid` is to close them **one macroscopic per moment group**, in hierarchy order: 1. the conserved moments first - density $\rho$ (zeroth) and momentum $\rho u_\alpha$ (first); 1. then the second moment - the stress $\Pi^{\mathrm{neq}}_{\alpha\beta}$ (equivalently $S_{\alpha\beta}$). In practice each boundary family **imposes one or two moments directly and derives the remaining one** from a closure. A no-slip wall imposes velocity, fixes density, and *derives* the stress from a wall-normal finite difference. A velocity inlet imposes density and velocity and *sets* the stress to its equilibrium value. An outlet fixes density and *takes* velocity and stress from the interior. Higher moments beyond the second carry no independent boundary physics; the recursive expansion fills them from the imposed moments (Eq. {math:numref}`lb_a-neq3`), which is exactly the regularization that discards ghost content. ## General reconstruction Given the boundary moments $\{\rho,\ u_\alpha,\ S_{\alpha\beta}\}$, the populations follow from the same third-order Hermite expansion used by the collision operator. The non-equilibrium stress is recovered from the rate-of-strain by inverting the macroscopic relation, $$ \Pi^{\mathrm{neq}}_{\alpha\beta} = -\frac{2\,\rho\,c_{s}^{2}\,\Delta t}{\omega}\,S_{\alpha\beta} - \frac{\Delta t}{2}\left(F_{\alpha}u_{\beta} + F_{\beta}u_{\alpha}\right), $$ (bc_pineq_from_S) and the populations are assembled as the truncated equilibrium plus non-equilibrium expansions, $$ f_{i} = f_{i}^{\mathrm{eq}}(\rho, u_\alpha) + f_{i}^{\mathrm{neq}}(\Pi^{\mathrm{neq}}_{\alpha\beta}, u_\alpha, F_\alpha), $$ (bc_reconstruction) with $f_{i}^{\mathrm{eq}}$ given by Eq. {math:numref}`lb_equilibrium-pop-exp` and $f_{i}^{\mathrm{neq}}$ by Eq. {math:numref}`lb_non-equilibrium-pop-exp`. A boundary family is then fully specified by *which* of $\{\rho,\ u_\alpha,\ S_{\alpha\beta}\}$ it imposes and *how* it closes the rest. ## Wall-normal finite-difference closure Every closure that derives a gradient at the boundary uses a single stencil convention. The wall-normal derivative is the second-order one-sided finite difference, evaluated at the boundary node $x_0$ and reaching two nodes into the fluid along the inward normal (with $\Delta x = 1$ at each level): $$ \frac{\Delta u}{\Delta x_{n}}\left(x_{0}\right)=\frac{-3\,u\left(x_{0}\right)+4\,u\left(x_{0}+\Delta x\right)-u\left(x_{0}+2\Delta x\right)}{2\,\Delta x}. $$ (bc_mb_fd) The rate-of-strain is built from these one-sided derivatives, $$ S_{\alpha\beta}=\frac{1}{2}\left(\frac{\Delta u_{\alpha}}{\Delta x_{\beta}}+\frac{\Delta u_{\beta}}{\Delta x_{\alpha}}\right), $$ (bc_mb_strain) consistent with the regularized solid-wall stencil (Eqs. {math:numref}`bc_finite_difference`, {math:numref}`bc_2nd_finite_difference`) and the scalar wall reconstructions. This is the same off-wall stencil whose lattice-Boltzmann use traces to {footcite:t}`skordos1993initial`. It is the only wall-normal difference used by any fluid boundary condition. ```{note} The stencil is one-sided and reaches *into* the fluid. It is well defined wherever two interior nodes exist along the inward normal; edges and corners follow the overwriting order set in {ref}`the chapter introduction `. ``` ## Density is fixed, not extrapolated ```{admonition} Fixed-density rule --- class: warning --- At a boundary node the density is **fixed to a prescribed value**, not extrapolated or copied from the interior neighbour. ``` Extrapolating density is the weak link of a boundary closure. The wall-normal density gradient is small and noisy, so a one-sided extrapolation amplifies lattice noise directly into the imposed pressure $p = \rho c_s^2$; accumulated over a run it drifts the domain-average density and destabilises the weakly-compressible pressure field. Pinning the boundary density removes that feedback path and is standard practice for regularized boundaries {footcite:p}`latt2008straight`. Concretely: - **Walls** (no-slip, moving, slip) fix $\rho$ at the boundary node rather than reading it from the neighbour. - The **regularized Neumann outlet** fixes $\rho(\mathbf{x}_{\mathrm{out}}) = \rho_{\mathrm{cte}}$, which is why it holds a stable outlet pressure where a plain zero-gradient (Neumann) condition lets the density float (see {ref}`Outlet `). The only moments allowed to be zero-gradiented from the interior are velocity and stress, and only where the boundary models an open surface. ## Boundary families as moment closures Each bulk boundary condition is one instance of *impose -> derive -> reconstruct*. The per-type pages carry the geometry and use cases; this section states only the moment closure. ```{list-table} Moment closures of the fluid boundary families --- header-rows: 1 widths: 24 30 28 18 --- * - Family - Impose - Derive - Reconstruct * - No-slip wall - $u_\alpha = 0$; fix $\rho$ - $S_{\alpha\beta}$ from Eq. {math:numref}`bc_mb_strain` - Eq. {math:numref}`bc_reconstruction` * - Moving wall - $u_\alpha = u_{\mathrm{w},\alpha}$; fix $\rho$ - $S_{\alpha\beta}$ from Eq. {math:numref}`bc_mb_strain` - Eq. {math:numref}`bc_reconstruction` * - Velocity inlet - $\rho$ and $u_\alpha$ - $S_{\alpha\beta} = 0$ (equilibrium) - $f_i = f_i^{\mathrm{eq}}$ * - Outlet (reg. Neumann) - fix $\rho = \rho_{\mathrm{cte}}$ - $u_\alpha$, $S_{\alpha\beta}$ zero-gradient from interior - Eq. {math:numref}`bc_reconstruction` * - Free surface / slip - $u_n = 0$; fix $\rho$ - tangential $u_t$, $S_{\alpha\beta}$ zero-gradient - Eq. {math:numref}`bc_reconstruction` * - Wall-modeled rough wall - $u_\alpha$, $S_{\alpha\beta}$ from modeled $\tau_w$ - $\tau_w$ from log-law / TBL - Eq. {math:numref}`bc_reconstruction` ``` - **No-slip solid wall** - impose $u_\alpha = 0$ and fix the density; derive $S_{\alpha\beta}$ from the one-sided strain (Eq. {math:numref}`bc_mb_strain`); reconstruct via the third-order Hermite expansion. See {ref}`Solid Wall `. - **Moving wall** - identical to the no-slip wall but with $u_\alpha = u_{\mathrm{w},\alpha}$; same fixed-density and derived-stress treatment. See {ref}`Moving Wall `. - **Velocity inlet** - impose both $\rho$ and $u_\alpha$ and set the state to equilibrium ($S_{\alpha\beta} = 0$), so $f_i = f_i^{\mathrm{eq}}$. See {ref}`Inlet `. - **Outlet (regularized Neumann)** - fix the density (pressure) and take velocity and stress as zero-gradient from the interior node. See {ref}`Outlet `. - **Free-surface / slip** - impose zero normal velocity, fix the density, and zero-gradient the tangential velocity and stress. See {ref}`Free Surface `. - **Wall-modeled rough wall** - set the velocity and stress from the modeled wall stress $\tau_w$ (log-law / TBL); the moment-based wall stress route follows {footcite:t}`malaspinas2014wall`. The closure for $\tau_w$ is not re-derived here; see the {ref}`Wall model ` chapter. ## Velocity-set independence The closures are derived on the hydrodynamic moment hierarchy, not on a particular discrete velocity set, so they are velocity-set agnostic. The published three-dimensional moment-based boundary conditions are formulated on D3Q19 {footcite:p}`krastins2020moment`; they transfer to Nassu's production D3Q27 lattice unchanged, with no expected physical difference, because the imposed moments $\{\rho,\ u_\alpha,\ \Pi^{\mathrm{neq}}_{\alpha\beta}\}$ and their Hermite reconstruction are identical on both sets (D3Q27 simply carries the complete third-order Hermite basis exactly). ## Relation to population bounce-back Population bounce-back is the legacy local alternative: at streaming it reflects the post-collision population back along the opposite direction, $f_{\bar{i}}(t+\Delta t) = f_{i}^{*}(t)$ (Eq. {math:numref}`hbbounceback`). This places the wall on the link midway between nodes, half a lattice spacing off the boundary node, and the effective wall position drifts with the relaxation time as the viscosity or LES eddy viscosity changes - so the wall is only first-order accurate in its location {footcite:p}`latt2008straight,Kruger2016-cv`. Moment imposition instead places the wall **exactly on the boundary node** and reconstructs from imposed macroscopics, removing the relaxation-time offset. ```{admonition} Bounce-back vs moment imposition Moment imposition is node-coincident and reads the wall macroscopics directly; population bounce-back is strictly local but viscosity-dependent and offset by half a node. Moment imposition is the formulation used throughout this chapter; bounce-back remains documented as the local, viscosity-dependent legacy form. ``` ````{only} internal ## BC contract (engineering spec) ```{admonition} Boundary-condition contract :class: caution This is the implementation contract every bulk BC targets. It is normative. ``` A boundary condition **determines the boundary node's moments and writes them**: for a fluid field $\{\rho,\ u_\alpha,\ S_{\alpha\beta},\ \theta\}$; for a transported scalar field $\{\phi,\ q_\alpha\}$. The next bulk collision rebuilds the populations from those moments. The BC owns the moments; it never owns populations. **Disqualifying anti-pattern.** Any population round-trip is forbidden: reconstructing populations, reflecting them ($f_i = f_{\bar i}$), and re-deriving moments (`moms2pops -> reflect -> pops2moms`) is the exact pattern this formulation removes. A BC that touches individual $f_i$ to enforce a wall is wrong by construction. **Shared invariants.** 1. **One finite-difference stencil.** Every wall-normal gradient uses Eq. {math:numref}`bc_mb_fd` (second-order, one-sided, two interior nodes along the inward normal). No BC introduces its own stencil. 1. **Density is fixed, never extrapolated.** Walls and the regularized outlet pin $\rho$ at the boundary node. Only velocity and stress may be zero-gradiented, and only for open-surface families. 1. **One shared symbolic closure per field, parameterized by face normal.** There is exactly one reconstruction routine per field (fluid, scalar), parameterized by the boundary normal $\hat m$ and the imposed-moment set. There are no per-BC copies of the reconstruction, and no per-face copies of the closure - the normal is an argument, not a fork. This is the no-duplication mandate applied to boundaries: the same code, the same path, one closure differing only by its genuine variation points (which moments are imposed, the face normal). ```` ```{eval-rst} .. footbibliography:: ```