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
+5 -25
View File
@@ -9,9 +9,9 @@ import json
import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
from CelerisLab.simulation import Simulation, _scatter_to_field, _gather_from_field
from ._cases import make_sim
# Use a small grid for fast compilation and test execution
@@ -23,7 +23,7 @@ class TestSyncBodiesSkeleton(unittest.TestCase):
def _make_sim(self) -> Simulation:
"""Create a Simulation with a small double_buffer D2Q9 grid."""
return Simulation(device_id=0)
return make_sim()
def test_remove_body_sync_and_run(self):
"""Remove a body, sync, and continue running without crash."""
@@ -134,28 +134,7 @@ class TestSyncBodiesEsoPull(unittest.TestCase):
def _make_esopull_sim(self, nx=128, ny=64) -> Simulation:
"""Create a Simulation with a small esopull D2Q9 grid."""
cfg = {
"grid": {"lattice_model": "D2Q9", "nx": nx, "ny": ny, "nz": 1},
"physics": {"data_type": "FP32", "viscosity": 0.05,
"velocity": 0.03, "rho": 1.0},
"method": {
"collision": "SRT", "streaming": "esopull",
"store_precision": "FP32", "ddf_shifting": False,
"les": {"enabled": False, "cs": 0.16, "closed_form": True},
"trt": {"magic_param": 0.1875},
"inlet": {"profile": "parabolic", "scheme": "zou_he_local"},
"outlet": {"mode": "neq_extrap", "backflow_clamp": True,
"blend_alpha": 0.7},
"y_wall_bc": "bounce_back",
"omega_guard": {"min": 0.01, "max": 1.99},
},
"cuda": {"threads_per_block": 256, "compute_capability": "auto"},
}
tmpd = tempfile.mkdtemp(prefix="esopull_sync_")
lbm_path = os.path.join(tmpd, "config_lbm.json")
with open(lbm_path, "w") as f:
json.dump(cfg, f)
return Simulation(lbm_config_path=lbm_path)
return make_sim(nx=nx, ny=ny, streaming="esopull")
def test_esopull_add_body(self):
"""EsoPull: add body, sync, run, read finite force."""
@@ -234,7 +213,8 @@ class TestSyncBodiesEsoPull(unittest.TestCase):
_gather_from_field(sim.field, s_host, all_cells)
sim.field.esopull_sync_encode(
s_gpu, s_host, idx_gpu, len(all_cells), step, stream)
stream.synchronize()
with sim.ctx.activate():
stream.synchronize()
sim.run(100)
macro = sim.get_macroscopic()