Ryan Goldade, Yipeng Wang, Christopher Batty, and Mridul Aanjaneya talked about their research on viscosity and fluid simulation and shared the source code.

### Ryan Goldade, Yipeng Wang, Christopher Batty, and Mridul Aanjaneya are the authors of a research paper on adaptive viscosity that will be presented at SIGGRAPH 2019. In this article, they talked about their approach to fluid simulation and viscosity and shared the source code as a Houdini plugin. Read the full paper here.

### Introduction

**80lv**: Could you introduce your team to us? Where do you guys work, what are the topics of your research?

My name is Ryan Goldade and I’m a PhD student at the University of Waterloo in Canada. I also work part-time for SideFX Software as a developer for their simulation tools. Yipeng Wang completed his Masters at Waterloo and has since taken a position at Amazon in Toronto. Christopher Batty is an Associate Professor at the University of Waterloo, and Mridul Aanjaneya is an Assistant Professor at Rutgers University. Our research is mainly focused on fluid dynamics with applications in computer graphics.

### A Few Words about Fluid Simulation & Paper

**80lv**: What is the current state of the fluid simulations in the field? What are the main challenges that researchers face?

For fluid simulations in computer graphics, the FLIP method is the long-standing industry standard. This approach uses particles to carry the state of the fluid simulation (velocity, density, etc.) over time but solves the physical equations on a background grid. Most research in fluid simulation tends to fall into three categories: simulating new phenomena, improving visual quality, or improving computational performance. An example of the first category is “On the Accurate Large-scale Simulation of Ferrofluids” by Huang et al. where they recreate the dazzling spikes of a ferrofluid. “Efficient and Conservative Fluids Using Bidirectional Mapping”, by Qu et al. is an example of the second category where the authors reduce sources of dissipation in a smoke simulation to capture much sharper details. Finally, our paper is an example of the third. Although computers are significantly more powerful than when the foundational papers were published, simulations scale so poorly that we can’t simulate fluids at equivalently higher resolutions. Our research focuses on a methodology to assign computational effort to regions of the fluid that provide the biggest contribution to the overall simulation quality. By reducing computational effort elsewhere, our adaptive framework offers significant performance improvements over a standard regular grid. All of these papers are being presented at SIGGRAPH this year.

### Viscosity

**80lv**: What way did you decide to approach the viscosity in your project and how is your approach different?

The project came together from a few observations. From our experience, liquids with a high viscosity coefficient (e.g., honey) are extremely slow to simulate and the vast majority of the simulation time was spent solving for the effect of viscosity. An adaptive method seems like a natural direction to improve performance. However, there are sparingly few methods for adaptively solving for viscosity. Previous methods either sacrifice symmetry in the system of equations (symmetry is a necessary requirement for using a fast solver) or generated equations with more terms, both of which would take longer to solve. We formulate our problem as an energy to be minimized, which has the inherent benefit of being symmetric, and we build our equations that describe this energy in a form that keeps the equations relatively sparse. This adaptive method gives us the power to make larger approximations deep inside the liquid and finer approximations near the surface. Due to some careful design choices, our method significantly reduces the computational cost compared to a non-adaptive viscosity solver without sacrificing the overall quality.

*This is a screenshot of the flip solver with our plugin. The “Gas Viscosity” node has been disabled and replaced by our “HDK Adaptive Viscosity” node. Once the use compiles our plugin, they can simply swap it in for the Houdini version (and update the parameters as necessary).*

### Liquid Simulation with Cubes

**80lv**: Can you explain the way liquid is simulated with the different cubes inside the fluid?

There is currently no known general solution to the underlying equations of fluid motion for arbitrary situations, so we have to approximate the fluid as a collection of cubes. In essence, we store velocity values on the faces of the cubes and use mathematical techniques to estimate how these velocity values change over time. If we use finer cubes, we can improve the resolution and accuracy of the fluid simulation but this also comes at a significant cost. Our method adaptively varies the size of the cubes to alleviate this cost, and, because the interior of a viscous liquid contains a fairly smooth, non-turbulent velocity field, there is minimal loss in visual quality.

### Benefits of the Presented Method

**80lv**: Can you talk a bit about the benefits of the method you’ve used, including the speed and more importantly the way it’s affecting the final results of the simulation?

We have carefully designed our method to be as efficient as possible. The original tree-based design for octree methods required complex and inefficient algorithms to move between grid cells. This created a longstanding view in the graphics community that much of the savings achieved from solving a smaller linear system was overshadowed by difficult implementation and the overhead costs of traversing the octree structure. Our octree design is based on sparsely allocated grids that allow us to easily move to neighboring grid cells with just a few simple operations. We also employ parallelism in almost every step of our algorithm. One example presented in our paper has an additional overhead of only a few minutes compared to a regular grid solver, whereas the savings in the linear system solver was greater than 23 hours.

As for simulation differences, our various examples show that results from our method match very closely to the results produced from a standard uniform grid viscosity solver (but at far lower cost).

### Distribution

**80lv**: Where and when do you think we could actually start seeing these things in real action? Any chances that we can actually get this running in Houdini?

You can use it right now! We have released the source code as a Houdini plugin. It’s available on my github account here.