From dd9a4dc4b8eff76659ed756c338fd814938a7629 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Oct 2026 14:39:29 +0000 Subject: [PATCH] Three levels: step unpacks only the first two levels; README multipatch nits step() did 'c, f = self._levels', which raises for three levels before any launch (root review). The child level is driven from the fine hops. Other _levels uses are per-level loops or explicit indices. README multipatch example now defines rest locally and states coarse/fine NaN separately. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +++- src/CelerisLab/lbm/refinement_stepper.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5445ae5..739dc72 100644 --- a/README.md +++ b/README.md @@ -145,13 +145,15 @@ Scope and limits: ```python cfg = LBMConfig(nx=32, ny=16, viscosity=.1) + rest = np.asarray(compute_feq_d2q9(1.0, 0.0, 0.0), np.float32)[:, None, None] with CudaContext(0) as ctx, FixedPatchStepper( cfg, ((4, 4, 12, 12), (16, 4, 24, 12)), context=ctx, fine_block=(4, 4), base_block=(4, 4)) as run: run.initialize(np.broadcast_to(rest, (9, *run.patch.coarse_shape)), np.broadcast_to(rest, (9, *run.patch.fine_shape))) # (9, 32, 64) run.step(32) - coarse_g, fine_g = run.download() # NaN outside every patch's active cells + coarse_g, fine_g = run.download() # coarse: NaN on every covered cell; + # fine: NaN on every non-ACTIVE cell ``` - Not available: per-link surface exchange/force readout in blocked mode, checkpoints, moving bodies, bodies/Jets with several patches, dynamic refinement, `Simulation` diff --git a/src/CelerisLab/lbm/refinement_stepper.py b/src/CelerisLab/lbm/refinement_stepper.py index bfa397c..ead846d 100644 --- a/src/CelerisLab/lbm/refinement_stepper.py +++ b/src/CelerisLab/lbm/refinement_stepper.py @@ -496,7 +496,7 @@ class FixedPatchStepper: raise ValueError("n must be a nonnegative integer") with self._lock, self.ctx.activate(): self._require("ready") - c, f = self._levels + c, f = self._levels[:2] # a nested child (third level) runs inside the fine hops p = self.patch kw = dict(block=self._block, stream=self._stream) try: