Skip to content

Vectorize MALI mesh flood-fill extrapolation for large-mesh speedup - #753

Open
trhille wants to merge 1 commit into
MPAS-Dev:masterfrom
trhille:landice/speed_up_extrapoaltion
Open

Vectorize MALI mesh flood-fill extrapolation for large-mesh speedup#753
trhille wants to merge 1 commit into
MPAS-Dev:masterfrom
trhille:landice/speed_up_extrapoaltion

Conversation

@trhille

@trhille trhille commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

The per-cell Python neighbor loop used to extrapolate beta/muFriction/ stiffnessFactor into undefined regions is O(rings x remaining-empty-cells) and slow on large meshes. Replace it with a shared extrapolate_into_mask() helper that processes only the active BFS frontier each ring using vectorized numpy neighbor reductions, preserving the same min/idw/value semantics. Also vectorize the one-time grounded-neighbor dilation in extrapolate_variable.py.

On an 829k-cell GIS mesh (muFriction grounded-mask case) this is ~107x faster for min (68.2s -> 0.64s, bitwise identical) and ~61x for idw (81.2s -> 1.32s, identical to 4e-15 sum-order roundoff). The new code also terminates cleanly on voids disconnected from any valid data, which the original loop could not.

The per-cell Python neighbor loop used to extrapolate beta/muFriction/
stiffnessFactor into undefined regions is O(rings x remaining-empty-cells)
and slow on large meshes. Replace it with a shared extrapolate_into_mask()
helper that processes only the active BFS frontier each ring using
vectorized numpy neighbor reductions, preserving the same min/idw/value
semantics. Also vectorize the one-time grounded-neighbor dilation in
extrapolate_variable.py.

On an 829k-cell GIS mesh (muFriction grounded-mask case) this is ~107x
faster for min (68.2s -> 0.64s, bitwise identical) and ~61x for idw
(81.2s -> 1.32s, identical to 4e-15 sum-order roundoff). The new code also
terminates cleanly on voids disconnected from any valid data, which the
original loop could not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant