Ejemplo n.º 1
0
def RequestDataDescription(datadescription):
    phactori.myDebugPrint3("PhactoriDriver.RequestDataDescription entered: " +
                           str(gDoCoProcessingCount) + "\n")

    phactori.TestUserDataForBypassScript(datadescription)

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

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

    global gCatchAllExceptionsAndPassUpFlag
    if gCatchAllExceptionsAndPassUpFlag:
        try:
            return RequestDataDescriptionSub(datadescription)
        except:
            import traceback
            tb = traceback.format_exc()
            phactori.IssueErrorOrWarningThroughSierraIO(
                datadescription, tb, True)
    else:
        return RequestDataDescriptionSub(datadescription)
Ejemplo 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
Ejemplo n.º 3
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)