Loading an OpenFOAM case in ParaView using python is straight forward with:
ofReader = OpenFOAMReader(FileName='<some OpenFOAM case directory>')
However, by default only the internalMesh
mesh region is selected in the reader object.
Using the trace method of ParaView is not of any help, since the MeshRegion
property of the OpenFOAMReader
object is simply set to the values of the mesh regions I select via mouse input:
ofReader.MeshRegions = ['internalField', 'patch1', 'patch2']
Since I do not know in advance what the mesh region names are I cannot produce such a line in my python ParaView script.
How is it possible to select and load all mesh regions of an OpenFOAM case in ParaView using a python script and only ParaView Python API functionality?
There is a SelectAll() function on ArrayListPropery python class.
ofReader = OpenFOAMReader(FileName='<some OpenFOAM case directory>')
ofReader.MeshRegions.SelectAll()
Show(ofReader)
Render()
If you need to know the names though, this is also possible :
ofReader.GetProperty("PatchArrayInfo")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With