Skip to content

Use compact offsets+indices neighbor-list representation and compressed index type#199

Open
AhmedSalih3d wants to merge 2 commits into
BeforeLidDrivenCavityExamplefrom
codex/optimize-neighborloop-algorithm-uhz8gq
Open

Use compact offsets+indices neighbor-list representation and compressed index type#199
AhmedSalih3d wants to merge 2 commits into
BeforeLidDrivenCavityExamplefrom
codex/optimize-neighborloop-algorithm-uhz8gq

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Replace per-cell dynamic Vector{Int} neighbor lists with a contiguous offsets+indices representation to reduce allocations and improve cache locality and iteration speed.
  • Use a compressed integer index type for neighbor references and add a CellIndexMap for fast cell lookup in boundary/MDBC routines.

Description

  • Introduce NeighborCellIndexType = UInt32 and helper CompressIndex for safe index compression and export the new type via SPHNeighborList imports.
  • Add a new CSR-like builder BuildNeighborCellLists!(NeighborCellListOffsets, NeighborCellListIndices, FullStencil, UniqueCellsView, ParticleRanges, CellIndexMap) and an overload that fills a CellIndexMap for the legacy API, while retaining the original BuildNeighborCellLists! behavior where needed.
  • Replace NeighborCellLists usages with NeighborCellListOffsets/NeighborCellListIndices and update neighbor iteration sites in SPHCellList (NeighborLoopPerParticle!, SimulationLoop, MDBC flow) to iterate by cursor over offsets and to Int-cast compressed indices when needed.
  • Change MDBC neighbor lookup to use an inline GhostCellIndex function and CellIndexMap get lookups instead of FindCellIndex, and update ApplyMDBCBeforeHalf! to pass the new arguments; update ComputeCellNeighborCounts to support the new offsets+indices layout.
  • Update allocation/initialization sites in FinalizeSimulationOutput! to create NeighborCellListOffsets, NeighborCellListIndices, and NeighborCellIndexMap and wire them through the simulation loop and neighbor-list rebuilds.

Testing

  • Ran the package test suite and the repository's simulation smoke test; all automated tests completed successfully.

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