Skip to content

AMR: swarm migration after mesh.adapt() raises IndexError -- k-d tree rebuilt before nav_coords refresh #286

Description

@jcgraciosa

tests/test_0810_amr_swarm_migration_regression.py::test_swarm_migration_after_adapt_does_not_raise fails with:

IndexError: index 91 is out of bounds for axis 0 with size 80

Cause: in nuke_coords_and_rebuild() (discretisation_mesh.py), the k-d tree is rebuilt at line 2346, but self._nav_coords isn't refreshed until line ~2401 -- later in the same function. So the rebuild runs against a stale nav_coords, sized for the old mesh, while nav_dm already reflects the new one. Confirmed by instrumenting a live run: at rebuild time, _nav_coords.shape=(80, 2) vs. nav_dm already at 127 points.

Checked the other two caches that also read nav_coords (faces_outer/inner_control_points from #135, and boundary_face_control_points_kdtree/_sign) -- both are invalidated but rebuilt lazily on next access, after this function has already finished, so they are not affected by this ordering issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions