ImageWriter1 = CreateWriter( XMLPImageDataWriter, "input_grid_%t.pvti", 1, cp_writers ) Grid = CreateProducer( datadescription, "input" ) "Callback to do co-processing for current timestep" "Callback to populate the request for current timestep"ĭatadescription.GetInputDescriptionByName(input_name).AllFieldsOn()ĭatadescription.GetInputDescriptionByName(input_name).GenerateMeshOn()ĭatadescription.GetInputDescriptionByName(input_name).AllFieldsOff()ĭatadescription.GetInputDescriptionByName(input_name).GenerateMeshOff() GlobalController.SetGlobalController(None)ĭef RequestDataDescription(datadescription): ImageData.SetWholeExtent(0, 2*mpi.size, 0, 5, 0, 5) Partitioned in slices in the x-direction here but that is Time is used to make the field time varying. #import libvtkCoProcessorPython as vtkCoProcessorPythonĭatadescription.SetTimeData(simtime, simstep)Ĭreate a vtkImageData and a point data field called 'pointData'. # you have to import libvtkCoProcessorPython instead of vtkCoProcessorPython # the name of the library was changed so for previous version of ParaView GlobalController.SetGlobalController(globalController)ĭef coProcess(grid, simtime, simstep, scriptname): GlobalController = vtk.vtkMPIController() If globalController = None or globalController.IsA("vtkDumm圜ontroller") = True: GlobalController = pm.GetGlobalController() Print "command is 'mpirun -np pyMPI parallelexample.py '" # the passed in script says we should at time/stepĬoProcess(imageData, time, step, sys.argv) ImageData.GetPointData().AddArray(pointArray) PointArray.SetNumberOfTuples(imageData.GetNumberOfPoints())įor i in range(imageData.GetNumberOfPoints()): ImageData.SetWholeExtent(imageData.GetExtent()) # create the input to the coprocessing library. Print 'the last argument should be a number, setting the number of time steps to 10' Inputdescription.SetWholeExtent(grid.GetWholeExtent()) If inputdescription.GetIfGridIsNecessary() = False: Inputdescription = datadescription.GetInputDescriptionByName("input") Print 'Cannot find ', scriptname, ' - no coprocessing will be performed.'ĭatadescription = vtkCoProcessorPython.vtkCPDataDescription()Ĭpscript.RequestDataDescription(datadescription) Scriptname = scriptname#scriptname.rstrip(".py") Import vtkCoProcessorPython # import libvtkCoProcessorPython for older PV versions See ] for details.ĭef coProcess(grid, time, step, scriptname): Note to remember to set your system environment properly. The executable takes in a python co-processing script and a number of time steps to be run for. Note that this example requires MPI to be available on your system as well as pyMPI to initialize and finalize MPI from the python script. This example is used to demonstrate how the co-processing library can be used with a python based simulation code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |