Exemplo n.º 1
0
def GetAndReduceViewControl():
    phactori.myDebugPrint('GetAndReduceViewControl entered\n')
    myProcId = phactori.SmartGetLocalProcessId()
    dataList = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    if (myProcId == 0):
        phactori.myDebugPrint('  I am process 0, reading file\n')
        GetViewControlFromTextFile(dataList)
    else:
        phactori.myDebugPrint('  I am not process 0, reading file\n')

    phactori.UseReduceToSpreadValues(dataList)

    xx = dataList[0]
    yy = dataList[1]
    zz = dataList[2]
    zoom = dataList[3]
    fx = dataList[4]
    fy = dataList[5]
    fz = dataList[6]
    showColorKey = dataList[7]
    showAxes = dataList[8]
    showOrientation = dataList[9]
    colorVariableCellOrPoint = dataList[10]
    colorVariableIndex = dataList[11]

    #theSource = GetActiveSource()
    theSource = phactori.GetCurrentSource()

    theArrays = None
    if (colorVariableCellOrPoint == 1):
        theArrays = theSource.CellData
    else:
        theArrays = theSource.PointData

    phactori.SetCameraLookAtPointAndLookDirection(\
      inLookDirection = [xx, yy, zz], \
      inFocalPoint = [fx, fy, fz], \
      inEyePositionFactor = zoom)

    phactori.ShowDataColorLegend('off')
    phactori.myDebugPrint("  GetAndReduceViewControl color variable index " + \
      str(colorVariableIndex) + " name: " + \
      theArrays[colorVariableIndex].Name + "\n")
    phactori.ColorByVariable(theArrays[colorVariableIndex].Name)
    if showColorKey == 1.0:
        phactori.ShowDataColorLegend('on')
    else:
        phactori.ShowDataColorLegend('off')
    if showAxes == 1.0:
        phactori.ShowCubeAxes('on')
    else:
        phactori.ShowCubeAxes('off')
    if showOrientation == 1.0:
        phactori.SetOrientationAxesVisibility('on')
    else:
        phactori.SetOrientationAxesVisibility('off')

    phactori.myDebugPrint('GetAndReduceViewControl returning\n')
Exemplo n.º 2
0
def RequestDataDescriptionSub(datadescription):
    phactori.myDebugPrint("PhactoriDriver.RequestDataDescriptionSub entered\n")
    "Callback to populate the request for current timestep"

    phactori.TestUserDataForBypassScript(datadescription)

    if phactori.GetBypassUserDataFlag() == False:
        fd = datadescription.GetUserData()

        if fd == None:
            phactori.myDebugPrint2("no user data, returning {}\n")
            returnViewMapC = {}
            return returnViewMapC

    global coprocessor

    global gFirstTimeInDoCoProcessing
    global gSkipCountdown

    if gFirstTimeInDoCoProcessing == True:
        phactori.myDebugPrint2(
            "RequestDataDescription doing gFirstTimeInDoCoProcessing\n")
        phactori.myDebugPrint2(" skip countdown is " + str(gSkipCountdown) +
                               "\n")
        if gSkipCountdown > 0:
            gSkipCountdown = gSkipCountdown - 1
            return 0
        coprocessor = CreateCoProcessor()
        coprocessor.EnableLiveVisualization(False)
        gFirstTimeInDoCoProcessing = False

    #import pdb
    #pdb.set_trace()

    phactori.InitializePerPipeRoot(datadescription, coprocessor)

    if datadescription.GetForceOutput() == True:
        # We are just going to request all fields and meshes from the simulation
        # code/adaptor.
        for i in range(datadescription.GetNumberOfInputDescriptions()):
            datadescription.GetInputDescription(i).AllFieldsOn()
            datadescription.GetInputDescription(i).GenerateMeshOn()
        return 1

    # setup requests for all inputs based on the requirements of the
    # pipeline.
    coprocessor.LoadRequestedData(datadescription)
    return 1
Exemplo n.º 3
0
def PerFrameUpdate():
    phactori.myDebugPrint('PhactoriScript.PerFrameUpdate entered\n')
    #GetAndReduceViewControl()
    global tearListPersistent
    global deathListPersistent

    global gDoNewScatterPlotsC
    if gDoNewScatterPlotsC:
        phactori.myDebugPrint2('doing phactori.UpdateAllScatterPlots (C)\n')
        phactori.UpdateAllScatterPlots()
        phactori.myDebugPrint2('doing phactori.UpdateAllPlotsOverTime\n')
        phactori.UpdateAllPlotsOverTime()
        phactori.myDebugPrint2('did plot updates\n')

    #currentFrameTearList = phactori.CollectCells1('TEAR_DOUBLE', 0.01, 1)
    #tearListPersistent = mergeCurrentIntoPersistent(tearListPersistent, currentFrameTearList)

    #currentFrameDeathList = phactori.CollectCells1('STATUS', 0.8, -1)
    #deathListPersistent = mergeCurrentIntoPersistent(deathListPersistent, currentFrameDeathList)

    #compareTearDeath(tearListPersistent, deathListPersistent)

    phactori.myDebugPrint('PhactoriScript.PerFrameUpdate exiting\n')
Exemplo n.º 4
0
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)

    # 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.LocalWriteImages3(datadescription,
                                              rescale_lookuptable=False)

    #coprocessor.WriteImages(datadescription, rescale_lookuptable=True)

    # Live Visualization, if enabled.
    coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)
Exemplo n.º 5
0
def GetViewControlFromTextFile(outDataList):

    global gSavedViewControlDataList
    global gViewControlTriggerTime

    triggerTime = os.path.getmtime("CatalystViewControl_trigger.txt")
    if triggerTime <= gViewControlTriggerTime:
        for ii in range(0, 12):
            outDataList[ii] = gSavedViewControlDataList[ii]
        return

    gViewControlTriggerTime = triggerTime

    ff = open('CatalystViewControl.txt', 'rb')
    fileLines = ff.readlines()
    xx = float(fileLines[1])
    yy = float(fileLines[3])
    zz = float(fileLines[5])
    zoom = float(fileLines[7])
    fx = float(fileLines[9])
    fy = float(fileLines[11])
    fz = float(fileLines[13])
    showColorKey = float(fileLines[15])
    showAxes = float(fileLines[17])
    showOrientation = float(fileLines[19])
    colorVariableCellOrPoint = float(fileLines[21])
    colorVariableName = str(fileLines[23])
    endIndex = len(colorVariableName) - 1
    if colorVariableName[endIndex] == '\n':
        #newEndIndex = len(colorVariableName)-1
        #colorVariableName = colorVariableName[0..newEndIndex]
        newColorVar = ""
        for ii in range(0, endIndex):
            newColorVar = newColorVar + colorVariableName[ii]
        colorVariableName = newColorVar

    ff.close()

    #theSource = GetActiveSource()
    theSource = phactori.GetCurrentSource()

    theArrays = None
    if (colorVariableCellOrPoint == 1):
        phactori.myDebugPrint("GetViewControlFromTextFile doing cell array\n")
        theArrays = theSource.CellData
    else:
        phactori.myDebugPrint("GetViewControlFromTextFile doing point array\n")
        theArrays = theSource.PointData

    colorVariableIndex = 0
    phactori.myDebugPrint("GetViewControlFromTextFile finding ->" +
                          colorVariableName + "<-\n")
    for ii in range(theArrays.GetNumberOfArrays()):
        phactori.myDebugPrint("GetViewControlFromTextFile trying ->" +
                              theArrays.GetArray(ii).Name + "<-\n")
        if theArrays.GetArray(ii).Name == colorVariableName:
            phactori.myDebugPrint("match! " + str(ii) + "\n")
            colorVariableIndex = ii
        else:
            phactori.myDebugPrint("no match\n")

    phactori.myDebugPrint('PhactoriScript.GetViewControlFromTextFile   [' + \
      str(xx) + ', ' + str(yy) + ', ' + str(zz) + '] ' + str(zoom) +
      ' [' + str(fx) + ', ' + str(fy) + ',' + str(fz) +
      ']\nshowColorKey: ' + str(showColorKey) + ' showAxes: ' + str(showAxes) + \
      ' showOrientation: ' + str(showOrientation) + \
      '\ncolorVariableCellOrPoint: ' + str(colorVariableCellOrPoint) + \
      ' colorVariableIndex: ' + str(colorVariableIndex) + '\n')
    outDataList[0] = xx
    outDataList[1] = yy
    outDataList[2] = zz
    outDataList[3] = zoom
    outDataList[4] = fx
    outDataList[5] = fy
    outDataList[6] = fz
    outDataList[7] = showColorKey
    outDataList[8] = showAxes
    outDataList[9] = showOrientation
    outDataList[10] = colorVariableCellOrPoint
    outDataList[11] = colorVariableIndex
    for ii in range(0, 12):
        gSavedViewControlDataList[ii] = outDataList[ii]