Hey there,
It’s Robin from CFD Engine, back with your weekly slice of CFD goodness. We’re 10+ issues in now & we haven’t had any ParaView content yet – let’s remedy that, right now.
I’m a huge fan of ParaView, I remember stumbling across it while looking for an EnSight replacement around 12 years ago. It was pretty good then & it’s come a long way since. It’s got everything I need to do my day-to-day post-pro, it’s open-source and it plays nicely with OpenFOAM – a triple bonus.
Most of my post-pro is generated in batch mode. Each project has its standard set of animations, output at the end of each run, for quick & easy comparison with previous results. On the occasions that I need to dig a little deeper, I’ll fire up an interactive session & have a poke around.
That’s the only time I read complete cases into ParaView. For the batch processing I export the assets I need – surfaces, slices, streamlines, etc. – using the OpenFOAM tools. The exports are done in parallel, so no need to reconstruct the model & they’re lightweight to use in ParaView.
Batch plots are automated using ParaView’s Python API (the simple one & even that one tests my limited Python Skillz).
Pro Tip: Use Trace (Tools > Start Trace) in an interactive ParaView session to record the Python commands that correspond to what you’ve just done. It’s not perfect but it’s a quick & easy way to start figuring out which Python commands you need.
I use Python scripts & the ParaView script runner (pvbatch) to produce the images. Most of my standard outputs are animations, so I’ll use FFmpeg to bundle the images into an MP4 movie file. Then I’ll use a player that supports scrubbing (like QuickTime or VLC) to play them back later as a flick book.
The exports from OpenFOAM, the image generation in pvbatch and the animation building are all done on the same instance that ran the simulation.
That’s the process at a high level & it’s probably quite like yours. If so, here are a few nuggets that I’ve picked up along the way which might be of interest…
Client-Server
Please don’t use ParaView via a remote desktop connection 🙏 the client-server option is your friend. In it’s simplest form you, run a graphical client on your local machine & read the data into a server somewhere else. Saving you the time & expense of moving simulation data around the place.
Whether you’re using it to connect a client on your laptop to a server on your workstation. Or you’re connecting to a server in a datacenter on the other side of the globe. It works really well. It’s not as snappy as having everything on your local machine, but it’s streets ahead of a remote desktop connection. More than good enough for most tasks & without having to bring your data back to base.
If you’ve got the right port open on your firewall & you’re using the same version of ParaView at both ends – then you’re good to go.
Superbuild
When I use ParaView on AWS it’s on a machine with no real graphics hardware 🐌 To speed things up I use ParaView’s offscreen/software rendering capabilities.
There are a few different flavours of software rendering & the best ones weren’t included in the ParaView binaries (I think they are now, but haven’t tested them). So, to get around this, I compile my own version of ParaView using the fastest software rendering libraries.
Thankfully Kitware (the team behind ParaView) have taken the sting out of this process with something called ParaView-Superbuild. With a handful of commands you can produce a custom stand-alone binary for any recent-ish ParaView release. You can include all the bits you need & skip those you don’t. Pretty useful. I’ve got a cheatsheet on using it – shout if you want it.
File Formats
There is a LOT of choice when it comes to file formats & ParaView. In my case…
I export my OpenFOAM assets as VTK or VTP files & read them into ParaView using the native readers.
If I need to share volume data with a client, then I’ll export the OpenFOAM case in EnSight format (using foamToEnsight
). You get a reconstructed dataset (without actually having to reconstruct the case) and ParaView can read EnSight files directly – handy.
If I need to read a case into an interactive session, I’ll use the built-in OpenFOAM reader. You just need to create an empty file in your case directory with the extension “.foam” & ParaView will open it using its built-in reader. You can open serial or decomposed cases, choose which variables & surfaces you’re interested in & other good stuff.
Pro Tip: Use
touch open.foam
to create an empty file in Linux (or just save an empty file from your text editor).
Smooth Operator
When you read a surface into ParaView it can look a bit flat and no-one wants that. A quick fix is to apply the “Generate Surface Normals” filter, a side effect of which is to help out ParaView’s shaders & make it look nice (you might have to apply the “Extract Surface” filter first).
Check out the example below using the mesh from the OpenFOAM motorbike tutorial.
Top image is just read in & displayed. The lower image is the same input with Generate Surface Normals applied – much cheaper than surface refinement 🤫 only joking.
There’s more where that came from, but I reckon that’s enough for one issue.
What’s your experience been like with ParaView? Is it indispensable or not that special? Anything you’ve struggled with? What should I cover in any future ParaView issues?
Until next week, stay safe,