Issue 116 – October 1, 2022

Surface Streamlines in OpenFOAM

Hey there,

It’s Robin from CFD Engine & we’re making plots like this todayπŸ‘‡

wallBoundedStreamlines from OpenFOAM using the motorBike tutorial data

Streamlines, restricted to the surface, based on an interpolated vector field, that look a bit like experimental oilflow plots.

Super-useful for revealing separation lines, showing flow paths in attached regions and relatively easy to make (once you know how).

So, grab your crayons & a recent solution, it’s time to get creative 🎨

The basics

The heart of these plots are the streamlines, which you can generate in ParaView, or export from OpenFOAM.

I prefer the OpenFOAM option, as (in my experience) they tend to have smoother paths, they’re quicker to generate & they can be added to any simulation via a single dictionary.

You arguably have more control over your seed points in ParaView, but the streamlines can be really slow when you’re tracing a good number of them.

Whether you choose OpenFOAM or ParaView, you’ll follow the same basic steps:

  1. Export a velocity vector (or shear stress) field at the wall (I’m assuming you’re using noSlip walls) – this is best done in OpenFOAM;
  2. Select some seed points on the surfaces you’re interested in;
  3. Trace surface-restricted streamlines from those seed points, using your new vector field;
  4. That’s it 🍹

How to do it in OpenFOAM

Yet again, the tutorials are your friend πŸ™

This exact process is included in my favourite, the motorBike tutorial via the wallBoundedStreamlines file.

This file includes two function calls – the first to interpolate the velocity field onto the surfaces of the motorBike. And the second to use that new velocity field to trace 20,000 wall-bounded streamlines, from random points across the bike.

You could grab that file, save it to your system directory, include it in the function section of your controlDict (like this) & you’d be away.

But, here are a few hints on what’s what & a guide to the bits you might want to change/tweak to fit your case…

Running it

By default, it’s setup to write the near-wall field & export streamlines every time your simulation saves. But what if you want to run it on a completed case?

Just as before, reference the wallBoundedStreamlines dictionary in the functions section of your controlDict (like this) and then run your chosen solver in postProcess mode, something like this:

simpleFoam -postProcess -latestTime

The nearWallFields function object doesn’t work using the stand-alone postProcess tool, hence why we need to do it like this.

Which surfaces to interpolate onto

If you’re only interested in a subset of your surfaces (like in my plot, with just the rider) then you can specify which ones to interpolate the velocity field onto by editing this line.

Streamline settings

These links show which lines to edit to tweak the following streamline settings:

Your streamlines will be exported into the postProcessing/sets/wallBoundedStreamLines/ directory (under the relevant time step) as a single .vtp file, which can go straight into ParaView for plotting.

ParaView method

Speaking of ParaView…drop me a note if you’d like to see the method for doing this in ParaView – I’m collecting a list of “ParaView stuff that could be better explained in a screencast” and I’ll add this to the list (if anyone’s interested) πŸ€·β€β™‚οΈ

Useful?

I don’t use standard streamlines much, but I use these guys A LOT – I find them clearer (& easier to explain) than LIC (we can have an email on that, if you’re interested) & an essential part of my standard post-pro output.

If you haven’t used them yet, definitely give them a go, either on the motorBike tutorial or tweak the setup to fit one of your own simulations.

Let me know how you get on, I think you might like them.

Until next week,

Signed Robin K