Example/docs closure fixes
- README: close the Manual stream control code fence before the new section; snippet now builds rest-equilibrium inputs (runnable as shown). - Example: diagnostics use the known fluid-leaf masks (uncovered coarse minus slot-mode wall rows; fine ACTIVE minus solids) and raise on any non-finite population or rho <= 0 there instead of filtering by finiteness. No solver changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5304525e39
commit
749f103ea8
2 files changed
+30
-8
No files matched your search
@@ -90,6 +90,7 @@ sim.run(100, stream=stream, upload_act=False, sync_obs=False)
|
||||
# Later: sync and read
|
||||
stream.synchronize()
|
||||
obs = sim.read_bodies(stream=stream) # sync already done, just read pinned buffer
|
||||
```
|
||||
|
||||
### Fixed 2:1 refinement patch (experimental backend)
|
||||
|
||||
@@ -99,10 +100,12 @@ normal surface velocity (blowing/suction). It is a standalone backend, not part
|
||||
of `Simulation`. Runnable demo: `examples/fixed_patch_circle.py`.
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
from CelerisLab.body.geometry.circle import CircleGeometry
|
||||
from CelerisLab.body.objects import SimObject, SurfaceActuation
|
||||
from CelerisLab.config import LBMConfig
|
||||
from CelerisLab.cuda.context import CudaContext
|
||||
from CelerisLab.lbm.equilibrium import compute_feq_d2q9
|
||||
from CelerisLab.lbm.refinement_stepper import FixedPatchStepper
|
||||
|
||||
cfg = LBMConfig(nx=32, ny=24, viscosity=.1)
|
||||
@@ -110,7 +113,10 @@ body = SimObject(0, geometry=CircleGeometry(16.0, 12.0, 2.15), center=(16.0, 12.
|
||||
surface_actuation=SurfaceActuation(0.7, 0.85, 0.002)) # angle, half-width, speed
|
||||
with CudaContext(0) as ctx, FixedPatchStepper(cfg, (8, 6, 24, 18), context=ctx,
|
||||
fine_objects=[body], fine_block=(16, 20)) as run:
|
||||
run.initialize(coarse_g, fine_g) # (9, ny, nx) postcollision populations per level
|
||||
rest = np.asarray(compute_feq_d2q9(1.0, 0.0, 0.0), np.float32)[:, None, None]
|
||||
# (9, ny, nx) postcollision populations per level; non-leaf cells are discarded.
|
||||
run.initialize(np.broadcast_to(rest, (9, *run.patch.coarse_shape)),
|
||||
np.broadcast_to(rest, (9, *run.patch.fine_shape)))
|
||||
run.step(128) # coarse steps; fine level takes two per step
|
||||
coarse_g, fine_g = run.download() # NaN on covered, ghost and solid cells
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user