Tuesday, August 12, 2014

Fluid Simulation with Ice

Problem: The challenge of fluid simulation has many applications in simulations that need to be implemented in different scenarios. So, in order to exercise my knowledge of fluid simulations, I wanted to create a challenging scenario for a fluid simulation to solve. I ended up settling on pouring water into a glass cup with ice in it because it presents several interesting challenges.

Among other challenges, it involves:

1. Allowing the water to pour into a relatively thin container without having any unintentional penetration.
2. Getting the ice to float on top of the water in a convincing way

So, keeping these three challenges in mind, I set about to build the simulation in Houdini.

Overall Simulation Network
Solution: The scene ended up being set up in a fairly standard way. I set up the simulation objects to be imported into a DOP network. Then from the DOP network I imported all the geometry relevant to the simulation to be rendered. Everything except for the glass.

Render Glass Geometry
Simulation Glass Geometry


1. The glass had to be treated in a different way because importing it straight into the DOP network as I wanted it rendered would definitely cause simulation errors. The solution came in creating two versions of the glass. One for rendering and one for simulating. The simulation glass has the same interior shape, but the sides of the glass are much thicker as to avoid having particles pass through it unintentionally. Instead of importing this glass geometry from the DOP network, we then take the render glass geometry and place it in the same position. Since the water stays in the interior of the simulation glass, it stays within the render glass as well.

DOP Simulation Network
2. To understand how to get the ice to be affected by the water, we have to take a look at how the objects are put together in the DOP network. As you can see, I opted to use a FLIP object to manipulate particles, simulating the movement of water. So, off of this particle data, somehow I would need to apply a force to the ice cubes, which are set up as Rigid Body Objects, so that they would rise like you would expect them to as the water fills the glass. Fortunately Houdini offers a Buoyancy Force node for just such an occasion. Using this node applies a force of the specified vector and intensity to be applied to the objects given based on the existence of the given field. So, by grabbing the surface field of the FLIP fluid simulation and designating the ice cubes to be influenced, I was able to achieve the visible effect.