PIC/FLIP Fluid Simulation

An individual free time project of implementing a fluid simulator from scratch in C++.

I have gone from using semi-Lagrangian advection on the whole grid domain to later separate liquid from air by using marker particles. I then implemented PIC (Particle in Cell) / FLIP (Fluid Implicit Particle) advection as a better solution to simulate liquids. It is now possible to get highly viscous fluids using the PIC method and more liquid like behaviour then I was able to get using semi-Lagrangian advection and marker particles.

Current state of the project features:

  • Staggered MAC Grid
  • Different advection schemes
    • Semi Lagrangian advection with
      • Bilinear interpolation
      • Runge Kutta and Euler solver
    • PIC advection with bilinear interpolation
    • FLIP advection with bilinear interpolation
    • PIC / FLIP combination
  • Pressure solve using the conjugate gradient method with the linear algebra library "Eigen"
  • Enforce Dirichlet boundary condition
  • Marker particles for air/fluid separation
  • Velocity extension using brute force search through grid

Example simulations

PIC / FLIP simulations rendered with grid, velocity field and particles. The first simulation is 100% PIC, the second one is 100% FLIP. The third one is a combination 2% PIC and 98% FLIP.

PIC Simulation FLIP Simulation 2% PIC 98% FLIP
PIC/FLIP Simulation

A simulation on a bigger grid

A real time simulation with interaction and OpenGL rendering

Future work

  • Adaptive time steps
  • Vorticity confinement
  • Make sure marker particles are outside of obstacles
  • Other interpolation alternatives (quadratic, cubic, Catmull Rom)
  • A better method for velocity extension
  • 3D simulation
  • Sophisticated rendering
  • Check if performance is enhanced if the conjugate gradient solve is parallelized using OpenMP or CUDA

I have a git repository hosted on github for this project.