tud_lbm.operators.boundary ========================== .. py:module:: tud_lbm.operators.boundary .. autoapi-nested-parse:: Boundary condition operators — composite builder. Public API: build_bc(), BCMasks, build_bc_masks Implementation modules (_bounce_back.py, _periodic.py, _symmetry.py) are internal. .. rubric:: 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 ------- .. autoapisummary:: tud_lbm.operators.boundary.BCMasks Functions --------- .. autoapisummary:: tud_lbm.operators.boundary.build_bc_masks tud_lbm.operators.boundary.build_bc Package Contents ---------------- .. py:class:: BCMasks Bases: :py:obj:`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. .. attribute:: top Mask for the top boundary (y = ny-1). .. attribute:: bottom Mask for the bottom boundary (y = 0). .. attribute:: left Mask for the left boundary (x = 0). .. attribute:: right Mask for the right boundary (x = nx-1). .. attribute:: front Mask for the front boundary (z = nz-1). .. attribute:: back Mask for the back boundary (z = 0). .. py:attribute:: top :type: jax.numpy.ndarray .. py:attribute:: bottom :type: jax.numpy.ndarray .. py:attribute:: left :type: jax.numpy.ndarray .. py:attribute:: right :type: jax.numpy.ndarray .. py:attribute:: front :type: jax.numpy.ndarray | None :value: None .. py:attribute:: back :type: jax.numpy.ndarray | None :value: None .. py:function:: build_bc_masks(grid_shape: tuple[int, Ellipsis]) -> BCMasks 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. :param grid_shape: Spatial dimensions ``(nx, ny, nz)``. :returns: A :class:`BCMasks` NamedTuple with 3D-shaped masks for all 6 faces. .. py:function:: build_bc(bc_config: dict[str, Any] | None, lattice: tud_lbm.lattice.lattice.Lattice) -> tud_lbm.operators.protocols.BoundaryOperator 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. :param bc_config: Mapping ``{_edge: bc_type, ...}``, e.g. ``{"top": "symmetry", "bottom": "bounce-back", "left": "periodic", "right": "periodic"}``. ``None`` means all-periodic. :param lattice: :class:`~setup.lattice.Lattice`. :returns: A callable satisfying the BoundaryOperator protocol, ``bc_fn(f_stream, f_col, bc_masks) → f``.