Skip to content

Decouple output scheduling from solver state#191

Open
AhmedSalih3d wants to merge 2 commits into
BeforeLidDrivenCavityExamplefrom
codex/refactor-simulation-output-control-flow
Open

Decouple output scheduling from solver state#191
AhmedSalih3d wants to merge 2 commits into
BeforeLidDrivenCavityExamplefrom
codex/refactor-simulation-output-control-flow

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Output boundaries reset local integration state which caused neighbor-list rebuilds and in-place particle sorting to be triggered by OutputTimes, changing physics outcomes.
  • The solver must keep adaptive timestep and neighbor-rebuild displacement independent of the passive output scheduler so snapshots do not affect solver sequencing.

Description

  • Added a persistent runtime state SimulationRuntimeState holding Δx, dt, and an initialization flag, and threaded it into SimulationLoop to avoid resetting these when the loop is re-entered (src/SPHCellList.jl).
  • Changed SimulationLoop signature to accept Runtime::SimulationRuntimeState{FloatType} and updated the loop to read/write Runtime.Δx and Runtime.dt, and to perform the initial neighbor-list build only once.
  • Initialized the Runtime instance in RunSimulation and passed it into SimulationLoop so neighbor-list rebuild timing and adaptive dt persist across outputs (src/SPHCellList.jl).
  • Fixed next_output_time(times::AbstractVector, ...) indexing to use <= length(times) so the final configured output time is reachable (src/TimeStepping.jl).
  • Restored an allocation-free Δt method that accepts (Position, Velocity, Acceleration, SimulationConstants, SPHKernel) and computes the max acceleration from the acceleration vector for compatibility with existing tests (src/TimeStepping.jl).

Testing

  • Ran julia --project=. -e 'using SPHExample' which precompiled and loaded the package successfully.
  • Ran julia --project=. -e 'using Pkg; Pkg.test()'; the time stepping tests passed, but the isolated particle test errored due to a FullTimeStep signature mismatch in the test harness (existing test calls FullTimeStep with the older 7-argument signature), so the full test suite did not complete successfully.
  • The changes are confined to src/SPHCellList.jl and src/TimeStepping.jl and preserve the intended behaviour of keeping OutputTimes passive with respect to solver state.

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