tud_lbm.registry ================ .. py:module:: tud_lbm.registry .. autoapi-nested-parse:: Central operator registry for TUD-LBM. Every operator (class or pure function) self-registers at import time via the :func:`register_operator` decorator. Consumers look up entries via :func:`get_operators`, :func:`get_operator_names`, or :func:`get_operator_category`. The registry stores :class:`OperatorEntry` objects keyed by ``"{kind}:{name}"``. Usage:: from registry import register_operator, get_operators @register_operator("collision_models") def collide_bgk(f, feq, tau, source=None): ... collide_bgk.name = "bgk" # or, for classes: @register_operator("collision_models") class CollisionBGK: name = "bgk" ... ops = get_operators("collision_models") # {"bgk": OperatorEntry(name="bgk", kind="collision_models", target=...)} Attributes ---------- .. autoapisummary:: tud_lbm.registry.OperatorTarget tud_lbm.registry.T tud_lbm.registry.OPERATOR_REGISTRY Classes ------- .. autoapisummary:: tud_lbm.registry.OperatorEntry Functions --------- .. autoapisummary:: tud_lbm.registry.register_operator tud_lbm.registry.get_operators tud_lbm.registry.get_operator_names tud_lbm.registry.get_operator_category tud_lbm.registry.unregister_operator tud_lbm.registry.collision_model tud_lbm.registry.force_model tud_lbm.registry.boundary_condition tud_lbm.registry.macroscopic_operator tud_lbm.registry.initialise_operator tud_lbm.registry.equilibrium_operator tud_lbm.registry.simulation_type_operator tud_lbm.registry.stream_operator tud_lbm.registry.update_timestep_operator tud_lbm.registry.wetting_operator tud_lbm.registry.lattice_operator tud_lbm.registry.plotting_operator tud_lbm.registry.comparison_operator tud_lbm.registry.extra_state_plugin Module Contents --------------- .. py:data:: OperatorTarget .. py:data:: T .. py:class:: OperatorEntry Bases: :py:obj:`Generic`\ [\ :py:obj:`T`\ ] A single entry in the global operator registry. .. py:attribute:: name :type: str .. py:attribute:: kind :type: str .. py:attribute:: target :type: T .. py:attribute:: metadata :type: dict[str, object] | None :value: None .. py:data:: OPERATOR_REGISTRY :type: dict[str, OperatorEntry[object]] .. py:function:: register_operator(kind: str, *, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Decorator to register a class or function in the global registry. The decorated object must either: * Have a ``name`` class/function attribute, **or** * Receive *name* explicitly via the keyword argument. :param kind: Operator category, e.g. ``"collision_models"``. :param name: Optional explicit name. Falls back to ``obj.name`` or ``obj.__name__``. :param \*\*meta: Arbitrary metadata stored in :attr:`OperatorEntry.metadata`. :returns: A decorator that registers *obj* and returns it unchanged. :raises ValueError: If *obj* has no discoverable name, or if the ``kind:name`` key is already registered. .. py:function:: get_operators(kind: str) -> dict[str, OperatorEntry] Return all registered operators of the given *kind*. :param kind: Category string, e.g. ``"collision_models"``. :returns: ``{name: OperatorEntry, ...}`` .. py:function:: get_operator_names(kind: str) -> set[str] Return the set of registered operator names for *kind*. .. py:function:: get_operator_category() -> set[str] Return the set of all registered operator kinds. .. py:function:: unregister_operator(kind: str, name: str) -> None Remove an operator from the registry (for testing only). :param kind: Operator category, e.g. ``"collision_models"``. :param name: Operator name within that category. .. py:function:: collision_model(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a collision operator (kind ``"collision_models"``). .. py:function:: force_model(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a force operator (kind ``"force"``). .. py:function:: boundary_condition(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a boundary-condition operator (kind ``"boundary_condition"``). .. py:function:: macroscopic_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a macroscopic operator (kind ``"macroscopic"``). .. py:function:: initialise_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register an initialisation operator (kind ``"initialise"``). .. py:function:: equilibrium_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register an equilibrium operator (kind ``"equilibrium"``). .. py:function:: simulation_type_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a simulation type (kind ``"simulation_type"``). .. py:function:: stream_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a streaming operator (kind ``"stream"``). .. py:function:: update_timestep_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register an update-timestep operator (kind ``"update_timestep"``). .. py:function:: wetting_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a wetting operator (kind ``"wetting"``). .. py:function:: lattice_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a lattice model (kind ``"lattice"``). .. py:function:: plotting_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a plotting operator (kind ``"plotting"``). .. py:function:: comparison_operator(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register a comparison plot operator (kind ``"comparison"``). .. py:function:: extra_state_plugin(*, name: str | None = None, **meta: object) -> collections.abc.Callable[[_OT], _OT] Register an extra-state plugin (kind ``"extra_state"``).