"""Interface of the Warp blood-flow solvers.
:class:`WarpFlowBase` is what a time-stepping blood-flow solver offers the
workflows that drive it. Solver families are tagged by suffix: Navier-Stokes
(NS) solvers live in ``*_ns.py`` modules as ``...NS`` classes, such as
:class:`monai_physio.WarpFlowNS`; lattice-Boltzmann (LB) solvers belong in
``*_lb.py`` modules as ``...LB`` classes; the solver-independent parts live
in ``*_base.py`` modules as ``...Base`` classes. Boundary conditions shared by
every solver are in :mod:`monai_physio.process_flow_boundaries`.
"""
from __future__ import annotations
from typing import Any
import numpy as np
from .monai_physio_base import MONAIPhysioBase
from .process_flow_boundaries import Windkessel
[docs]
class WarpFlowBase(MONAIPhysioBase):
"""Time-stepping blood-flow solver with an inlet flow and outlet models.
Ports are boundary regions identified by integer ids. The inlet takes a
prescribed volume flow; every outlet ends in an object with the
:class:`Windkessel` members ``implicit(dt)``, ``advance(Q, dt)`` and
``pressure``, which the solver updates in place.
"""
#: Time step in seconds.
dt: float
#: Outlet model of every outlet region.
outlets: dict[int, Windkessel]
[docs]
def step(self, inlet_flow: float) -> dict[str, Any]:
"""Advance one time step and update the outlet models.
Args:
inlet_flow: Volume flow entering through the inlet in m^3/s.
Returns:
At least ``"flows_m3_s"``, the outward flow of every port region
in m^3/s, ``"pressures_pa"``, the pressure of every outlet region
in Pa, and ``"residual"``, the relative residual of the step's
solve.
"""
raise NotImplementedError
[docs]
def velocity(self) -> np.ndarray:
"""Return the current velocity in m/s at the solver's velocity points."""
raise NotImplementedError
[docs]
def pressure(self) -> np.ndarray:
"""Return the current pressure in Pa at the solver's pressure points."""
raise NotImplementedError
[docs]
def close(self) -> None:
"""Release the solver's native and GPU resources."""
raise NotImplementedError