Skip to content

Optimize neighbor list scratch usage#131

Open
AhmedSalih3d wants to merge 2 commits intocodex/refactor-to-avoid-if-statementfrom
codex/improve-neighborlist-code
Open

Optimize neighbor list scratch usage#131
AhmedSalih3d wants to merge 2 commits intocodex/refactor-to-avoid-if-statementfrom
codex/improve-neighborlist-code

Conversation

@AhmedSalih3d
Copy link
Owner

Motivation

  • Reduce per-iteration allocations and redundant checks when building neighbor lists and producing grid cell statistics by reusing scratch buffers and precomputing cell occupancy.

Description

  • Add NeighborListScratch (fields CellCounts, CellOccupied, NeighborCounts) and ResizeNeighborListScratch! to hold reusable cell/neighbor buffers in src/SPHNeighborList.jl.
  • Add in-place helpers UpdateCellCounts!, ComputeCellParticleCounts!, and ComputeCellNeighborCounts!, and adapt ComputeCellParticleCounts/ComputeCellNeighborCounts to call the in-place variants in src/SPHNeighborList.jl.
  • Change BuildNeighborCellLists! to accept a CellOccupied array and use occupancy checks (and sizehint!) instead of reading particle ranges for empty-cell checks in src/SPHNeighborList.jl.
  • Wire a NeighborScratch instance into the simulation: create NeighborScratch = NeighborListScratch() in RunSimulation, call UpdateCellCounts! before BuildNeighborCellLists!, and pass NeighborScratch through SimulationLoop to reuse buffers for constructing neighbor lists and preparing VTK grid outputs in src/SPHCellList.jl.
  • Re-export the new types and functions from SPHNeighborList and update the top-level SPHExample.jl exports accordingly.

Testing

  • No automated tests were run on these changes.

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