Repository navigation
Projecting a discontinuous field to a continuous one averages the cells at a node (#905) - #973
Conversation
…he cells at a node project_to_degree (and project_to_vertices and write_vertices_to_viewer, which call it) returned each node value of a discontinuous variable times the number of cells meeting there: the interpolation matrix gives a continuous node shared by k cells one copy of each cell's interpolant, in different source columns, so its row summed to k (2 to 7 at P1 vertices). For a discontinuous source each row is now divided by its sum, which averages the cells. A continuous source's rows already sum to 1 and the matrix is left untouched. test_0005_project_discontinuous_to_continuous (tier B): a linear DG1 field projects to its exact P1 values and a DG0 constant to the constant (both fail on development eddab70); a continuous P2 source projects exactly as before. The XDMF and save/load tests pass. Underworld development team with AI support from Claude Code
Adversarial review of #973Verdict: ready with the changes below; no defect found in the fix. Head 0168c2d, base eddab70, np 1, 2, 3, 4 and 8 through the supervisor. Findings
Attacks that failed
Issues#905: fixed by this PR for its stated reach, with finding 3's caveat. None else found in the area. A rank with no cells worked here, which depends on #902's interpolator; #902 itself was not checked. Merge conditions
Could not testThe new test is serial, so CI's reach on the parallel behaviour rests on probes run by hand under Underworld development team with AI support from Claude Code |
… cases From hyperion's review of #973: - The row scaling applies only when the target is continuous. A discontinuous target's nodes each lie in one cell, and scaling moved a DG-to-DG projection by up to 2e-15, enough to change an XDMF dataset in the last bit. - test_0005 adds a DG0 field with a different value in every cell, whose projection must be the unweighted mean of the cells at each node (a linear or constant field cannot tell a full average from a partial one), and a vector DG1 field. Both fail on development; all five pass here, with test_0005_xdmf_dg1. - The docstring says the result at a shared node is the cells' unweighted mean. Underworld development team with AI support from Claude Code
Final word on #973 at b8399ce: readyAll three merge conditions from the review are met, and CI is green on this head. The fix itself is unchanged.
One note, not a condition. The new per-cell test fails if run under Underworld development team with AI support from Claude Code |
Projecting a discontinuous field to a continuous one averages the cells that meet at a node, instead of summing them (#905).
The bug
uw.function.project_to_degree(var, 1, continuous=True)on a discontinuous variable returned each node value multiplied by the number of cells meeting at that node. That is 2 to 7 times the value at P1 vertices.project_to_verticesandfield_projection.write_vertices_to_viewercall it, so they did the same. The interpolation matrix gives a continuous node shared bykcells one copy of each cell's interpolant, in different source columns, so its row summed tok.The XDMF writer projects a discontinuous field to DG0, so it was not affected.
The change
For a discontinuous source, each row of the interpolation matrix is divided by its sum. Each cell's rows sum to 1, so this averages the cells meeting at the node. A continuous source's rows already sum to 1, and its matrix is left untouched, so those results are bit-for-bit as before.
Tests
tests/test_0005_project_discontinuous_to_continuous.py(tier B, shard 4'stest_00[0-4]*batch):project_to_verticesagrees exactly;On development eddab70 the first two fail and the third passes. On this branch all three pass. The XDMF and save/load tests (test_0003, test_0005_xdmf_*) give 35 passed.
Issues
Underworld development team with AI support from Claude Code