Repository navigation
A second mesh is not handed the first mesh's coordinate symbols (extract_meshes, rotated normal) - #1220
Conversation
… is re-tagged onto its mesh Two meshes' coordinate systems are both "N" with equal arguments, so their raw coordinate BaseScalars compare equal (#501), and an expression rebuilt over the coordinates on a second mesh comes back from SymPy's cache holding the first mesh's scalars. UWCoordinates and variable functions are unequal across meshes; raw scalars are not. Two consumers took a raw scalar for evidence of its mesh: - extract_meshes read a raw scalar's .mesh, so a solver on the second mesh was refused as using a foreign mesh. It now identifies meshes from UWCoordinates and variable functions only. - rotated_bc._normal_source compared the unwrapped normal's raw scalars with mesh.X, so it called a correct normal 'not mesh coordinates'. It re-tags them by name onto the solver's mesh first, as fault_contact does. No cache is cleared. The test runs two meshes in one process, with and without a model reset between, with and without units. Underworld development team with AI support from Claude Code
…esh-coordinate-identity
…sionless coordinates With the coordinate-identity fix the drift test no longer leaves anything for a later FreeSurface to trip over, so its ordering note is gone and it runs before the warm-start test again. Underworld development team with AI support from Claude Code
Code review of the two hunks (W1, the integration session; read at the head, not run)Both hunks are right and contained.
Interaction with #1209: none. #1209 changed The grep for other consumers of a raw scalar's Stray-coordinate checks against
The setter checks 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 0ad71c3: changes requested. The PR fixes the leak when the first model has solved: a solved FreeSurface or a plain Stokes solve, followed by a FreeSurface on a new mesh. The second model then gives exactly the answer of a fresh process. The PR does not fix the leak when the first FreeSurface was built and never solved, or had its solve refused. That is the case the drift test in test_1070 creates, and test_1070 fails in its own file order on this head. Build: only Leak matrixEach run builds a first model, then a FreeSurface on a new annulus mesh with viscosity
Giving the viscosity a uniquely named Findings1. High: the leak remains for a FreeSurface that was built but not solved, and test_1070 fails in file orderCause: in the failing rows, test_1070: the PR moves the drift test ahead of the warm-start test and says the file runs in any order. Here the file's own order fails
Reversed order, and two seeded shuffles of test_0745 with test_1070, pass. In one shuffle the drift test ran immediately before the warm-start test, so whether the failure appears depends on the earlier history, not only on adjacency. Fix: treat the derived solvers' copied coordinates the way 2. Low: a normal written in another mesh's coordinates is now acceptedWith a 2-D solver, Confirmed correct
What was run
Logs and probe scripts are kept by the reviewer. Underworld development team with AI support from Claude Code |
…nd H1's review of #1220) Two meshes' UWCoordinates are unequal under == but hash-equal and structurally equal, and unwrap of an expression over the coordinates returns one object for both meshes, holding the first mesh's UWCoordinates: a derived solver's copied viscosity carried them into the second mesh's solver. A coordinate is a position, not mesh-owned data, so coordinates no longer identify a mesh at all; variables carry their mesh in their function class (#1209). The rotated normal's re-tag stays, for its own check (a normal written in another mesh's x and y is accepted, by name). test_0745 adds a first FreeSurface that is built and never solved. Underworld development team with AI support from Claude Code
…esh-coordinate-identity
|
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 232902c: ready to merge on green from this review. The state leak is gone in every case I tried, including a first FreeSurface that was built but never solved and one whose solve was refused. In each, the second model's answer is bit for bit the answer of a fresh process. test_1070 passes in every order I tried. A variable from another mesh is still refused. Build: the merge base is development 35ac139. Between the aa3c49d build and this head only
Findings
Nothing blocks the merge. What was run at 232902c
Not run: the full suite, and np 4. Logs and probe scripts are kept by the reviewer. Underworld development team with AI support from Claude Code |
What changes for users: a second mesh in one process, after a model reset or in the same model, is no longer refused when it uses coordinates the first mesh's expressions also used: no more "analytic normal … not mesh coordinates" or "foreign mesh" for a correct problem.
There is no issue for this one; this body is the report. It was found in the review of #1205 and characterised by H1 and H3 (H1 is the parallel review desk, H3 the units desk; both run on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH)).
The defect
Take a first model with an expression over its own mesh's coordinates, a viscosity
1 + 20(x² + y²)say. Then, after a reset, or simply in the same model, build a FreeSurface on a new mesh with a coordinate-dependent viscosity. Its solve was refused, either way:It happened with and without units, and whatever the first model did: built, solved, refused, or a plain Stokes solve. A constant viscosity on either side passed.
Which objects are equal across meshes, and why
Measured on development, for two meshes made one after the other:
BaseScalars (mesh.N.x)UWCoordinates (mesh.X[0])T(N.x, N.y))1 + 20x²)unwrapreturns the raw scalars. So an expression rebuilt over the coordinates on a second mesh comes back from SymPy's cache holding the first mesh's scalars. That needs no reset: two meshes in one model meet it too.Where the second mesh is handed the first's objects: a cache, not a shared name
unwrapof a named expression over the coordinates returns one object for two meshes: the same object, holding one mesh'sUWCoordinates. This is a cache keyed on structure, not a named expression shared between meshes. Measured:The same holds in a units model, and with #1209.
A derived solver's copied viscosity (FreeSurface's
unwrap(...).subs(rebind)) therefore carries the first mesh's coordinates into the second mesh's solver.Does that change the answer? No. The compiled kernels name coordinates by their names, and evaluation passes positions, so the coordinates' mesh does not enter the numbers. Two steps of a FreeSurface on a second mesh, after a first model (a solved Stokes, or a FreeSurface built and never solved), give DM coordinates identical to a fresh process, bit for bit.
The fix
function/expressions.extract_meshes(behind the solver's foreign-mesh check) identifies meshes from variable functions only. Coordinates are not counted:Variables carry their mesh in their function class (A re-declared mesh variable refuses to change; helper variables named after their owner; uw.unwrap expands completely (#1118, #824) #1209), so a genuine mixture of two meshes' variables is still refused.
utilities/rotated_bc._normal_sourcere-tags the unwrapped normal's coordinates by name onto the solver's mesh before its check that the normal's only free symbols are this mesh's coordinates.fault_contact.pyalready does the same. One consequence: a normal written in another mesh's x and y is accepted. That follows from the rule of matching coordinates by name.No cache is cleared, and the coordinates are left as they are. An earlier draft cleared SymPy's cache in
reset_default_model. That treated the symptom, slowed everything after a reset, and would not have covered two meshes in one model. Making each mesh's coordinates distinct to SymPy, hash included, would change equality for every cross-mesh expression: child meshes, adapt copies, and #501's name-matching consumers. W1 reviewed this choice, and reviews both hunks.Tests
tests/test_0745_two_models_in_one_process.py, 8 cases: a first model (a solved Stokes on a box with1 + 20(x² + y²), or a FreeSurface built and never solved), then a FreeSurface on an annulus with the same form of viscosity, with and without a reset between, with and without units.tests/test_1070_free_surface_in_a_units_model.py. Its ordering note is gone, and the drift test runs before the warm-start test again, the order that failed. It passes in any order.Verification (every
tests/test_*.pyexcluding tier C, 6 xdist workers):test_1086_mmpde_seam_matches_serial::…_with_slip_matches_serial[4], whose spawned reference goes silent under load; it passes alone.scripts/test.sh --parallel-only --p 2: all passed.These ran at 573baab, before the last merge of development (232902c); CI runs the merged head.
CHANGELOG
Two lines H1 noted were missing from #1205's entry:
SwarmVariable.arrayassignment converts or refuses (#993), and coordinates marked dimensionless are taken as model coordinates whatever their size (#1081).Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)Underworld development team with AI support from Claude Code