我正在使用pvbatch从一系列cgns文件中生成屏幕截图。这个过程效果很好,只有pvbatch会冻结(它不会崩溃,它会停止前进...)
在linux下(使用Paraview 5.3.0)我正在调用: pvbatch --mesa-llvm --use-offscreen-rendering make_all_videos_trunk.py
我的python代码如下所示:
from paraview.simple import *
import os
def get_cgns_source():
_sources = GetSources()
_cgnsKeys = []
for _k in _sources.keys():
if "CGNSSeriesReader" in _sources[_k].__repr__():
_cgnsKeys.append(_k)
if len(_cgnsKeys) == 1:
return _sources[_cgnsKeys[0]]
else:
raise Exception("Could not find the CGNS source")
def reset_session():
pxm = servermanager.ProxyManager()
pxm.UnRegisterProxies()
del pxm
Disconnect()
Connect()
gridName = "Grid5a_1.1m"
stateSource = r"video3_template.pvsm"
mainPath = os.path.join(os.curdir,gridName)
pathFigures = os.path.join(mainPath, "_summary", "_figures")
if not os.path.exists(pathFigures):
os.mkdir(pathFigures)
# go through all cases under that grid
for caseName in os.listdir(mainPath):
casePath = os.path.join(mainPath, caseName)
reset_session()
LoadState(stateSource)
cgnsReader = get_cgns_source()
_stepsRange = []
for fileName in os.listdir(casePath):
if fileName.startswith('out-') and fileName.endswith("solution.cgns"):
_stepsRange.append(int(fileName.replace("_solution.cgns","").replace('out-','')))
if not os.path.exists(os.path.join(pathFigures,caseName)):
os.mkdir(os.path.join(pathFigures,caseName))
for iStep in _stepsRange:
_sStep = str(iStep).zfill(8)
filePath = os.path.join(casePath, "out-%s_solution.cgns" % _sStep)
cgnsReader.FileNames = filePath
figName = 'Fig_%s.png' % _sStep
print figName
_figPathTemp = os.path.join(pathFigures,caseName, figName)
SaveScreenshot(_figPathTemp, layout=GetLayout())
我是否错过了#34;清洁"一边?还有别的吗?
感谢您的帮助!