FLIP FLUIDS from scratch - Houdini Study

Problem

I will be implementing FLIP Fluid simulation inside of the software Houdini. I will be implementing the technique presented in the paper  (Animating Sand as a Fluid , Yongning Zhu and Robert Bridson, 2005) The problem presented before the paper was that previous fluid techniques provided two major approaches. Eularian Grids and Lagrangian particles.

  1. Eularian Grid-based methods store velocity, pressure, some sort of indicator of the presence of the fluid and any additional variables on a fixed grid. Usually a MAC grid is used. This allows simple and stable pressure solutions. Though simple to implement gird-based methods have difficulties with advection of particles.
  2. Lagrangian form utilizes Navier-Stokes equations  to calculate interaction forces between particles. Smoothed Particle Hydrodynamics exemplifies this technique. Benefit is you get the splashy results but the simulation easily becomes unstable causing particles to shoot out.

There is a big push towards realtime simulations these last couple of years.

Importance of the Problem

Larger-Scale simulations require a lot of work require stability provided by Grids and realism provided by Particles , so a combined approach taking the best of both worlds would help solve potential problems. Though the solution provided by the paper is not perfect but it leads to believable results which are workable.


Previous Work

Carlson et al ( Melting and Flowing, 2004) , Goktekin et al (A method for animating visoelastic fluids,2004) , Lasasso et al(Simulating Water and smoke with OctTree data structure,2004) provided grid based methods of simulating fluids.

Monaghan et al (Smoothed Particle Hydrodynamics 1992), Miller et al(Globular dynamics. 2003), Premoze et al(Particle based simulation of fluids,2003) all provide methods in Lagrangian particle based simulation.

Combination of Particle and grid based systems include the use of level sets by Enright et al(A hybrid particle level set method for improved interface capturing,2002). Another approach utilized was Volume of fluid(VOF) which solves accuracy issues but is very computationally heavy. Sussman  (A second order coupled level set and volume of fluid method for computing growth and collapse of vapor bubble, 2003) utilized the VOF method.

To solve Divergence they utilize the method provided by Stable Fluids, F. H. Harlow and J. E. Welch.


Motivation

In order to further understand fluid simulation, I intended to implement the fluid dynamics part of the paper. My ultimate goal outside of class is to implement this paper and  surface only fluids in real time. I want to understand the intricacies and then simplify it for real time use. I believe the latest graphics cards can provide parallelization of voxel grid calculations which can speed up the process. Also using first order integration can also simplify a lot of the process.


Basic Methodology

  • Initialize Particle positions and velocities.
  • For each time Step:
    1.   At each staggered MAC grid node. Compute a weighted average of the nearby particle velocities and transfer it to each voxel grid.
    2.   Save the Grid Velocities into a temp variable .
    3.   Do all the non-advection steps of a standard water simulation ( based off of Stable Fluid paper).
    4.   For Flip: Subtract the new velocities from the saved velocities. Add the interpolated differences to each particle.
    5.   For PIC: You directly apply the resultant velocity onto the particles.
    6.   Transfer the Final Grid velocities to particles velocity attribute.
    7.   Advect the particle positions based on velocity.
TLDR: Source Particles and Velocities => Transfer to Velocity Grid => Do required Velocity Calculations on Grid => Transfer the Grid Velocities to particles => Calculate new Particle Positions.

Programs/Libraries 

I utilize Houdini to generate and quickly iterate and focus on the algorithm rather than worrying about efficiency. I did try to do as much as I could with code but I used Houdini methods to generate the initial grids and transfer from Grid to Particle and vice-versa. Otherwise use of visual programming was also used in few occasions. I utilize the Houdini tools to generate collision fields. Since this wasn’t the focus of this paper I just utilized the methods provided by Houdini.


Detailed Methodology

Sourcing : Fill a Custom Model with Scattered jittered points. The points are colored and assigned a custom tearing force based on the color.

Velocity Vector Field was created to store the velocities. These are Marker and Cell (MAC) grids with velocities stored on the grid faces.

Particular Velocity :  I used Euler Integration to calculate the velocity step based on the constant force applied.

Euler: v@v = v@v + v@accel*@TimeInc;

Transfer Velocity : I use Houdini (Gas Particle to Field Node) to transfer the particle velocities into a velocity field using tri-linear filtering.

Duplicate Velocity Field: Save the current Velocity field (vel) into a temporary Oldvel vector field to be utilized later.

Divergence: Calculate Pressure component by calculating the divergence . Once calculated we subtract it from the velocity to remove Divergence. To find out more about divergence.

Particle In Cell ( PIC) : To generate this we just transfer the Calculated Velocity Field(vel) onto the particle velocity attribute. We use the nifty (

Node) to transfer the velocity field(vel) to particle attribute (v) provided based on the trilinear filtering of their position in the cell.

FLIP : For implementing Flip methodology. We find the difference between vel and Oldvel and add it to the Oldvel . We then use the same (Gas field to Particle Node) to transfer the velocity field (Oldvel) to particle attribute (v) .

Position Update: I use the 2nd order Runge-kutta method to generate the new Position(P) of the particles using the transferred velocity(v) attributes.

RK2: @P = @P + @TimeInc*0.5*@v + @TimeInc*0.5*(@v+@accel*@TimeInc);

Result

PIC(below)

FLIP ( below)

 


Future Work

  • My interest is to be able to control the flow of fluid in real-time.
  • There is some interesting work going on in real time FX and the flexibility of today’s tools has a lot of people experimenting.
  • During the project I developed a strong understanding of current production methods of fluid dynamics. I believe simplifying the integration method and parallelism of today’s GPU can help generating a real time solution for this.
  • Once implemented in realtime. It would be interesting for the user to have an interface to control the fluid using VR tools and ability to add obstacles .
  • Implementing Changing Forces overtime. 

Final Thoughts

Overall I am quite happy of the result. It is exactly what I expected and what the paper concluded. PIC being more smoothed and FLIP being more splashy was a happy result to see.

I did encounter some roadblocks in just getting things like my custom code to integrate with Houdini properly. The discussion forums provided a lot of help towards solving several of my issues which allowed me to iterate quickly and effectively . I believe I achieved what I set out to do for the project provided. Thanks to being in a stable 3D Package such as Houdini, I can modularly change and expand on the setup.


Contact

Copyright © 2019 Soumitra Goswami. All rights reserved.