"""Depth-2 twin of the nested shear preset (opt-in twin_shear_n128). Same two L0->L1 boxes as shear_nested, no L2. Four fresh cases: U128, U256 (finest control = 2N), constant R128 depth 2, projected R128 depth 2; same wave, phase, Re100/U=0.03, initialization, times, eps(root N), limits, floors. Twin vs nested measures the effect of adding this nested L2 refinement. Removing L2 also changes the finest spacing and refined volume, so the contrast does not isolate abstract depth. Physics is the unchanged depth-2, 2N-control shear_wave.assess; shear_nested.py stays byte-identical. """ import numpy as np import shear_nested as nested ROOT_N = nested.ROOT_N DEPTH = 2 FINEST_FACTOR = 2 REFINEMENTS = [nested.REFINEMENTS[0]] # L0 -> L1 only, root coordinates CASES = ((100, ROOT_N, 1, "constant"), (100, FINEST_FACTOR * ROOT_N, 1, "constant"), (100, ROOT_N, DEPTH, "constant"), (100, ROOT_N, DEPTH, "projected_linear")) ROOT_STEPS = 16 * ROOT_N LEAVES = [7936, 33792] HOPS = [ROOT_STEPS * 2**level for level in range(DEPTH)] # [2048, 4096] WORK = sum(c * h for c, h in zip(LEAVES, HOPS)) # 154664960 per refined case NU = nested.NU[:DEPTH] TAU = nested.TAU[:DEPTH] def leaf_masks(): """Independent numpy leaf masks (root complement, full L1 boxes).""" child = np.zeros((ROOT_N, ROOT_N), bool) for x0, y0, x1, y1 in REFINEMENTS[0]: child[y0:y1, x0:x1] = True return [~child, np.kron(child, np.ones((2, 2), bool))]