OpenFOAM 的 vtk 过滤器

vtk filter for OpenFOAM

我想使用 python-vtk

通过阈值过滤压力
    import vtk
    filename = "a.foam"

    reader = vtk.vtkOpenFOAMReader()
    reader.SetFileName(filename)
    reader.CreateCellToPointOn()
    reader.DecomposePolyhedraOn()
    reader.EnableAllCellArrays()
    reader.Update()

    tArray = vtk_to_numpy(reader.GetTimeValues())
    reader.UpdateTimeStep(tArray[-1]) 
    reader.Update()

    filter_threshold = vtk.vtkThreshold()
    filter_threshold.SetInputConnection(reader.GetOutputPort()) 

我应该如何 select "pressure" 过滤 class?

使用SetInputArrayToProcess方法。

https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#a6bea16e1329609dbccce0ff8d2367484