Proposal (GSoC 2016 - Blender Mantaflow Integration)
Proposal for my GSoC 2016 Blender project "Single code fluid solver". It is based on previous integration steps of Mantaflow into Blender.
Email / IRC
Liquids and smoke are both fluids and share properties. It therefore makes sense to have one single fluid solver in Blender which handles all fluid simulations.
In this project I plan to add liquid simulations to the existing Mantaflow (smoke) integration. More specifically, I would like to achieve the same functionality from the Elbeem code base with Mantaflow . Besides smaller Mantaflow specific features, the novel NB FLIP  will be implemented as well.
There's always two sides to a coin. In my view, both Blender programmers and artists will benefit from this project:
From the programmer's perspective, Blender will ...
- have a more maintainable fluid solver code base. Not only will smoke and liquids finally share code, but also will it be easier to update the fluid core as the Mantaflow library is very loosely coupled. For smoke it's currently just a matter of plugging in the new Mantaflow files. For liquids it should be similarly convenient.
- get an API to access state of the art liquid simulation techniques from research. Recently, NB FLIP simulations  were presented and implemented in Mantaflow. With a Mantaflow API for liquids such approaches (and possible future ones) will be available in Blender, too!
- be set for development cycle 2.8. The new liquid simulations will use the same 'Python script based' technique that was used previously for smoke to exchange data. Such approach would then make a node based fluid simulation possible, where each node represents a part from the Mantaflow script (cf. ).
From the artist's perspective, Blender will ...
- provide (visually) higher quality liquid simulations. Mantaflow uses state of the art Hollywood technology, is updated regularly and should therefore improve the look and feel of liquids.
- have faster baking times for liquids. Mantaflow itself should run more efficiently than Elbeem and with NB FLIP  in place there really should be a notable difference in computation time.
- get a terminology clean up. Liquids and smoke are both fluids :)
So far the Mantaflow integration has been a work-in-progress. Over the summer, I would like to implement these liquid specific features:
- Full integration of Mantaflow for liquids
- Mantaflow specific features, such as NB FLIP , adaptive time stepping
- User and technical documentation in form of Blender-Wiki and video tutorials
Note: "Full integration" is a broad term, especially when using it in the context of deliverables. In this case, what I mean is a setup in which all existing liquid settings from Blender are taken into account, then transfered to Mantaflow, worked on with the help of Python script snippets and finally read and shown in Blender. Hence, the deliverable for the "full integration" is an API which handles the appropriate data structures (e.g. meshes, grids) and the data exchange between the two platforms Blender and Mantaflow.
Similar to the Mantaflow smoke integration, data from a scene setup in Blender needs to be passed to Mantaflow for calculations and then retrieved from it. The idea for this project is to use the same 'Python script based' approach from the smoke integration.
My project will therefore make use of existing functions to exchange grid data and add functions to handle new data structures like meshses which have not been used so far but which are essential for liquid simulations. Data that is retrieved from Mantaflow will then in a final step have to be fitted into Blenders disk caching mechanism.
Node based fluidsolver
The ultimate goal of the Mantaflow integration is to implement a node based fluidsolver. My proposed liquid simulations paired with the existing Mantaflow smoke setup will pave the way for this goal as they are script based and thus much more flexible than the existing fluidsolver setup. As with the smoke API, I will design the liquid API with all this in mind so that a future node UI can easily integrate the new solver.
The NB FLIP
With the NB FLIP I plan to integrate a novel way of FLIP simulations which reduces the amount particles and thus saves computation time. In fact, since the results from the paper  showed that NB FLIP simulations are able to create liquids simulations with nearly the same visual appearance, I plan to tackle them as early as possible. That is, when setting up the base liquid simulation I will either offer the option to switch between FLIP and NB FLIP or ditch FLIP and only implement the NB FLIP from the beginning. The final decision will be made during the project (makes more sense in my view) and after another consultation with the mentor.
Secondary particle system (optional)
A secondary particle systems allows for higher quality simulations in critical regions, e.g. areas with splashing liquids, foam and bubbles in breaking waves. In a future node based fluid simulation, it should be possible to have to control over such systems. If I have time left, I will look into this feature and work on the foundations, e.g. setup of secondary particle system in Mantaflow script.
I expect the project to last for the entire length of the summer of code. I will start immediately and have the advantage that I am quite familiar with the Blender code - its general structure and of course the Mantaflow API for smoke that I have been working on. This should shorten the time to familiarize with the code.
In late July I will take a few exams and do some of the easier work at that time, e.g. documentation, video comparisons. This is actually ideal because by then I should have some content to publish.
Other than that, I plan to follow this timeline for the 13 weeks of coding:
|0||until 23/05||Get to know the Elbeem code base, read more about FLIP simulations and especially NB FLIP|
|1||23/05 - 29/05||Implement base class with functions for liquid data exchange (mesh transfer from Mantaflow to Blender)|
|2||30/05 - 05/06||Focus on writing Mantaflow script snippets which will be executed from Blender|
|3||06/06 - 12/06||Hook up Mantaflow snippets with Blender liquid API|
|4||13/06 - 19/06||Extra week to work on liquid API, see how my API works with kernel classes|
|5||20/06 - 26/06||Bug fixing and "lather, rinse, repeat" some work from week 1-4 to get simulation running|
|6||27/06 - 03/07||Basic liquid simulation should work|
|7||04/07 - 10/07||Implement additional features, e.g. obstacles, external forces|
|8||11/07 - 17/07||Refactor some code and make sure that liquid works well together with smoke code (share code)|
|9||18/07 - 24/07||NB FLIP should work|
|10||25/07 - 31/07||Create user documentation, sample scenes and videos|
|11||01/08 - 07/08||Extra week on coding for things that got left behind|
|12||08/08 - 14/08||Testing with different scenes and incorporating user feedback|
|13||15/08 - 23/08||Code review, refactor and cleanups|
My name Sebastián, I am 23 years old and currently studying computer science at the Technical University of Munich (TUM). For my bachelor's thesis I worked together with Nils Thuerey on smoke and fire simulations, continuing the Mantaflow integration that was started in the GSoC 2014. My main achievements during that time were implementing the flow type fire, fixing type smoke and also the Mantaflow script export.
Since then I have continued my work at the chair for computer graphics at TUM and added new features like wavelet noise or adaptive time stepping. My most recent work involved a complete refactor of the Mantaflow smoke API which could now form the basis for the integration of liquids.
- Thuerey N., Pfaff T., http://mantaflow.com, 2016
- Ferstl F., Ando R., Wojtan C., Westermann R., and Thuerey N., Narrow Band FLIP for Liquid Simulations, EUROGRAPHICS 2016