Issue 025 – December 12, 2020

Three Tiny Tips: Part 01

Hey there,

It’s Robin from CFD Engine and this week’s email is a little sharing experiment. No big worked examples or tutorials – just three (new to me) little nuggets that you might find useful.

Instead of tucking them away in my notes, I thought I’d drop them into an email & hope you get some value from them.

Of course, there’s always the chance that they’re not new to you, but hopefully there’s something of interest here.

Let’s get it…

Value Averaging

Do you use forceCoeffs to record the force history during a run?

Maybe you monitor a key value on a patch, or at a probe location?

Did you know that there’s a functionObject which will average those values during the simulation?

valueAverage takes the output of a functionObject and averages the values (it’s a good name). The example in the that link shows it averaging force coefficients & here’s another averaging a momentum report.

Much nicer than copy-pasting into Excel, knocking out a Python script or (if you’re like me) wrangling awk.

There are a few caveats though…

  • it’s only in the .com versions (since v1612+)
  • the naming convention can be mind-bending – some functions are dead easy, but for some you’ll need to dig into the source code to figure out the “real” name of the field you want to average – not ideal.
  • I couldn’t get it to average the output of forces (which has a terrible file format BTW). It might work if you can figure out the field names, but it was beyond me.
  • There’s a windowing option but it isn’t quite what you might expect. You’re probably better off using timeStart & timeEnd to control the period over which you’re averaging.

Not sure if I’ll use it extensively but I’ll definitely add it to my toolkit.

Force Fields

Not the kind that might feature in a Marvel film (unfortunately) but interesting nonetheless.

I’m a big fan of plotting “force” contours, particularly lift & drag contours, on surfaces. I say “force” because it’s actually just “static pressure × normal” but it tells a story.

Explaining to clients that “red surfaces generate drag” is much easier than explaining the mental gymnastics of resolving forces in your head from a pressure plot.

To save you the effort of breaking out the calculator filter in ParaView, there’s an option in forceCoeffs to write the forces out as a field (so that they can be plotted directly).

writeFields yes;

It also writes out a moment field, but that melts my brain a little 🤯

Some caveats again…

  • only in the .com version (since v3.0+)
  • the contours aren’t super-smooth, especially where you have large changes in face size.
  • the reported values are pretty small (they sum to the reported force coefficients) so you need tight ranges when plotting.
  • don’t just add it to your existing force reports. They are probably writing out every iteration – no-one needs force fields every iteration. Instead, add an additional function that only writes data at the end of the simulation with the fields activated.

Might it be useful for exchanging data with FE? I don’t know.

I prefer the smoother “pressure × normal” contours generated in ParaView but this tool has it’s place & it’s quick.

Changing Directories with Time

When I started doing CFD it was common to change schemes & relaxation factors during the course of a simulation – 500its first-order then QUICK until the end – something like that.

If this is something you do and you manage it manually then timeActivatedFileUpdate might be of interest.

It’s been available in the .com AND .org versions forever, but it only came on my radar recently.

You create your several versions of the file you want to change, then use this function to copy/replace the files, triggered by time / iteration.

It’s really easy to configure and much easier than dropping out to the command line &/or interrupting your simulation.

Well worth a look if you do this kind of runtime dictionary manipulation.

The Jackpot

While putting this together I hit the jackpot, looking for additional valueAverage examples I stumbled across the pisoFoam cavity tutorial in the .com version.

It’s a treasure trove of functionObjects with 40+ worked examples to go at – check it out here.

It was too late for this email, but I’m pretty sure some of the examples will feature in future issues.

So that’s it, three little nuggets (& a treasure chest) of OpenFOAM goodness that I wanted to share with you. Were they all super-obvious? Should I make it a regular thing? Is there anything you’ve come across recently that you’d like me to share with the class? Drop me a note & I’ll add it to the list for the next “tips” email.

Until next week, stay safe,

Signed Robin K