Fluid simulation

Position based dynamic(PBD), SPH, Physics-based fluid simulation in Unity

2D PBD Cloth implemented in CPU

3D PBD Water using GPGPU to optimize

Intro to PBD algorithm

PBD.PNG

Overall structure

1. Simulation (Eg. Use gravity only)

     v += gt

     x += vt

2. PBD

Projection() depends on the specific constraint

     new x = Constrain(x)

Update velocity and position

     v += (new x - x)/dt

     x = new x

For Cloth (Jacobi solution)

c147f7e5-d0e3-4c4d-8a64-a2d74167f0a5.png

Projection/Constrain function for cloth

For Water: SPH algorithm(Based on PBD)

  • For every particle i

    • Calculate the predicted velocity and position

      • Only apply gravity and damping, assume mass = 1

        • v += (Gravity - Damping)*dt

        • pos += v*dt

  • Compute the neighborhood set.

  • Using the neighborhood, compute density -> pressure as a constraint.

  • Update the position and velocity

  • Calculate the viscosity and update the velocity

viscosity.png
pressure.PNG