Motion tracking flow visualization for Tesla Model 3 using Blender and OpenFOAM

I made this aerodynamically and aesthetically pleasing video.

Integrating a CFD simulation with a real video footage. Visualizing three-dimensional flow field on a 2D spaces (image or video) has been a challenge. And here’s how I did it.

CFD stands for computational fluid dynamics. It’s like a wind tunnel test without a wind tunnel. People build cars and aircraft using CFD, and it also happens to be my day job. It can be colorful, but most of the value comes from engineering, correlation with experiment, and design principles. In this case, I’m going to focus on how to make it more ‘colorful’ using OpenFOAM to simulate external flow over my car, Tesla Model 3.

Installing OpenFOAM on a Mac is easier than ever, thanks to Docker.

$ docker container run -ti openfoam/openfoam7-paraview56

I started from motorBike tutorial (tutorials/incompressible/simpleFoam/motorBike), since we’re doing an external flow as well. All we have to do is simply replacing this biker with our Model 3.

Both OpenFOAM and Blender are open-source. OpenFOAM is an open-source alternative of Ansys Fluent or CFX, and Blender is an open-source tools similar to Autodesk 3ds Max.

Now it’s very hard to define what Blender does, since it became so versatile and powerful in many directions. I’m going to use it to model a Tesla. Not from the scratch, though. I like this low poly version from this guy, but I’d like these wheels from this guy. Remix it. Make it watertight, so we can make volumetric mesh for CFD.

Once your case is ready, solve it for 500 times, and do a typical post-processing the result using Paraview.

Velocity Contour

Jet color map is not the best colormap, but certainly is the most widely used one in CFD community. Tried better colormap (viridis) for pressure as below.

Pressure distribution on the Tesla Model 3
Streamlines around the car

So far it’s still close to what I do for my day-job. Let’s go further because I’m doing this for the Internet. Export the scene as VRML file, so you can do post-post-processing with Blender.

VRML files contain 3D objects with vertex colors. In Shader node, connect Vertex color to Diffuse BSDF or other shaders. I used 60% diffuse and 40% glossy, as shown below.

This type of rendering image would be great for a cover page for technical keynote that I do once a year. But let’s go further with Blender magic.

Motion Tracking

I’ve been watching Blender tutorial videos, and these two gentlemen are top-notch at motion tracking tutorials (IanHubert and CGMatters).

High contrast Tesla logo on the wheel makes a great tracker

Basically you’d track some fraction of the video until you have “a good solve” that reverse-engineer the camera movement from the shot. You can automate a lot of it, but it’s better to do it manually if you have a long 360-degree-walk-around-view shot on a camera with gimbal for ants.

Reload the VRML file to the scene, do your best to place the 3D model on the tracked footage. Notice that my car had side-mirrors folded, while the 3D models’ were unfolded.

On thing to note is that you can use the surface body as a masking body. Enable ‘hideout’ from the filter, and set the car body (with pressure contour) as a group. Toggle the hideout option so the streamlines behind the car are not shown in the scene.

So there you have it. Hope you like watching it as much as I did while making it.