This project implements:
- Algorithm 1 from "SPH Fluids in Computer Graphics"
- Calculate pressure force explicitly with state equations.
For all particles:
Find neighbors
For all particles:
compute density
For all particles:
compute presssure force
compute viscosity force
compute other forces (e.g. gravity)
add them up
For all particles:
update velocity
update position
- Pros: Easy to implement.
- Cons:
- Unstable
- Small time step.
For faster neighborhood search I implemented a uniform grid.
- The simulation space is divided into small cubic cells.
- Each particle is associated with one of the cells.
- The cell length equals to the support radius of the kernel.
- For each particle, loop through 3^3 = 27 cells to find all its neighbors.
- Solve pressure force implicitly.
- Predict particle velocities with non-pressure forces and iteratively correct density and divergence error.
- Divergence free solver is used to correct velocity field.
- Constant density solver to correct numerical errors.
- Simulation Step:
For all particles:
find neighbors
For all particles:
calculate densities and some factors
while(t < t_max):
For all particles:
calculate non-pressure forces.
Calculate adaptive time step using CFL condition
For all particles:
predict velocities with calculated time step
correct density error
For all particles:
predict position
For all particles:
find neighbors
For all particles:
calulate densities and some factors
Correct divergence error
For all particles:
update velocities
- Pros:
- Stable
- Adaptive time step for faster update
- Cons:
- Difficult to implement. Have to set up initial conditions carefully.
The DFSPH paper also introduces an implicit viscosity solver.
- Viscosity tensor is defined by the strain rate tensor and the viscosity coefficient.
- Similar approach as the divergence and density solver.
- Iteratively compute the predicted strain rate, comparing it with the target strain rate, and correct velocities.
- Pros: Easy to intergrate with the divergence free solver.
- Cons:
- Viscosity parameter depends on the time step. Not physically meaningful.
- Solving the inverse of a six-dimentional matrix for each constriant, causing a large computional effort.
- Extremely difficult to set up initial conditions.
- Fixed time step: 1ms
- particle radius: 0.025m
- OpenGL Bindings: GLEW, GLFW .
- Math: GLM, Eigen .
- Search: CompactNSearch .
- GUI: AntTweakBar .
- Parallelism: OpenMP .
- "SPH Fluids in Computer Graphics", Ihmsen, Orthmann, Solenthaler, Kolb, Teschner
- Jan Bender and Dan Koschier. Divergence-free SPH for incompressible and viscous fluids. IEEE Transactions on Visualization and Computer Graphics, 2017.
- Miles Macklin, Matthias Müller, Nuttapong Chentanez and Tae-Yong Kim. Unified Particle Physics for Real-Time Applications. ACM Trans. Graph., 33(4), 2014