Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select all mesh regions in ParaView OpenFOAM case using python scripting?

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?

like image 298
Woltan Avatar asked May 18 '18 06:05

Woltan


1 Answers

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")
like image 79
Mathieu Westphal Avatar answered Oct 21 '22 14:10

Mathieu Westphal