Hey there 👋
It’s Robin from CFD Engine & this week, hot on the heels of my divergence detector, I’m looking at detecting convergence.
Particularly force convergence, in steady-state simulations & using it to shorten (or extend) runs to ensure nicely-averaged results.
Potentially shorter (cheaper) simulations with better averages? I’m listening 🤔
Because this one’s not mine, I’m taking AirShaper’s new open-source project for a spin…
Background
I don’t need to introduce AirShaper, but you might’ve missed their two open-source projects – a neat adaptive mesh workflow that I’ve mentioned before & their new convergence detector.
The first one uses standard OpenFOAM tools & glues them together to do something new. In this case, adaptive mesh refinement that re-snaps any refined surfaces back onto their original input geometry.
Their new convergence detector is a little different. It adds functionality to OpenFOAM via a new function object, kinda like runTimeControl
but with super-powers.
But here’s the bit that might put some people off – you have to compile it.
I promise it’s not too tricky, even I managed it (i.e. it was scripted & I just had to copy-paste two lines) 🤫
What’s going on?
But what is it doing, that we couldn’t just do with runTimeControl
?
Here’s my grasp of what’s going on, using drag convergence as an example…
This is a real-time monitor, so at each time-step it:
- grabs the second half of the drag history;
- normalises it by its mean;
- calculates the gradient of the normalised trace & stores it;
- repeats until the gradient has settled, within a tolerance;
- and then calls it converged 🙌
But it’s not quite finished…
Once converged, it triggers field averaging & continues monitoring the force history.
Now it’s looking for when the solution is ready – i.e. when is the force average “good enough” that it can stop iterating?
One neat feature is that a “converged” solution can revert to being “un-converged” if the forces suddenly change.
So, if your solution has a wobble and the gradient of the force history drifts outside acceptable bounds, it’ll call off the field averaging & go back to waiting for the gradient of the mean to stabilise.
There are a lot of arbitrary windows, thresholds & limits involved, but they’re all customisable. AirShaper have their suggested settings, but you can easily play with them until they suit your sims.
It’s probably worth checking out their recent conference paper for more details (their adaptive mesh refinement is in there too).
Gotchas
The documentation isn’t quite there (yet). I’m sure it’s coming, but I’d recommend another approach.
Ignore the main repository & check out their “tutorial” instead. Here you’ll find the trusty motorBike
case, extended to include downloading, compiling & using the convergence detector.
Follow the instructions & have a play with it.
It doesn’t modify your OpenFOAM install at all, it just grabs the code & compiles it within the case directory. Perfect for running a few tests.
Your call
Will I use this? Honestly, I don’t know.
I like the idea, I like the process, I like the functionality, I like that AirShaper released it as open-source & I’d love to see something similar make it into an OpenFOAM release.
But…I’m reticent to recommend adding what is essentially a third-party plugin to the heart of your workflow (but maybe I’m too cautious) 🤷♂️
I fully recommend taking it for a spin though – check out the tutorial, try it on your own cases & see what you reckon.
Does it sound like something you’d use? Or have you rolled your own convergence detector? Do you think OpenFOAM could do with more plugins like this (and should I be more accepting of them)? 🤗
I’d love to get your thoughts – every day is a school day, so drop me a note.
Until next week, stay safe,