---
title: Boundary conditions
summary: Boundary conditions are imposed weakly through the same numerical fluxes as interior faces. Walls use a boundary state rather than a ghost-cell Riemann problem, which keeps force functionals adjoint consistent.
section: theory
order: 6
level: 2
keywords: [boundary conditions, adjoint consistency, slip wall, no-slip wall, far field]
---
<!-- gyre docs: expanded Markdown of theory/boundary-conditions.md (generated tables, verification numbers and chart data are written out). Base level of this page: L2 Practice; passages at another level are bracketed by 'begin level N' / 'end level N' comments and start with [LN Name]. Built from revision ceb1f4b0be. -->

Every boundary face is treated like an interior face whose exterior data are supplied by a
boundary function of the interior trace $\mathbf U^-$, the outward normal and the flow
parameters. Each boundary function returns three states:

* $\mathbf U_L, \mathbf U_R$ — handed to the interface Riemann flux;
* $\mathbf U_b$ — the boundary state for viscous fluxes and gradient lifting (or none).

| condition | inviscid flux | viscous treatment |
|---|---|---|
| `farfield` | Riemann flux between $\mathbf U^-$ and the free stream | interior gradient, no lifting |
| `slip_wall`, `symmetry` | $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma)$, normal momentum removed | no viscous flux |
| `slip_wall_mirror` | Riemann flux against the mirrored state | no viscous flux |
| `noslip_adiabatic` | $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma)$, zero velocity | $\mathbf u = 0$ lifted, zero heat flux |
| `noslip_isothermal` | as above with wall temperature `t_wall` | $\mathbf u = 0$, $T = T_w$ lifted |
| `pressure_outlet` | $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma)$ with $p = p_\text{back}$ (interior $p$ if supersonic) | interior gradient |
| `total_inlet` | $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma)$ from total pressure/temperature and flow angle, interior static pressure | interior gradient |

Three conditions read data from the flow parameters: `noslip_isothermal` the wall temperature
`t_wall`, `pressure_outlet` the back pressure `p_back` and `total_inlet` the total pressure and
temperature `pt_in`, `tt_in`, all as ratios to the free-stream static values. A condition whose
data are missing is rejected with an error that names the boundary group, the condition and the
key.

<!-- begin level 3 (Mechanics) -->
**[L3 Mechanics] Direct boundary states and adjoint consistency**

For walls and for the internal-flow inlet/outlet conditions Gyre sets $\mathbf U_L = \mathbf U_R =
\mathbf U_\Gamma(\mathbf U^-)$. Any consistent numerical flux then returns exactly the physical
flux of the boundary state, $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma)$, with no dissipation. For a
slip wall

$$
\mathbf U_\Gamma = \left(\rho,\; \rho\mathbf u - (\rho\mathbf u\cdot\mathbf n)\,\mathbf n,\; \rho E\right),
\qquad \mathbf n\cdot\mathbf F(\mathbf U_\Gamma) = (0,\; p_\Gamma\,\mathbf n,\; 0),
$$

so the wall flux is a pure pressure force with $p_\Gamma = p(\mathbf U_\Gamma)$. Following Hartmann
and Leicht, a boundary flux of the form $\mathbf n\cdot\mathbf F(\mathbf U_\Gamma(\mathbf U^-))$,
combined with functionals evaluated from *the same* boundary flux, yields an adjoint-consistent
discretization: the discrete adjoint is a consistent discretization of the continuous adjoint
problem including its boundary conditions. The mirrored-ghost-state alternative is available for
comparison but is not adjoint consistent in this sense.

<!-- end level 3 -->

<!-- begin level 3 (Mechanics) -->
**[L3 Mechanics] Functionals reuse the residual's fluxes**

Forces are not recomputed from interpolated pressure. `SurfaceOps.face_forces` calls the
residual kernel with `faces=True` and integrates the momentum components of the numerical
boundary flux — inviscid minus viscous — that the residual itself used. Two consequences:

1. the force is discretely conservative: summing the surface loads and the far-field momentum
   flux reproduces the residual sum exactly;
2. the functional is adjoint consistent, a prerequisite for the superconvergence measured in the
   output-error study.

<!-- end level 3 -->

<!-- begin level 3 (Mechanics) -->
**[L3 Mechanics] No-slip walls**

The boundary state keeps density and total energy and sets the velocity to zero,
$\mathbf U_\Gamma = (\rho, \mathbf 0, \rho E)$ (adiabatic), or replaces the energy by
$\rho\,c_v T_w$ (isothermal). Velocity (and wall temperature) enter the BR2 lifting as Dirichlet
data, $\mathbf W^* = \mathbf W(\mathbf U_\Gamma)$; the viscous boundary flux is
$\mathbf F_v(\mathbf U_\Gamma, \mathbf G + \eta\,\mathbf r_f)\cdot\mathbf n$, with the energy component
removed for adiabatic walls (zero heat flux and zero velocity leave no energy transfer).
The numerical energy flux through an adiabatic wall is therefore zero by construction, for any
state. The [cylinder validation](../verification/validation.md) checks instead that the wall
heat conduction of the converged solution, the flux that is removed, decreases between the
two highest polynomial degrees; it vanishes for the exact solution.

<!-- end level 3 -->

<!-- begin level 4 (Theory) -->
**[L4 Theory] Boundary conditions under differentiation**

Boundary functions are ordinary JAX code of $(\mathbf U^-, \mathbf n, \mathbf x, \theta)$. Their
dependence on flow parameters (the free-stream state in `farfield`, the back pressure in
`pressure_outlet`) and on geometry (through $\mathbf n$) is therefore differentiated together with
everything else. The linearization study verifies JVPs, VJPs and the block preconditioner for
every wall type, the mirrored slip wall (`slip_wall_mirror`) with each interface flux
included, for a channel mixing four different conditions and for an inlet/outlet channel
(`total_inlet`, `pressure_outlet`, `symmetry`, `slip_wall_mirror`).

**Table: Linearization defects** (Exact linearization by automatic differentiation)

| configuration | p | DOF | JVP vs FD (rel.) | dot-product (rel.) | \|B⁻¹ J_ee - I\| | split residual defect |
|---|---|---|---|---|---|---|
| Euler, slip wall | 2 | 432 | 5.3652e-10 | 7.4656e-16 | 6.7502e-14 | 0 |
| NS, adiabatic wall | 2 | 432 | 3.7139e-10 | 7.5418e-15 | 1.2397e-14 | 0 |
| NS, isothermal wall | 2 | 432 | 3.1571e-10 | 1.0274e-13 | 1.6348e-14 | 0 |
| NS, mixed channel | 3 | 576 | 5.2611e-10 | 4.3341e-16 | 1.4949e-14 | 0 |
| Euler, mirrored slip wall | 2 | 432 | 1.9949e-10 | 1.0578e-13 | 5.6843e-14 | 0 |
| Euler, mirrored slip wall, HLLC flux | 2 | 432 | 5.6037e-10 | 7.5694e-14 | 2.4869e-14 | 0 |
| Euler, mirrored slip wall, LLF flux | 2 | 432 | 1.3770e-10 | 1.4703e-15 | 1.1713e-14 | 0 |
| Euler, inlet/outlet channel | 2 | 324 | 2.1088e-10 | 1.2508e-13 | 5.3846e-15 | 0 |
| Euler, mirrored slip wall, ES-Roe flux | 2 | 432 | 1.8848e-10 | 1.3925e-14 | 3.8192e-14 | 0 |
| NS, adiabatic wall, ES-Roe flux | 2 | 432 | 3.0017e-10 | 2.9248e-15 | 1.6784e-14 | 0 |

Provenance: gyre 0.4.0; revision `39979fcf90` (commit `39979fcf902ad6116eb550b881b4278d4599c8e2`); 2026-11-12T10:27:54-0500; device cpu; quick suite. **Revision check: Same code as this build.** Produced by 39979fcf902ad6116eb550b881b4278d4599c8e2. Every commit between it and the commit this site was built from (ceb1f4b0bed41de53e586df10858079f5a2bcdd8) changes only documentation text, evidence records or bookkeeping: the code is the same. Full record: [linearization.json](../data/verification/linearization.json).

<!-- end level 4 -->
