Skip to content

Support Float32 simulation paths#184

Open
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/enable-float32-functionality
Open

Support Float32 simulation paths#184
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/enable-float32-functionality

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Enable the library to run simulations and helper functions with Float32 without accidental promotion to Float64 or reinterpret casts that fail for smaller floats.
  • Preserve element types when converting 2D SVectors to 3D so generated vectors keep the same float precision.
  • Make kernel/tensile helper and timestep utilities accept particle-array inputs and return type-consistent scalar results for Float32.

Description

  • Replace the Float64-only reinterpret trick in Estimate7thRoot with a type-generic implementation and add an overload for Real, and update InverseHydrostaticEquationOfState to be type-preserving. (src/SimulationEquations.jl)
  • Preserve element types in to_3d by constructing SVector{3,eltype(v)} and using zero(eltype(v)) for the z-component. (src/AuxiliaryFunctions.jl)
  • Make the Wendland tensile correction return zero(q) so scalar q inputs (including Float32) produce a zero of the correct type. (src/SPHKernels.jl)
  • Add a convenience Δt overload that accepts particle Position, Velocity, and Acceleration vectors and computes the maximum acceleration before delegating to the scalar Δt path. (src/TimeStepping.jl)
  • Add a Float32 coverage testset exercising constants, kernel instance creation, Estimate7thRoot, InverseHydrostaticEquationOfState, tensile_correction, to_3d, and the particle-vector Δt. (test/runtests.jl)

Testing

  • Ran the package test file with julia --project=. test/runtests.jl and observed the full test suite (including the new Float32 support tests) pass. (success)
  • Executed a direct runtime smoke check with julia --project=. -e 'using SPHExample, StaticArrays; T=Float32; ...' that asserts key functions and types return Float32 values and that Δt returns a Float32 timestep. (success)
  • Attempted julia --project=. -e 'using Pkg; Pkg.test()' but the invocation stalled during temporary test-environment precompilation; the direct test file execution was used to validate changes instead. (precompilation stalled)

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