Skip to content

Localize support buffers in simulation loop#152

Open
AhmedSalih3d wants to merge 8 commits intocodex/refactor-to-avoid-if-statementfrom
codex/remove-support-data-code-structures
Open

Localize support buffers in simulation loop#152
AhmedSalih3d wants to merge 8 commits intocodex/refactor-to-avoid-if-statementfrom
codex/remove-support-data-code-structures

Conversation

@AhmedSalih3d
Copy link
Owner

Motivation

  • Reduce reliance on globally allocated support arrays by allocating per-run buffers inside the main timestep loop to better match the per-particle execution model.
  • Avoid preallocating support structures in RunSimulation so memory lifetime and initialization are colocated with the simulation loop.

Description

  • Allocate dρdtI, Velocityₙ⁺, Positionₙ⁺, ρₙ⁺, and shifting arrays inside SimulationLoop using @alloc and conditionally allocate shifting buffers when SMode is not NoShifting in src/SPHCellList.jl.
  • Remove the call to AllocateSupportDataStructures from RunSimulation and simplify the SimulationLoop parameter list so those buffers are no longer passed in.
  • Initialize the new local buffers (fill! for scalars and copyto! to prime Positionₙ⁺, Velocityₙ⁺, and ρₙ⁺) so loop logic continues to use the same temporaries as before.

Testing

  • I ran repository inspection and edit commands used during the change: ls, cat AGENTS.md, rg --files -g 'AGENTS.md', sed -n '1,260p' src/SPHCellList.jl, sed -n '260,620p' src/SPHCellList.jl, rg -n "RunSimulation|SimulationLoop|HalfTimeStep|FullTimeStep|AllocateSupportDataStructures" src/SPHCellList.jl src/PreProcess.jl src/TimeStepping.jl, sed -n '640,940p' src/SPHCellList.jl, sed -n '1,260p' src/PreProcess.jl, sed -n '1,220p' src/TimeStepping.jl, rg -n "DensityEpsi" -n src, sed -n '1,120p' src/SimulationEquations.jl, rg -n "AllocateSupportDataStructures" -n src, rg -n "SimulationLoop\\(" src/SPHCellList.jl, git status --short, and git diff, and committed the change.
  • No automated test suite or runtime tests were executed for this change.

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