Hey there,
It’s Robin from CFD Engine and I’m back with another leaky issue.
I know from previous posts that many of us (me included) invest considerable time & effort chasing leaks out of our input geometries, making sure we only get cells where we want them.
We trade the time taken, for reduced cell counts & a lower chance of being bitten by bad mesh.
So, if you’ve ever missed a night out because you were stuck in the office chasing leaks, then this one is for you – a few tips to quickly track down those leaks & be the first to the bar.
Let’s go…
locationsOutsideMesh
snappyHexMesh
has had the ability to detect leaks for a couple of years, but for some reason, the first time I used it was a couple of months ago. I think it’s one of my favourite features, not just in snappyHexMesh
, but in OpenFOAM.
Apart from it saving hours of frustration trying to find leaks in complex, overlapping, non-watertight input geometry, it’s also really user friendly.
Add the locationsOutsideMesh
keyword to your snappyHexMeshDict
, add some points where your mesh shouldn’t be, and you’re done.
On top of that, it has:
- No additional steps: it’s part of your normal
snappyHexMesh
run; - Minimal input: just add a point (or points) where mesh shouldn’t be;
- Minimal output: a VTK file containing all the leak paths it could find;
- Sensible defaults: there’s nothing to tweak & it only outputs something IF it finds a leak;
- Runs early in the process: you know before the first (castellated mesh) stage completes if it has leaked – no need to wait for snapping or layering.
If your mesh has leaked, bring your input geometry into ParaView, along with the VTK leak paths & follow them to find the leaks. Fix them in CAD & off you go again.
It just works 👏
There’s a tutorial here if you want to see it in action.
AFAIK it’s not in the Foundation version – sorry.
Feature Edges
If your input geometries are supposed to be watertight, but they’re still leaking, you can do a quick & easy visual check for holes in ParaView .
Read in your leaky OBJ/STL file & apply the Feature Edges
filter, leaving only Boundary Edges
checked. Turn off your input geometry & inspect the boundary edges. You should be able to recognise the ones that are supposed to be there & spot the candidates for a hole/leak.
You’ll be surprised what you can pick up using this method, even on complex geometries, especially if you’ve spent hours working with the geometry & know it back-to-front.
Backface Colors
Speaking of back-to-front, many CAD/geometry tools allow you to colour the backface of a surface differently. It’s hard to spot holes if the inside of a model is the same colour as the outside – this makes things much easier.
It’s the default in ANSA (those grey & yellow surfaces), Rhino let’s you switch it on (Preferences > Display Modes > Shaded > Backface Settings), as do Meshmixer & MeshLab for when you’re working with surface mesh/scan data.
I’m sure others can do it too – it’s definitely worth checking.
Meshmixer
Speaking of Meshmixer it does an awesome job of highlighting holes, free edges & other similar problems in your OBJ/STL geometry & will even have a go at fixing them.
If you can’t spot your leak/hole in ParaView, then try bringing your OBJ/STLs into Meshmixer & letting it have a go.
Probably worth having in your toolkit, just for this reason.
You can do the same in MeshLab (open-source & actively developed – unlike Meshmixer) but it’s not as intuitive.
Over to you
You aren’t going to need these tips every day, but stick them in your memory palace for the next time you’re chasing leaks in snappyHexMesh
.
That said, I’ve started adding locationsOutsideMesh
to all my snappyHexMeshDicts
– just in case 🤞 It does nothing if there’s no leak & saves you having to re-run it when there is.
Beware though, these tips & your subsequent early arrival at the pub, may end up costing you a round of drinks – cheers 🍻
Do you have any top tips for chasing out leaks in your models? Let me know, I’m always keen to hear how you’re getting things done.
Until next week, stay safe,