def coProcess(grid, time, step, scriptname, wholeExtent): import vtkPVCatalystPython import os scriptpath, scriptname = os.path.split(scriptname) sys.path.append(scriptpath) if scriptname.endswith(".py"): print('script name is %s' % scriptname) scriptname = scriptname[0:len(scriptname) - 3] try: cpscript = __import__(scriptname) except: print(sys.exc_info()) print('Cannot find %s -- no coprocessing will be performed.' % scriptname) sys.exit(1) return datadescription = vtkPVCatalystPython.vtkCPDataDescription() datadescription.SetTimeData(time, step) datadescription.AddInput("input") cpscript.RequestDataDescription(datadescription) inputdescription = datadescription.GetInputDescriptionByName("input") if inputdescription.GetIfGridIsNecessary() == False: return inputdescription.SetGrid(grid) if grid.IsA("vtkImageData") == True or grid.IsA("vtkRectilinearGrid") == True \ or grid.IsA("vtkStructuredGrid") == True: inputdescription.SetWholeExtent(wholeExtent) cpscript.DoCoProcessing(datadescription)
def coprocess(time, timeStep, grid, attributes): global coProcessor import vtk import vtkPVCatalystPython as catalyst import paraview from paraview import numpy_support dataDescription = catalyst.vtkCPDataDescription() dataDescription.SetTimeData(time, timeStep) dataDescription.AddInput("input") if coProcessor.RequestDataDescription(dataDescription): import fedatastructures imageData = vtk.vtkImageData() imageData.SetExtent(grid.XStartPoint, grid.XEndPoint, 0, grid.NumberOfYPoints-1, 0, grid.NumberOfZPoints-1) imageData.SetSpacing(grid.Spacing) velocity = paraview.numpy_support.numpy_to_vtk(attributes.Velocity) velocity.SetName("velocity") imageData.GetPointData().AddArray(velocity) pressure = numpy_support.numpy_to_vtk(attributes.Pressure) pressure.SetName("pressure") imageData.GetCellData().AddArray(pressure) dataDescription.GetInputDescriptionByName("input").SetGrid(imageData) dataDescription.GetInputDescriptionByName("input").SetWholeExtent(0, grid.NumberOfGlobalXPoints-1, 0, grid.NumberOfYPoints-1, 0, grid.NumberOfZPoints-1) coProcessor.CoProcess(dataDescription)
def coProcess(grid, time, step, scriptname, wholeExtent): import vtkPVCatalystPython import os scriptpath, scriptname = os.path.split(scriptname) sys.path.append(scriptpath) if scriptname.endswith(".py"): # print 'script name is ', scriptname scriptname = scriptname[0 : len(scriptname) - 3] try: cpscript = __import__(scriptname) except: print sys.exc_info() print "Cannot find ", scriptname, " -- no coprocessing will be performed." sys.exit(1) return datadescription = vtkPVCatalystPython.vtkCPDataDescription() datadescription.SetTimeData(time, step) datadescription.AddInput("input") cpscript.RequestDataDescription(datadescription) inputdescription = datadescription.GetInputDescriptionByName("input") if inputdescription.GetIfGridIsNecessary() == False: return inputdescription.SetGrid(grid) if ( grid.IsA("vtkImageData") == True or grid.IsA("vtkRectilinearGrid") == True or grid.IsA("vtkStructuredGrid") == True ): inputdescription.SetWholeExtent(wholeExtent) cpscript.DoCoProcessing(datadescription)
def coprocess(time, timeStep, grid, attributes): global coProcessor import vtk import vtkPVCatalystPython as catalyst import paraview from paraview import numpy_support dataDescription = catalyst.vtkCPDataDescription() dataDescription.SetTimeData(time, timeStep) dataDescription.AddInput("input") if coProcessor.RequestDataDescription(dataDescription): import fedatastructures imageData = vtk.vtkImageData() imageData.SetExtent(grid.XStartPoint, grid.XEndPoint, 0, grid.NumberOfYPoints - 1, 0, grid.NumberOfZPoints - 1) imageData.SetSpacing(grid.Spacing) velocity = paraview.numpy_support.numpy_to_vtk(attributes.Velocity) velocity.SetName("velocity") imageData.GetPointData().AddArray(velocity) pressure = numpy_support.numpy_to_vtk(attributes.Pressure) pressure.SetName("pressure") imageData.GetCellData().AddArray(pressure) dataDescription.GetInputDescriptionByName("input").SetGrid(imageData) dataDescription.GetInputDescriptionByName("input").SetWholeExtent( 0, grid.NumberOfGlobalXPoints - 1, 0, grid.NumberOfYPoints - 1, 0, grid.NumberOfZPoints - 1) coProcessor.CoProcess(dataDescription)
def coProcess(grid, time, step): # initialize data description datadescription = vtkPVCatalystPython.vtkCPDataDescription() datadescription.SetTimeData(time, step) datadescription.AddInput("input") cpscript.RequestDataDescription(datadescription) inputdescription = datadescription.GetInputDescriptionByName("input") if inputdescription.GetIfGridIsNecessary() == False: return if grid != None: # attach VTK data set to pipeline input inputdescription.SetGrid(grid) # execute catalyst processing cpscript.DoCoProcessing(datadescription)
def coProcess(grid, time, step): # initialize data description datadescription = vtkPVCatalystPython.vtkCPDataDescription() datadescription.SetTimeData(time, step) datadescription.AddInput("input") cpscript.RequestDataDescription(datadescription)
def CatalystCoProcess(timeStep, time, grid): datadescription = catalyst.vtkCPDataDescription() datadescription.AddInput("input") datadescription.SetTimeData(time, timeStep)