Skip to content

ramakarl/fluids3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fluids:
A fast, GPU-based, smooth particle hydrodynamics (SPH) fluid simulator.

Rama Hoetzlein (c) 2007-2025

👉 Project Website: https://ramakarl.com/fluids3

Fluids v.3 was the first very fast, interactive >1 million particle, Smooth Particle Hydrodynamic simulator.
This repository contains the complete history of Fluids.

🚀🚀 NEW (2025): The latest Fluids 5.0 has been published in Nov 2025!
The current version is even faster, uses the CUDA Driver API, can handle >4 million particles, uses full smart CPU/GPU pointers, buffer-based structure of arrays, integrated CPU/GPU switching, with cleaner, simplified code.

Latest Performance

Date: 11/23/2025
Hardware: GeForce RTX 4090
# Particles: 4,000,000

  • Fluids ver 3.2 ➔ 32 fps
  • Fluids ver 3.9 ➔ 71 fps
  • Fluids ver 4.0 ➔ 98 fps
  • Fluids ver 5.0 ➔ 160 fps
    (same hardware & num particles for all versions)

How to Build

I recommend you build the latest Fluids v5.0.
Run CMake on the Fluids v5.0 folder.
The CUDA Toolchain must be setup correctly for your Graphics Cards model, CUDA Toolkit version and NVIDIA Driver.
Set the CUDA_ARCH_BIN and CUDA_ARCH_PTX cmake variables to match your hardware.
For example: GeForce RTX 5060, CUDA 13.0, NV Driver 581.80 => CUDA_ARCH_BIN=compute_120, CUDA_ARCH_PTX=sm_120
Use ChatGPT to help install the proper toolchain for your specific hardware, or if you don't know what I'm talking about.

History

Fluids 5.0

  • Modernized, 2023
  • Cuda Driver API (cuLaunchKernel), no longer requires CUDA Run-time linkage
  • Large-scale prefixSums, custom code, >4 million particles
  • Full Smart Pointers, CPU & GPU (DataPtr)
  • Buffer-based kernels
  • Abstract Buffer management (DataX)
  • Removed run modes
  • Integrated CPU & GPU switching per func (instead of ver 4.0 Run modes)
  • Modern folder struct (src, assets)
  • Major code cleanup and reduction


Fluids 4.0

  • Rewrite, 2022
  • Fluid struct removed
  • Fluid as buffers (SofA, see fluid.h)
  • Buffer-based kernels
  • Allows for arbitrary per-particle properties
  • New kernels: sampleParticles, computeQuery
  • Write to disk (SavePoints)
  • Equivalent CPU & GPU code
  • Run modes: SEARCH, CPU_SLOW, CPU_GRID, VALIDATE, GPU_FULL, PLAYBACK


Fluids 3.9

  • Major update, 2021
  • Switched to Cuda Driver API (cuLaunchKernel), no need to link to Cuda Run-time
  • Large-scale prefix sums, custom code, >4 million particles
  • Allocation helper, cpu & gpu (AllocateBuffer)
  • Source at top level


Fluids 3.2

  • Minor update, 2013
  • Application code (abstracted main)
  • GUI added
  • Still using Cuda Run-time API (cudaLaunchKernel)
  • Identical kernels to 3.0

Fluids 3.0

  • Major update, 2012
  • New Insertion-sort based
  • Entirely on GPU
  • Explicit memory allocs
  • Cuda Run-time API (cudaLaunchKernel)
  • Static/mixed host code (fluid_system_host.cu)
  • 3rd party Prefix scan
  • Fluid as struct (AofS)
  • Kernels: insertParticles, countingSort, computePressure, computeForce, advanceParticles
  • Introduced insertion-sort and prefix scan, as faster alternatives to radix-sort for particle search
  • GTC 2014 Talk: 2014, Hoetzlein. Fast Fixed-Radius Nearest Neighbors: Interactive Million-Particle Fluids. GPU Technology Conference. Santa Clara, CA. 2014.


Fluids 2

  • First GPU version, 2011
  • Radix-sort based (Simon Green, 2010)
  • CPU-GPU transfers per frame (pipeline bottleneck)


Fluids 1

  • First CPU version, 2007
  • Smoothed Particle Hydrodynamics (SPH)
  • Proof of concept
  • Self learning


Keyboard commands (Fluids 3.0):

H		Turn scene info on/off
N, M		Change number of particles
[, ]		Change example scene (loaded from scene.xml)
F, G		Change algorithm (CPU, GPU, etc.)
J		Change rendering mode (points, sprites, spheres)
C		Adjust camera (using mouse)
L		Adjust light (using mouse)
A,S,W,D	Move camera target
1		Draw acceleration grid
2		Draw particle IDs (be sure # < 4096 first)
~		Start video capture to disk (tilde key)
-, +		Change grid density

Scene parameters (Fluids 3.0)

  • Example scenes are loaded from the scene.xml file
    All parameters are permitted in either Fluid or Scene sections.
DT			Simulation time step
SimScale		Simulation scale (see website)
Viscosity		Fluid viscosity coefficient
RestDensity	Fluid rest density
Mass			Fluid particle mass
Radius		Fluid particle radius, only for boundary tests
IntStiff		Fluid internal stiffness (non-boundary)
BoundStiff		Fluid stiffness at boundary
BoundDamp		Fluid damping at boundary
AccelLimit		Acceleration limit (for stability)
VelLimit		Velocity limit (for stability)
PointGravAmt	Strength of point gravity
PointGravPos	Position of point gravity
PlaneGravDir	Direction of plane gravity
GroundSlope	Slope of the ground (Y- plane)
WaveForceFre	Frequency of wave forcing
WaveForceMin	Amplitude of wave forcing from X- plane
WaveForceMax	Amplitude of wave forcing from X+ plane
Name			Name of scene example
Num			Number of particles to simulate
VolMin		Start corner of Domain Volume
VolMax		End corner of Domain Volume
InitMin		Start corner of Initial Particle placement
InitMax		End corner of Initial Particle placement

Contact

Feel free to contact me if you have any questions, comments or suggestions:
Rama Hoetzlein
Website: ramakarl.com
Email: ramahoetzlein@gmail.com

License & Copyright

MIT License
FLUIDS - SPH Fluid Simulator for CPU and GPU
Copyright (c) 2007-2023. Rama Hoetzlein

About

fluids v.3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published