Repository navigation
Units frame defects: FreeSurface, parallel refinement and semi-Lagrangian transfers, swarm .array, coordinate label, and deform's plain arrays (#993, #992, #991, #979, #998, #1081) - #1205
Conversation
The setter wrote a value's magnitude straight into .data, so 500 K stored 500 where 0.5 is right. A unit-aware value is now converted and a plain array is refused as ambiguous, as for MeshVariable. Underworld development team with AI support from Claude Code
…992) At np > 1 the record read the dimensional var.array, stripped its units and stored the magnitude as non-dimensional: 500 at np 2 for a field holding 0.5. It now reads var.data, for scalar and vector fields; other layouts fall back to evaluate. Underworld development team with AI support from Claude Code
#1003 moved both parallel sites to coords_nd and the storage layout, so the refusal #1002 added is no longer needed: the transfers are exact for every shape at np 2 and 3. test_0785's refusal tests now assert exactness, over scalar, vector, 2x3 MATRIX, TENSOR and SYM_TENSOR. Underworld development team with AI support from Claude Code
X.coords holds SI metres, from the length scale, but X.units returned mesh.units (kilometres for a reference length in km), a factor-1000 label mismatch. mesh.units stays the unit output is written in. Underworld development team with AI support from Claude Code
…del (#998) It read mesh nodes and field nodes from .coords, which is in metres in a units model, against DM and recovery positions in model units: the first solve lost every trace-mass weight, and write_boundary_scalar_field matched no key, so the recovered topography was zero. Node and field coordinates now come from the model-unit frame (mesh._coords, coords_nd), and estimate_dt converts a dimensional solver step to model time instead of taking float() of seconds. Two steps of the test_1070 annulus with and without reference quantities give the same DM coordinates to 1e-8. Underworld development team with AI support from Claude Code
#993) The old setter reshaped rows, so (N, 2, 1) into a vector viewed as (N, 1, 2) worked (test_0504_projections); writing through the view needs the exact shape. Such shapes hold the entries in the same order and are reshaped first. Underworld development team with AI support from Claude Code
…ts model now requires Underworld development team with AI support from Claude Code
…ce copies constant parameters with their units #1081: in a model with reference quantities a plain array is ambiguous (metres or model units), and is refused whatever its values, as a bare number for a dimensional parameter is. The size guess, which failed when the length scale is near 1, is gone. Coordinates with units, or model coordinates marked units="dimensionless", are accepted. FreeSurface passes its model-unit target marked so. test_0770 (serial and parallel) and test_0785 move with the rule. FreeSurface's helper solvers copied the free solve's parameters through unwrap, which turns a quantity into a bare number; a constant is now copied as its expression. Its internal smoother and composition defaults run in the internal context. Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Verdict on head c66af42: changes requested. The six fixes do what they say, and each issue's reproducer passes on this branch and fails on development at the rank counts in the table below, including an empty rank for the refinement transfers. Two FreeSurface defects should be fixed before merge. Both can only happen now that FreeSurface runs in a units model, and both are small fixes: the drift guard is blind to constant parameters (M1), and the warm start copies dimensional velocity and pressure as model values (M2). The other findings are about test strength and documentation. Per-issue resultAll runs used development fafbecb against this head, through a Python overlay on one compiled build. Only
FindingsM1 (medium): in a units model, the FreeSurface drift guard does not catch a constant re-assigned after construction
The PR makes a constant parameter live: the helper solvers hold the free solve's own expression. So re-assigning one constant to another is tracked, and that part is right (see "Confirmed correct"). But an expression is still copied as a rebound snapshot. If the user later re-assigns it to a constant, the helper solves keep the old expression, and nothing refuses the solve. Failure case: the test_1070 annulus, one
Fix: guard the check the same way as the copy. Compare the unwrapped values when the unwrapped value has no The same guard reports the opposite case correctly. Build with a constant, then re-assign a strain-rate-dependent expression: the live copy then carries the free solve's velocity atoms, and the guard raises, as it should. M2 (medium): in a units model, the consistent-solve warm start writes dimensional velocity and pressure as model values
Failure case: a units model, a velocity in Measured effect: test_1070's two steps, with the free solve's velocity in This is one of the "about 15 sites" from #998 that the PR leaves as it was. test_1070 does not reach it, because its fields have no units. Fix: copy L1 (low): test_0785's refinement pair does not refine
With M = 400 (child 4 times finer), I measured the same exactness, ≤ 3.6e-15, at np 1, 2 and 4 and with an empty rank at np 2, 3 and 4. A metric like that would make the test show what its name says. The 1e-9 tolerance is meaningful either way: values are O(1), and the old errors were O(1) to O(1e3). L2 (low): test_0992 covers the scalar onlyThe PR adds a VECTOR branch to the direct copy, and sends MATRIX, TENSOR and SYM_TENSOR components to L3 (low): API changes with no changelog entryThere are two API changes:
Both are deliberate and the error messages are clear. Scripts in units models will meet them, so they deserve an entry in Related: test_0770 no longer asserts that a Notes (no action needed)
Confirmed correct
What was run
Logs and probe scripts are kept by the reviewer. Underworld development team with AI support from Claude Code |
…tant, the warm start copies stored values (H1's review of #1205) - _check_derived_solvers_match called .subs on the plain number a constant unwraps to in a units model, and a bare except hid it: a re-assigned viscosity was not caught and the solve ran on the stale one. Constants are compared as they are, and the swallow is gone. - _solve_consistent warm-started V_cons and P_cons through .array, which put a velocity with units into a field without them; it copies .data, the raw variable-to-variable copy inside the non-dimensional boundary, as ddt.py does. - test_0785's refinement metric is 400 (h = 0.05), which refines; 0.1 was an h of 3.2 and refined nothing. test_0992 covers a vector. - CHANGELOG: the two API breaks of the units ruling (#1182, #1081). Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Re-check of head d2804e3: ready to merge on green from this review. M1 and M2 are fixed, and L1 to L3 are addressed. The test-order failure that the new test_1070 docstring describes is real. It is not caused by the refused solve, and it is already on development, so it should be filed on its own (below). It does not block this PR. The new commit changes only
The test-order note: a state leak, but not from the refused solve, and not new. In one process I built a first model, reset the default model, and then built a FreeSurface on a new annulus mesh whose viscosity depends on the coordinates (1 + 20 r²). The second build fails whenever the first model had a coordinate expression on its own mesh:
The second build succeeds:
This holds with and without reference quantities, and on development fafbecb in a model without units. So some state keyed on coordinate expressions carries across meshes; it is not left by the refused solve. In test_1070, running the drift test and then the warm-start test fails the second with the foreign-mesh error. Running the drift test after the others passes, which is the order the file uses. Suggestions:
The new warm-start test uses a radial viscosity, which is spatially variable but not nonlinear. No power-law case was run. Runs at d2804e3:
Logs and probe scripts are kept by the reviewer. Underworld development team with AI support from Claude Code |
What changes for users: in a model with reference quantities, FreeSurface runs, refinement transfers run in parallel, a parallel semi-Lagrangian history is right, assigning to a swarm variable's
.arrayconverts units,mesh.X.unitsnames the unitsmesh.X.coordscarries, andmesh.deformrefuses a plain array, which could be metres or model units.These are the units "frame" defects: places where a dimensional array lost its units and was then read as model units, or the reverse. Each comes with a test that fails on development. Runs were on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on development fafbecb merged in. #990 was fixed by #1003 and is labelled separately.
The fixes
SwarmVariable.array = valuewrote the magnitude straight into.data, so 500 K stored 500 where 0.5 is right (1000 K reference)MeshVariabledoes: a unit-aware value is converted, and a plain array is refused as ambiguoustest_0117_swarm_array_assignment_units: 6 fail on development, 6 passvar.array, stripped it and stored it as non-dimensional: 500 at np 2 for a field holding 0.5 (0.5 at np 1)var.data, for scalars and vectors; other layouts fall back toevaluateparallel/test_0992_…: fails at np 2 and 3 on development, passes at np 1, 2 and 3coords_ndand the storage layout, so the refusal is lifted: exact (< 1e-9) for scalar, vector, 2×3 MATRIX, TENSOR and SYM_TENSORparallel/test_0785_…changed (see below): 10 fail on development, 16 pass at np 2 and 3mesh.X.unitsreturnedmesh.units(km for a reference length in km) whilemesh.X.coordsholds metres: a factor-1000 label errormesh.X.unitsismeterin a units model;mesh.unitsstays the unit output is written intest_0622_coordinate_units_label: 1 fails on developmentmesh.deformguessed whether a plain array was metres or model units from its size; the guess failed when the length scale is near 1units="dimensionless", are accepted, and the size guess is gone.test_0770(serial and parallel) andparallel/test_0785updatedtest_1070annulus give the same DM coordinates with and without reference quantities, to 1e-8test_1070_free_surface_in_a_units_model: 2 fail on development#998 needed three changes, found one after another:
.coords, which is metres in a units model, and matched against DM and recovery positions in model units. They now come frommesh._coordsandcoords_nd.utilities/boundary_flux.write_boundary_scalar_fieldkeyed its nodes byfield.coordsagainst the recovery's model-unit positions. No key matched, so the recovered topography was zero, and the surface did not move. It now keys bycoords_nd.FreeSurface.estimate_dttookfloat()of the composition solver's dimensional step, which is seconds. Where that limit bound, the step was 7.6e10 where 2.4e-3 is right. The second test shows this, with the fix swapped out.FreeSurface and the bare-number ruling. The free surface copies the free solve's parameters onto its helper solvers through
unwrap, which turns a quantity into a bare number. That bare number would then be refused, and it has nothing to rebind anyway, so a constant is now copied as its expression, with its units. Its internal Laplacian smoother and its default composition diffusivity are library settings in model units, set inside the internal context of #1182. Its own target formesh.deformis passed marked as model units.#993 and an existing caller. The old setter reshaped rows, so
(N, 2, 1)written into a vector viewed as(N, 1, 2)worked, andtest_0504_projectionsrelies on it. Writing through the view needs the exact shape. Shapes that differ only by axes of length one hold the entries in the same order, so they are reshaped first. A plain array written to a swarm variable with units in a units model is now refused, as it already is for aMeshVariable. That includesv.array = v.array, because the view is not itself unit-aware: the same asMeshVariabletoday.Existing tests that changed
tests/parallel/test_0785_evaluated_values_reach_storage_parallel.py.…_refuse_under_reference_scalesand…_refuse_with_reference_quantities_and_scaling_off, pinned Mesh.remesh transfers past an empty rank, units included; global_evaluate no longer transposes #1002's guard. With the guard lifted they assert exactness instead, renamed…_are_exact_…, and the parametrisation gains vector, TENSOR and SYM_TENSOR. The guard's own function,_refuse_parallel_refinement_with_units, is removed.tests/test_0770_mesh_move_in_a_units_model.py. The "model" form, a plain array, is gone from the accepted forms. The refusal test now asserts that a plain array is refused whatever its values. Before, only an array the size of the physical domain was refused.tests/parallel/test_0770_mesh_move_in_a_units_model_parallel.py. The empty-rank move passes model coordinates marked dimensionless. Its point, that every rank returns, is unchanged.tests/test_1070_free_surface_in_a_units_model.py(new in this PR) states its parameters withmodel_units, from Units contract: evaluate refuses mixed units and far points; Stokes fields carry units (#771, #904, #881, #786, #844, #1001) #1182.Regression runs
Every
tests/test_*.py, excluding tier C, 6 xdist workers:test_1086_mmpde_seam_matches_serial::…_with_slip_matches_serial[4], whose spawned reference run goes silent under load. Run alone it passes, on this branch and on development.scripts/test.sh --parallel-only --p 2: all passed.Not touched
Solver defaults,
petsc_generic_snes_solvers,rotated_bc.py, the custom multigrid.scripts/check_test_coverage.pypasses.Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)Underworld development team with AI support from Claude Code