Weekly Development Notes #12 – Surface Force Fields

Covering the week of March 9th – 13th, 2020.

Hello! This is Ryan here with the 12th weekly development update of the FLIP Fluids addon for Blender! Last week mostly involved fixing and investigating bugs related to our work in progress force fields feature.

Now that FLIP Fluids version 1.0.8 has been released, I have so much more time to get back to work on force field development! The next addon version 1.0.9 will include our force field feature and is set to be released in June or July. In this post, I’ll be covering one of the most requested force field modes: surface forces.

Surface Forces

Our surface force mode generates a force field around an object in the direction of the object’s surface normals. This mode has the effect of drawing fluid towards an object’s surface. Surface forces are not a force field mode available in Blender’s built-in simulation tools, but they have some interesting applications in fluid simulation.

Here is an example animation where surface forces are used on an object that has been twisted 180 degrees. This creates an effect as if the direction of gravity has been warped along the path.

Here is a test where the surface force is aligned to the shape of a pyramid and base:

A useful application of surface forces are in helping liquid stick to an object. Getting fluid to stick effectively on an object in a FLIP simulator can be a struggle, especially if the object is a moving target. You will often find that over time, thin liquid layers peel off of the object unnaturally. Surface force fields can help in this situation by pulling in fluid towards the objects surface to prevent the fluid from falling off. This is a common trick when using a FLIP based simulator.

Here is a comparison of three force strengths pulling fluid against a moving curved surface. In these examples, the strengths are measured in terms of earths gravity of 9.81 m/s^2. In the first example on the left, there is no surface force (0.0g) applied.

Higher resolution comparison can be found on our Facebook Page.

Before I left for the weekend, all three simulations as well as all six renders in this comparison were started and run simultaneously and all completed in under 2 hours! I was worried, but glad I didn’t experience any crashes.

Continuing surface force field development

The surface force field mode is still a work in progress and some issues need to be solved until I would consider it to be stable, usable, and reliable enough for release. Current issues:

  • It can be slow to compute. The calculations involved are computationally intense and requires computing a signed distance field (SDF). An SDF is a grid where each point stores the distance to the closest point on an objects surface where positive values denote points outside of the surface and negative values denote points inside of the surface. This data allows us to efficiently compute the vector towards the closes point on the surface at any point in the grid. It can be quick to compute for a narrow band that is within a small distance near the object surface. But if the SDF needs to be computed further away from the object, or computed over the entire grid, this can be very slow.
  • Due to the possibility of this computation becoming very slow, I’ve tested out some quick approximations during last week. It works well for many situations, but can become unstable if the object contains complex geometry. This may be caused by a bug in my implementation, or a limitation of the approximation. I’ll need to investigate this during the upcoming week.
  • There is a possibility for this type of SDF computation to be highly parallelizable. This means that it could be suitable for GPU acceleration! This is something that I’ll also need to investigate. GPU acceleration can be a bit time consuming and complex for programming, so if this is a possibility, it may need to wait until after the initial force fields features are released.

The surface force field feature has been one of the more complex and time consuming force field modes to develop, but the computations in this mode also apply to another popular force field request: suction forces that fill an objects volume with fluid. This is similar to Control objects in the older Blender Elbeem simulator.

Other popular force field mode requests are curve guided forces, vortex/whirlpool forces, and turbulence forces. These are much simpler to implement and quick to compute.

Precision editing for viscosity and surface tension values

The viscosity and surface tension values are dependent on the physical scale of the simulation. For example a single viscosity value will appear thicker in a smaller scale domain than a larger scale domain. For this reason, the viscosity and surface tension values can become difficult to edit at small scales due to lack of precision. For small adjustments, dragging your mouse on the parameter can increment or decrement the value by too large of an amount.

A recommendation to solve this issue was to add an exponent value to these settings as a way to simplify precision editing for small values. This is the system that the Blender Elbeem and Mantaflow simulators for adjusting viscosity.

The viscosity and surface tension values will be comprised of two components: the base value and the exponent value. With these values, the formula for computing the total viscosity is:

total_viscosity = base * 10^(-exponent) 

For example, if the base and exponent are set to 5.0 and 3, the resulting viscosity will be:

5.0 * 10^-3 = 0.005 

We will be setting the default exponent to 0 so that this added parameter will not affect compatibility with older .blend files (10^0 = 1). We will also be adding some tweaks to the UI that will make editing and understanding this value easier compared to Blender’s system:

  1. The UI will display the resulting total viscosity so that you don’t need to compute this in your head.
  2. When changing the exponent, the base value will be automatically updated so that the total viscosity remains equal. This allows you to seamlessly switch between exponent precision without needing to re-compute the value yourself. Need more precision? Simply increase the exponent and continue editing the base value.