diff --git a/tests/unit/test_jets.py b/tests/unit/test_jets.py index aea1770..9285f2e 100644 --- a/tests/unit/test_jets.py +++ b/tests/unit/test_jets.py @@ -346,3 +346,30 @@ def test_separate_jets_on_separate_bodies_accepted(device): for j in (0, 1): assert len(np.unique(cl.body_id[cl.jet_id == j])) == 1 assert cl.body_id[cl.jet_id == 0][0] != cl.body_id[cl.jet_id == 1][0] + + +def test_one_body_with_noncontiguous_rows_accepted_and_mixed_rejected(): + # Synthetic rows: ownership is set membership over body_id, not row adjacency. + from CelerisLab.body.geometry.circle import CircleGeometry + from CelerisLab.body.objects import SimObject + from CelerisLab.config import LBMConfig + from CelerisLab.lbm.descriptors import FLUID + cfg = LBMConfig(nx=12, ny=10, viscosity=.1) + cfg.validate() + objs = [SimObject(i, geometry=CircleGeometry(3. + 5*i, 5., 1.), center=(3. + 5*i, 5.), radius=1.) + for i in (0, 1)] + flags = np.full(cfg.nx*cfg.ny, FLUID, np.uint16) + fluid_idx = np.array([10, 20, 30], np.uint32) + dirs = np.array([1, 1, 1], np.uint8) + zeros = np.zeros(3, np.float32) + hits = np.array([[0., 0.], [5., 5.], [0., 1.]]) + jet = Jet(Tube((0., -.5), math.pi/2, 2., .5), Parallel(0.)) # selects rows 0 and 2 + for body_id, ok in ((np.array([0, 1, 0], np.int32), True), (np.array([0, 1, 1], np.int32), False)): + call = lambda: surface_link_velocity(objs, cfg, flags, fluid_idx, dirs, body_id, + zeros, zeros, jets=[jet], hits=hits) + if ok: + _, aperture = call() + assert aperture.tolist() == [True, False, True] + else: + with pytest.raises(ValueError, match="one jet may drive only one body"): + call()