def DoCoProcessingSub(datadescription): "Callback to do co-processing for current timestep" global gDoCoProcessingCount phactori.myDebugPrint3("PhactoriDriver.DoCoProcessingSub entered: " + str(gDoCoProcessingCount)+ "\n"); gDoCoProcessingCount += 1 fd = datadescription.GetUserData() if phactori.GetBypassUserDataFlag() == False: if fd == None: phactori.myDebugPrint2("no user data, returning {}\n") returnViewMapC = {} return returnViewMapC global coprocessor global gFirstTimeInDoCoProcessing global gSkipCountdown if gFirstTimeInDoCoProcessing == True: phactori.myDebugPrint2("DoCoProcessing doing gFirstTimeInDoCoProcessing\n") phactori.myDebugPrint2(" skip countdown is " + str(gSkipCountdown) + "\n") if gSkipCountdown > 0: return coprocessor = CreateCoProcessor() coprocessor.EnableLiveVisualization(False) gFirstTimeInDoCoProcessing = False #import pdb #pdb.set_trace() phactori.InitializePerPipeRoot(datadescription, coprocessor) "Callback to do co-processing for current timestep" timestep = datadescription.GetTimeStep() phactori.myDebugPrint("timestep is: " + str(timestep) + "\n"); phactori.SmartGetLocalProcessId() # Load the Pipeline if not created yet #if not pipeline: # phactori.myDebugPrint("PhactoriDriver.DoCoProcessing creating pipeline\n"); # pipeline = CreatePipeline(datadescription) #else: # phactori.myDebugPrint("PhactoriDriver.DoCoProcessing updating pipeline\n"); # # update to the new input and time # UpdateProducers(datadescription) # PerFrameUpdate(datadescription) # Update the coprocessor by providing it the newly generated simulation data. # If the pipeline hasn't been setup yet, this will setup the pipeline. coprocessor.UpdateProducers(datadescription) PerFrameUpdate(datadescription) # check for simulation-data-based i/o filtering--skip image creation # and writing if criteria has been set up to determine whether to # create images, such as 'maximum of variable X above 80.0' result = phactori.WriteOutImagesTest(datadescription, coprocessor) if result == False: #don't write images return # Write output data, if appropriate. #coprocessor.WriteData(datadescription); # Write output data #WriteAllData(datadescription, cp_writers, timestep); # Write image capture (Last arg: rescale lookup table) #phactori.myDebugPrint("PhactoriDriver.DoCoProcessing writing images\n"); #LocalWriteAllImages(datadescription, cp_views, timestep, False) #WriteAllImages(datadescription, cp_views, timestep, False) # Live Visualization #if (len(cp_views) == 0) and live_visu_active: # DoLiveInsitu(timestep, pv_host, pv_port) # Write output data, if appropriate. coprocessor.WriteData(datadescription) coprocessor.LocalExportOperationsData3(datadescription) # Write image capture (Last arg: rescale lookup table), if appropriate. coprocessor.LocalWriteImages3(datadescription, rescale_lookuptable=False) #test and allow for looping when doing user vis interaction while #pausing simulation continueWriteAndInteractionCheckLoop = True while continueWriteAndInteractionCheckLoop: interactionTestResult = \ phactori.DoUserInteractionWithSimulationPausedIfEnabled() if interactionTestResult == 0: #looping interaction is not or is no longer on; allow simulation to #continue continueWriteAndInteractionCheckLoop = False elif interactionTestResult == 1: #looping interaction is on, but there were no changes to the vis #(i.e. no trigger was given to update vis). Therefore do not write #images, but continue looping and waiting for vis change trigger continueWriteAndInteractionCheckLoop = True elif interactionTestResult == 2: #there was a vis change triggered; update the images for the new #vis, write out the images, and continue looping continueWriteAndInteractionCheckLoop = True imagesNeedWriting = True if imagesNeedWriting: phactori.UpdateAllImagesetViewsWhichMayChangeWithData() coprocessor.LocalExportOperationsData3(datadescription) coprocessor.LocalWriteImages3(datadescription, rescale_lookuptable=False) #coprocessor.WriteImages(datadescription, rescale_lookuptable=True) # Live Visualization, if enabled. coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)
def compareTearDeath(tList, dList): phactori.myDebugPrint2('compareTearDeath entered\n') phactori.myDebugPrint2('compareTearDeath returning\n')
def GetViewMapCFromUserData(datadescription): """given a datadescription, get the json string view map from the user data and convert it into a python dict using the json library, and return that item. Also determine the separator character and input deck filename""" import json #the following code forces a UserData item for internal testing #phactori.myDebugPrint2("GetViewMapCFromUserData entered\n") #import paraview.vtk as vtk #newFd = vtk.vtkFieldData() #newStringArray = vtk.vtkStringArray() #xxViewMapCStr = '{ "camera blocks": { }, "representation blocks": { }, \ # "operation blocks": { }, "imageset blocks": {}, \ # "scatter plot blocks": { }, "plot over time blocks": { } }' #newStringArray.InsertNextValue(xxViewMapCStr) #x2str = '_' #x3str = 'cool_input_deck' #newStringArray.InsertNextValue(x2str) #newStringArray.InsertNextValue(x3str) #newFd.AddArray(newStringArray) #datadescription.SetUserData(newFd) fd = datadescription.GetUserData() if fd == None: phactori.myDebugPrint2("no user data, returning {}\n") returnViewMapC = {} return returnViewMapC sa = fd.GetAbstractArray(0) testJsonString = sa.GetValue(0) separatorCharacterString = sa.GetValue(1) inputDeckFilename = sa.GetValue(2) phactori.myDebugPrint2("gGetJsonViewMapCFromUserData string:\n" + \ str(testJsonString) + "\n") phactori.myDebugPrint2("separator string: " + separatorCharacterString + \ "\ninputDeckFilename: " + inputDeckFilename + "\n") extraFileString = sa.GetValue(3) phactori.myDebugPrint2("extraFileString: " + extraFileString + "\n") phactori.myDebugPrint2("num strings2: " + str(sa.GetNumberOfValues())) phactori.SetSeparatorString(separatorCharacterString) phactori.SetExtraFileString(extraFileString) returnViewMapC = json.loads(testJsonString) returnViewMapC = phactori.convertJsonUnicodeToStrings(returnViewMapC) phactori.SetDefaultImageBasename(inputDeckFilename) phactori.myDebugPrint2("GetViewMapCFromUserData returning\n") return returnViewMapC