Weekly Development Notes #22 – Debugging, Optimizing, and Testing Volume Forces

Covering the week of June 1st – 5th, 2020.

Hey, everyone! This is our 22nd development update for the FLIP Fluids liquid simulation add-on for Blender. I had a productive week and a fantastic weekend, and I hope you did as well! Last week’s development mainly involved debugging, optimizing, and testing our upcoming force fields feature set. I also had a chance to fix some small issues within the add-on that had been bothering me (and maybe others!) for a while.

In this post, I’ll detail how we optimized the engine and simulation setup to reduce baking time of a volume force field scene from 27 hours down to 10 hours.

Optimizing Volume Forces

In last week’s post, I covered a volume force field test using an animated character. You can read more about more here: Weekly Development Notes #21 – Volume Force Fields.

The test in last week’s post took a very long 29 hours to compute! A large contributor to the compute time was the result of a bug that did not allow some optimizations to kick-in as well as overkill in the amount of force field simulation accuracy in the simulation setup.

I made some modifications in the scene setup and ran some tests over the weekend to compare baking performance. In the original animation, the fluid character grows over time due to a large amount of added liquid. For these tests, the added liquid was removed so that the fluid would more closely conform to the character mesh shape, which would make it easier to compare results. The simulation was re-run without bug fixes and optimizations, and the animation without added liquid took about 27 hours to compute.

After adding a few small force field optimizations to the simulation engine, the compute time was then reduced to about 18 hours! But we can improve this time further with a simple optimization the force field setup.

Optimizing Force Field Resolution

The FLIP Fluids add-on is largely a grid-based simulator. Many different calculations are run on a 3D grid where the resolution setting controls how many times the domain is divided into voxels. The simulation voxel grid is similar to a 2D pixel grid in an image in the way that the size of a single pixel is the minimum amount of visual detail that can be resolved in the image. In a 3D simulation grid, the size of a single voxel is the minimum amount of physics detail that can be resolved in the simulation.

Like many other calculations in the simulator, force field calculations are also run on a grid. But the force field grid does not need to be the same resolution as the domain resolution. Depending on your effect, the force field grid resolution can be much lower than the domain resolution and still produce a good simulation result. Some force field calculations such as our volume force mode can be very computationally intense and using a lower resolution grid will help speed up these calculations.

Our upcoming force field feature set has a setting to choose the force field grid resolution using four quality modes: low, medium, high, and ultra. You will also be able to visualize this grid using our existing grid visualization tool in the FLIP Fluid Debug panel. Using the visualizer can help you determine which level of quality you will need.

Force Field Resolution Comparisons

Here is a comparison of baking times between different force field resolutions in the animated character volume force test:

At the lowest resolution, the simulation time is reduced to 10h20m! Each tests looks quite similar visually with some minor differences. To decrease baking time as much as possible in this scene setup, reducing the force field grid resolution to low or medium would be a good idea.

The reason why a a low force field resolution would be okay to use in this effect is because at this grid density, the size of a voxel is still small enough to capture the details of the mesh shape. Here is a comparison of the low, medium, high, and ultra grid resolutions using our grid visualization tool:

More Development Notes

  • Blender 2.83 compatibility – Blender 2.83 released last week. The addon was tested with the official Blender release and it was determined that no changes were needed in order to stay compatible with the new release. Our Blender 2.8 support documentation was updated to include the 2.83 release as well as the 2.9x experimental releases.
  • Bug fix: possible divide-by-zero error in point-to-triangle distance calculation – A very rare bug could cause our point-to-triangle distance test to result in a divide-by-zero (NaN) error. This was found in a simulation setup where the mesh contained a specific arrangement of triangles around another triangle with zero area. It looks like this bug has been in the simulator since it’s creation, but was rare enough that we never noticed it until last week and we had never had a report of this issue. This issue was fixed by detecting a zero area triangle and reducing the distance calculation to either a single point or a line segment.
  • Bug Fix: Attribute Error when retrieving domain – A possible error message has been resolved when the add-on searches for the domain object. If Blender is in an incorrect context, an Attribute Error message would be displayed in the Blender System Console window. This error was harmless and did not affect the functionality of the add-on, but it’s still good to prevent error messages!
  • UI fix: Added checkboxes to collapsed submenus – In an earlier development post, we displayed screenshots of how we cleaned up the UI by making it possible to collapse submenus. We received a very helpful usability tip that pointed out a flaw in our design: When a submenu is collapsed such as viscosity or surface tension, you would not be able to tell whether the feature was enabled and you would not be able to quickly enable/disable this feature without re-opening the submenu. This has been fixed by adding a checkbox toggle to show whether the feature is enabled or not:
  • UI Fix: Stats alignment issue – Fixed a possible usability/alignment issue when the FLIP Fluids Stats panel is set to show frame info. If you scrub through the timeline to see the frame info results, and you scrub past the point where there is available stats data, the panel will show a small Data Not Available message. This message causes the vertical height of the panel to be reduced, which causes a vertical UI shift in the properties panel. This issue has been very frustrating to me for a while because this vertical shift makes it needed to manually scroll the UI in order to see the stats panel again. This has been fixed by making sure that the vertical height of the panel remains consistent when there is both data available and not available.
  • Updated Whitewater Advanced Settings tooltips – Added a note to some tooltips that in most cases, you will only need to modify the settings displayed in the Basic Settings View. Modifying settings in the Advanced Settings view is rarely needed, and if you do not understand what some of the settings do, this could cause odd behaviour or no whitewater to be generated.
  • Force Field Optimization: Smoother Force Fields Force field grid data is now interpolated/smoothed when the force field grid does not match the domain grid. This results in smoother force field data at lower resolutions, which can allow you to get away with using a lower resolution force field in the simulation setup.
  • Force Field Optimization: Added Adaptive Timestepping for Force Fields option – This settings is similar to the Adaptive Timestepping for Obstacles option in the FLIP Fluids Advanced panel (both disabled by default). Force fields don’t need to be updated as frequently as other simulation calculations in order to remain stable. In most cases, force field calculations will only need to be updated on the first substep of a frame. Enabling this option will update force fields on every substep, and will add additional substeps if the force field is moving very quickly. Enabling this option will only needed if the animated force field object will move a large distance within the domain between frames.
  • Force Field Exporter Improvement – Added functionality to skip exporting animated force field data if it already exists in the cache. This is similar and functions in the same way as how animated Fluid/Inflow/Obstacle/Outflow objects can be skipped during export.
0 0 vote
Article Rating