Skip to content

Keep support arrays aligned on neighbor rebuild#193

Open
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/make-neighbor-list-rebuilding-safe
Open

Keep support arrays aligned on neighbor rebuild#193
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/make-neighbor-list-rebuilding-safe

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Rebuilding neighbor/cell lists sorts SimParticles in place which can desynchronize separate per-particle work arrays (e.g. Positionₙ⁺, Velocityₙ⁺, ρₙ⁺, dρdtI, ∇Cᵢ, ∇◌rᵢ) and corrupt the integrator when ShouldRebuild is triggered frequently.
  • The intent is to make the neighbor-list rebuild path safe when rebuilds occur every iteration by keeping auxiliary arrays indexed consistently with the sorted particle array.

Description

  • Added UpdateNeighborsAligned! which computes the cell-sort permutation, applies it to Particles, and then applies the same permutation to any provided aligned per-particle arrays before rebuilding cell ranges (new functions in src/SPHNeighborList.jl).
  • Factored the cell-range reconstruction into RebuildCellRanges! and updated UpdateNeighbors! to reuse that helper so the legacy path is preserved.
  • Replaced the initial and conditional neighbor-rebuild calls in the simulation loop to use UpdateNeighborsAligned!, passing dρdtI, Velocityₙ⁺, Positionₙ⁺, ρₙ⁺, ∇Cᵢ, and ∇◌rᵢ so these support arrays stay aligned with SimParticles (src/SPHCellList.jl).
  • Exported the new API symbol and added a regression test aligned neighbor rebuild to test/runtests.jl; tests were also updated to use current Δt and FullTimeStep argument forms.

Testing

  • Ran the package test suite with julia --project=. -e 'using Pkg; Pkg.test()', and the full test suite passed.
  • The new regression test verifies that an auxiliary array is reordered consistently with particle IDs after UpdateNeighborsAligned! and succeeded under test.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant