Fix IndexError in _pic_swarm_in_mesh on MPI ranks with empty cell partition#5078
Conversation
leo-collins
left a comment
There was a problem hiding this comment.
I think this is good. The same thing probably happens for the extruded case too - can you add a test for this (and a fix if necessary)?
|
Thanks @leo-collins for the quick review. I have applied all the inline suggestions and added the test and fix for the extruded meshes. |
|
Should this be going into |
If this is a question for me, I am not sure, I would go with your recommendation. My understanding from the contribution guide is that bug fixes generally go into release, but I am happy to follow whatever is preferred here. |
|
Unless this is somehow relying on features that only exist in |
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
aa18a4d to
59d9202
Compare
|
Done — rebased onto release and retargeted the PR! |
|
Thanks! |
Description
Fixes #5077.
In
_pic_swarm_in_mesh,parent_cell_nums_localcontains-1sentinels for points notowned by the current rank. On ranks with an empty cell partition,
cell_closurehas shape(0, k)and NumPy rejects-1as an axis-0 index, causing anIndexErrorwheninterpolating from a
Submeshonto its parent mesh in parallel.Fix: index
cell_closureonly onvisible_idxs(the non-sentinel entries), pre-fillingthe rest with
-1. The same issue exists in the extruded branch:_parent_extrusion_numberingfloor-divides
parent_cell_nums_local, and-1 // N == -1in Python, so sentinels passthrough into
base_parent_cell_numsand cause the same crash. Both branches are fixed.Two regression tests added in
tests/firedrake/submesh/test_submesh_interpolate.pyusing8 MPI ranks:
test_submesh_interpolate_3Dcell_2Dfacet_empty_rank_8_processes: interpolates from aSubmeshof the x=1 face ofUnitCubeMesh(2, 2, 2)onto the parent mesh.test_submesh_interpolate_3Dcell_extruded_empty_rank_8_processes: interpolates fromExtrudedMesh(UnitSquareMesh(1, 1), layers=3)(6 cells) onto aUnitCubeMesh(2, 2, 2),guaranteeing at least two ranks own zero extruded cells.