Add jet, surface and fixed-patch tests and runnable examples

This commit is contained in:
Frank14f
2026-10-15 10:13:49 +08:00
parent ed1a6ee54e
commit cdbb9c42f6
48 changed files with 9267 additions and 210 deletions
+7 -7
View File
@@ -5,9 +5,9 @@ Requires GPU."""
import unittest
import numpy as np
import pycuda.autoinit
from CelerisLab.simulation import Simulation
from ._cases import make_sim
from CelerisLab.lbm.descriptors import FLUID, OBSTACLE
@@ -17,7 +17,7 @@ class TestDDFPatchAddBody(unittest.TestCase):
def test_add_body_runs_stably(self):
"""After adding a body, the simulation runs with finite forces
for a moderate number of steps."""
sim = Simulation(device_id=0)
sim = make_sim()
nx = sim.lbm_cfg.nx
ny = sim.lbm_cfg.ny
cx, cy = nx // 4, ny // 2
@@ -44,7 +44,7 @@ class TestDDFPatchRemoveBody(unittest.TestCase):
def test_remove_body_released_region_is_fluid(self):
"""After removal, the former body center should be a fluid cell."""
sim = Simulation(device_id=0)
sim = make_sim()
nx = sim.lbm_cfg.nx
ny = sim.lbm_cfg.ny
cx, cy = nx // 4, ny // 2
@@ -63,7 +63,7 @@ class TestDDFPatchRemoveBody(unittest.TestCase):
def test_remove_body_finite_field(self):
"""After removal, the macroscopic field is finite."""
sim = Simulation(device_id=0)
sim = make_sim()
nx = sim.lbm_cfg.nx
ny = sim.lbm_cfg.ny
cx, cy = nx // 4, ny // 2
@@ -91,7 +91,7 @@ class TestDDFPatchAddAndRemove(unittest.TestCase):
def test_add_one_remove_another(self):
"""Add a body and remove a different one in the same sync."""
sim = Simulation(device_id=0)
sim = make_sim()
nx = sim.lbm_cfg.nx
ny = sim.lbm_cfg.ny
cx, cy = nx // 4, ny // 2
@@ -119,8 +119,8 @@ class TestDDFPatchNoChange(unittest.TestCase):
def test_no_mask_no_change(self):
"""When neither mask has any True entries, DDF should be unchanged."""
sim = Simulation(device_id=0)
sim.add_body("circle", center=(128, 128), radius=8)
sim = make_sim()
sim.add_body("circle", center=(sim.lbm_cfg.nx // 4, sim.lbm_cfg.ny // 2), radius=8)
sim.initialize()
sim.run(100)