tud_lbm.operators.boundary

Boundary condition operators — composite builder.

Public API: build_bc(), BCMasks, build_bc_masks

Implementation modules (_bounce_back.py, _periodic.py, _symmetry.py) are internal.

Example

from operators.boundary import build_bc, build_bc_masks

bc_fn = build_bc({“top”: “symmetry”, “bottom”: “bounce-back”}, lattice) masks = build_bc_masks((64, 64)) f = bc_fn(f_stream, f_col, masks)

Classes

BCMasks

Pre-computed boundary-condition masks — valid JAX pytree.

Functions

build_bc_masks(→ BCMasks)

Construct pre-computed boundary-condition masks.

build_bc(→ tud_lbm.operators.protocols.BoundaryOperator)

Build a composite BC closure from a bc_config dict.

Package Contents

class tud_lbm.operators.boundary.BCMasks[source]

Bases: NamedTuple

Pre-computed boundary-condition masks — valid JAX pytree.

Each mask is a boolean jax.Array of shape (nx, ny, nz, 1, 1) that is True on the corresponding edge row/column/plane.

top[source]

Mask for the top boundary (y = ny-1).

bottom[source]

Mask for the bottom boundary (y = 0).

left[source]

Mask for the left boundary (x = 0).

right[source]

Mask for the right boundary (x = nx-1).

front[source]

Mask for the front boundary (z = nz-1).

back[source]

Mask for the back boundary (z = 0).

top: jax.numpy.ndarray[source]
bottom: jax.numpy.ndarray[source]
left: jax.numpy.ndarray[source]
right: jax.numpy.ndarray[source]
front: jax.numpy.ndarray | None = None[source]
back: jax.numpy.ndarray | None = None[source]
tud_lbm.operators.boundary.build_bc_masks(grid_shape: tuple[int, Ellipsis]) BCMasks[source]

Construct pre-computed boundary-condition masks.

Each mask is a boolean array of shape (nx, ny, nz, 1, 1) that is True on the corresponding edge row/column/plane.

Parameters:

grid_shape – Spatial dimensions (nx, ny, nz).

Returns:

A BCMasks NamedTuple with 3D-shaped masks for all 6 faces.

tud_lbm.operators.boundary.build_bc(bc_config: dict[str, Any] | None, lattice: tud_lbm.lattice.lattice.Lattice) tud_lbm.operators.protocols.BoundaryOperator[source]

Build a composite BC closure from a bc_config dict.

The returned function applies boundary conditions in order: bottom → top → left → right. Edges not present in bc_config or mapped to "periodic" are no-ops.

Parameters:
  • bc_config – Mapping {_edge: bc_type, ...}, e.g. {"top": "symmetry", "bottom": "bounce-back", "left": "periodic", "right": "periodic"}. None means all-periodic.

  • latticeLattice.

Returns:

A callable satisfying the BoundaryOperator protocol, bc_fn(f_stream, f_col, bc_masks) f.