diff --git a/tests/validation/multigrid/test_exchange_window.py b/tests/validation/multigrid/test_exchange_window.py index be8b11c..a66bdde 100644 --- a/tests/validation/multigrid/test_exchange_window.py +++ b/tests/validation/multigrid/test_exchange_window.py @@ -25,8 +25,8 @@ EPS = np.finfo(np.float64).eps def build(m, window=True, raw=True): - return FixedPatchStepper(config("periodic"), BOUNDS, context=m["context"], base_block=(3, 4), - fine_block=(16, 20), fine_objects=[circle()], + return FixedPatchStepper(config("periodic"), context=m["context"], refinements=[BOUNDS], + level_blocks=[(3, 4), (16, 20)], level_objects=[(), (circle(),)], observe_raw_exchange=raw, observe_window_exchange=window) @@ -109,10 +109,11 @@ class ExchangeWindowGPU(unittest.TestCase): from test_raw_exchange_gpu import BOUNDS as RB, CFG, circle as rc, jet, state from CelerisLab.cuda.context import CudaContext with CudaContext(0) as ctx: - kw = dict(context=ctx, fine_block=(16, 20), fine_objects=[rc()], jets=[jet()], + kw = dict(context=ctx, refinements=[RB], level_blocks=[None, (16, 20)], + level_objects=[(), (rc(),)], level_jets=[(), (jet(),)], observe_raw_exchange=True) - with FixedPatchStepper(CFG, RB, observe_window_exchange=True, **kw) as windowed, \ - FixedPatchStepper(CFG, RB, **kw) as plain: + with FixedPatchStepper(CFG, observe_window_exchange=True, **kw) as windowed, \ + FixedPatchStepper(CFG, **kw) as plain: arrays = [state(level.shape) for level in windowed._levels] windowed.initialize(*arrays) plain.initialize(*arrays) @@ -200,11 +201,11 @@ class ExchangeWindowShiftedMRTGPU(unittest.TestCase): from CelerisLab.cuda.context import CudaContext cfg = LBMConfig(nx=32, ny=24, viscosity=.1, collision="MRT", ddf_shifting=True) with CudaContext(0) as ctx: - kw = dict(context=ctx, base_block=(12, 8), fine_block=(16, 20), fine_objects=[rc()], - observe_raw_exchange=True) - with FixedPatchStepper(cfg, RB, observe_window_exchange=True, **kw) as windowed, \ - FixedPatchStepper(cfg, RB, observe_window_exchange=True, **kw) as split, \ - FixedPatchStepper(cfg, RB, **kw) as plain: + kw = dict(context=ctx, refinements=[RB], level_blocks=[(12, 8), (16, 20)], + level_objects=[(), (rc(),)], observe_raw_exchange=True) + with FixedPatchStepper(cfg, observe_window_exchange=True, **kw) as windowed, \ + FixedPatchStepper(cfg, observe_window_exchange=True, **kw) as split, \ + FixedPatchStepper(cfg, **kw) as plain: arrays = [state(level.shape) for level in windowed._levels] for run in (windowed, split, plain): run.initialize(*arrays) diff --git a/tests/validation/multigrid/test_multiple_pinned_remap_gpu.py b/tests/validation/multigrid/test_multiple_pinned_remap_gpu.py index f518dd1..0ce6962 100644 --- a/tests/validation/multigrid/test_multiple_pinned_remap_gpu.py +++ b/tests/validation/multigrid/test_multiple_pinned_remap_gpu.py @@ -48,9 +48,8 @@ def make(context): for (x, y), amplitude in zip(centers, (.003, -.002)) ) run = FixedPatchStepper( - CFG, PARENTS, context=context, base_block=(4, 4), fine_block=(4, 4), - child_block=(4, 4), child_rectangles_in_parent=START, - child_objects=objects, child_jets=jets, + CFG, context=context, refinements=[PARENTS, START], level_blocks=[(4, 4)] * 3, + level_objects=[(), (), objects], level_jets=[(), (), jets], ) return run, objects diff --git a/tests/validation/multigrid/test_pinned_body_remap_gpu.py b/tests/validation/multigrid/test_pinned_body_remap_gpu.py index 8f1e1d0..4959ad8 100644 --- a/tests/validation/multigrid/test_pinned_body_remap_gpu.py +++ b/tests/validation/multigrid/test_pinned_body_remap_gpu.py @@ -25,9 +25,8 @@ B = ((16,16,32,40), (60,16,76,40)) def make(ctx): body = SimObject(71, geometry=CircleGeometry(12.,14.,.8),center=(12.,14.),radius=.8) jet = Jet(Tube((10.5,14.),0.,3.,.3),Parallel(0.),'parabolic',.003) - run = FixedPatchStepper(CFG,PARENTS,context=ctx,base_block=(4,4),fine_block=(4,4), - child_block=(4,4),child_rectangles_in_parent=A, - child_objects=(body,),child_jets=(jet,)) + run = FixedPatchStepper(CFG,context=ctx,refinements=[PARENTS,A],level_blocks=[(4,4)]*3, + level_objects=[(),(),(body,)],level_jets=[(),(),(jet,)]) return run,(body,) diff --git a/tests/validation/multigrid/test_raw_exchange_gpu.py b/tests/validation/multigrid/test_raw_exchange_gpu.py index e08da43..464ab67 100644 --- a/tests/validation/multigrid/test_raw_exchange_gpu.py +++ b/tests/validation/multigrid/test_raw_exchange_gpu.py @@ -90,14 +90,18 @@ def census(run, index, buffer): return totals(dense, leaf), external, independent + +def fine(block): + """Two-level circle+jet construction on BOUNDS; block None keeps the dense fine level.""" + return dict(refinements=[BOUNDS], level_blocks=[None, block], + level_objects=[(), (circle(),)], level_jets=[(), (jet(),)]) + class RawExchangeGPU(unittest.TestCase): def test_row_ledger_interval_jet_switch_and_no_population_effect(self): with CudaContext(0) as ctx: for block in ((32, 40), (16, 20), (8, 10)): - with FixedPatchStepper(CFG, BOUNDS, context=ctx, fine_block=block, - fine_objects=[circle()], jets=[jet()], observe_raw_exchange=True) as measured, \ - FixedPatchStepper(CFG, BOUNDS, context=ctx, fine_block=block, - fine_objects=[circle()], jets=[jet()]) as plain: + with FixedPatchStepper(CFG, context=ctx, **fine(block), observe_raw_exchange=True) as measured, \ + FixedPatchStepper(CFG, context=ctx, **fine(block)) as plain: arrays = [state(l.shape) for l in measured._levels] measured.initialize(*arrays) plain.initialize(*arrays) @@ -146,9 +150,8 @@ class RawExchangeGPU(unittest.TestCase): """Same fine resolution/initial data with dense storage: a numerical reference for cut-link rows, not a uniform-whole-domain convergence study.""" with CudaContext(0) as ctx: - with FixedPatchStepper(CFG, BOUNDS, context=ctx, fine_objects=[circle()], jets=[jet()]) as dense, \ - FixedPatchStepper(CFG, BOUNDS, context=ctx, fine_block=(16, 20), - fine_objects=[circle()], jets=[jet()], observe_raw_exchange=True) as blocked: + with FixedPatchStepper(CFG, context=ctx, **fine(None)) as dense, \ + FixedPatchStepper(CFG, context=ctx, **fine((16, 20)), observe_raw_exchange=True) as blocked: arrays = [state(l.shape) for l in blocked._levels] dense.initialize(*arrays) blocked.initialize(*arrays) @@ -229,8 +232,7 @@ class RawExchangeGPU(unittest.TestCase): layout = BlockLayout2D.build(48, 64, 8, 8) with CudaContext(0) as ctx: with PeriodicBlockStepper(fine_cfg, layout, context=ctx, objects=[obj]) as uniform, \ - FixedPatchStepper(CFG, BOUNDS, context=ctx, fine_block=(16, 20), - fine_objects=[circle()], jets=[jet()], observe_raw_exchange=True) as amr: + FixedPatchStepper(CFG, context=ctx, **fine((16, 20)), observe_raw_exchange=True) as amr: amr.initialize(*(state(l.shape) for l in amr._levels)) uniform.initialize(state((9, 48, 64))) b = amr._level_boundaries[1] diff --git a/tests/validation/multigrid/test_refinement_jets.py b/tests/validation/multigrid/test_refinement_jets.py index 485332b..7ed275b 100644 --- a/tests/validation/multigrid/test_refinement_jets.py +++ b/tests/validation/multigrid/test_refinement_jets.py @@ -41,8 +41,9 @@ def mocked(objects, jets, fine_block): patch.object(compiler, "load_module", return_value=module), \ patch.object(cuda, "mem_alloc", side_effect=lambda size: Mock()), \ patch.object(cuda, "memcpy_htod", htod): - backend = FixedPatchStepper(config("periodic"), BOUNDS, context=context, - fine_objects=objects, fine_block=fine_block, jets=jets) + backend = FixedPatchStepper(config("periodic"), context=context, refinements=[BOUNDS], + level_blocks=[None, fine_block], level_objects=[(), tuple(objects)], + level_jets=[(), tuple(jets)]) return backend, htod @@ -149,8 +150,9 @@ class JetStepperCPU(unittest.TestCase): def test_jet_overlapping_legacy_aperture_rejected_before_cuda(self): with patch.object(cuda, "Stream", side_effect=AssertionError("CUDA touched")): with self.assertRaisesRegex(ValueError, "SurfaceActuation"): - FixedPatchStepper(config("periodic"), BOUNDS, context=Mock(), - fine_objects=[circle(actuation(SPEED))], jets=[jet()]) + FixedPatchStepper(config("periodic"), context=Mock(), refinements=[BOUNDS], + level_objects=[(), (circle(actuation(SPEED)),)], + level_jets=[(), (jet(),)]) def run(mode, fine_block, *, objects, jets, switch=None): @@ -158,8 +160,9 @@ def run(mode, fine_block, *, objects, jets, switch=None): cfg = config(mode) patch_ = FixedPatch2D.from_config(cfg, BOUNDS) with CudaContext(0) as context, FixedPatchStepper( - cfg, BOUNDS, context=context, coarse_boundary=mode, fine_objects=objects, - fine_block=fine_block, jets=jets) as backend: + cfg, context=context, coarse_boundary=mode, refinements=[BOUNDS], + level_blocks=[None, fine_block], level_objects=[(), tuple(objects)], + level_jets=[(), tuple(jets)]) as backend: backend.initialize(state(NY, NX, 1), state(*patch_.fine_shape, 2)) if switch is None: backend.step(STEPS)