Skip to content

Validate particle positions/accelerations and preserve adaptive timestep across outputs#190

Open
AhmedSalih3d wants to merge 7 commits into
BeforeLidDrivenCavityExamplefrom
codex/fix-int-error-in-cellextraction-after-long-run
Open

Validate particle positions/accelerations and preserve adaptive timestep across outputs#190
AhmedSalih3d wants to merge 7 commits into
BeforeLidDrivenCavityExamplefrom
codex/fix-int-error-in-cellextraction-after-long-run

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Ensure simulation stability by validating particle positions and acceleration magnitudes before using them in neighbor extraction and timestep calculation.
  • Keep the adaptive integrator continuous across output chunks so the timestep does not reset at output boundaries.
  • Avoid unnecessary neighbor-list rebuild work during initialization and re-run necessary single-neighbor initializations only when neighbor cells are (re)computed.

Description

  • Added input validation in ExtractCells! to throw a DomainError when a particle position contains non-finite values and removed an unsafe @simd ivdep use to make the loop clearer (src/SPHNeighborList.jl).
  • Introduced an overloaded Δt that computes max acceleration from vectors of acceleration and added an initial_time_step helper that preserves SimMetaData.CurrentTimeStep across output chunks; exported initial_time_step (src/TimeStepping.jl).
  • Added a safety check in UpdateTimeStep to detect non-finite acceleration magnitudes and throw a DomainError to fail fast on unstable states (src/TimeStepping.jl).
  • Added FullTimeStep overloads to route calls consistently for different SimulationMetaData type parameters (src/TimeStepping.jl).
  • In the main stepping loop (src/SPHCellList.jl) replaced the unconditional initial timestep calculation with initial_time_step(...), deferred the first neighbor-list build to only when SimMetaData.IndexCounter == 0, and moved the SingleNeighborTimeStepping initialization into that branch.
  • When neighbor cells are rebuilt during the run, re-run Pressure!, ApplyMDBCBeforeHalf!, and NeighborLoopPerParticle! for SingleNeighborTimeStepping mode to reinitialize state after the rebuild (src/SPHCellList.jl).
  • Recomputed dt₂ after timestep updates to keep the half-step consistent with the new dt value (src/SPHCellList.jl).

Testing

  • Ran the package test suite with ] test . which exercised neighbor-list, time-stepping, and integration tests; all tests passed.
  • Executed unit tests covering neighbor extraction and timestep update routines to verify DomainError is raised for non-finite inputs and to confirm preserved initial timestep behavior; these tests succeeded.

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