Dear all,
I am dealing with an EnsightGold file representing a CFD solution on a mesh with several boundary patches. I need to extract the ‘inlet’ and ‘outlet’ patches to perform the post-processing. I need to apply an extractBlock filter on the solution and get these patches. I would like to make the python script general so I would need to choose by name the block to extract or at least to know the index number corresponding to any block. I found some possible solutions on the net but none of them worked for my case.
The functions that I tried are reported below:
def GetBlockIndices(source, name): indices = [] it = servermanager.vtkPVCompositeDataInformationIterator() it.SetDataInformation(source.GetDataInformation().DataInformation) it.InitTraversal() while not it.IsDoneWithTraversal(): if it.GetCurrentName() == name: indices.append(it.GetCurrentFlatIndex()) it.GoToNextItem() del it return indices
def getBlockIndices(compositeDataInformation, index=0):
localDict = {} if compositeDataInformation.GetDataIsMultiPiece(): index += compositeDataInformation.GetNumberOfChildren() else: if compositeDataInformation.GetDataIsComposite(): for i in range(compositeDataInformation.GetNumberOfChildren()): index += 1 _blockName = compositeDataInformation.GetName(i) localDict[_blockName] = index leafDict, index = getBlockIndices(compositeDataInformation.GetDataInformation(i).GetCompositeDataInformation(), index) localDict.update(leafDict)
return localDict, index
Looks like the number of children is zero and GetName method always returns None. The thing is that opening the GUI and using it to extract the patches everything works.
Anyone has an idea about how to make the script work?
Thanks in advance,
Lorenzo