コード例 #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')
コード例 #2
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)
コード例 #3
0
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

try:
    paraview.simple
except:
    from paraview.simple import *

from paraview import coprocessing

# ----------------------- Pipeline definition -----------------------

import phactori

#do sierra/catalyst logging (from process id 0 only)
#note: logging should be disabled for testing, but enabled for production
if phactori.SmartGetLocalProcessId() == 0:
    import os
    from datetime import datetime

    loggingIsEnabled = True
    if "SNL_CATALYST_SIERRA_USAGE_LOG_FLAG" in os.environ:
        #print "SNL_CATALYST_SIERRA_USAGE_LOG_FLAG environment variable: " + \
        #os.environ["SNL_CATALYST_SIERRA_USAGE_LOG_FLAG"]
        if os.environ["SNL_CATALYST_SIERRA_USAGE_LOG_FLAG"] == "disable":
            loggingIsEnabled = False

    if loggingIsEnabled:
        #print "I am process 0 doing logging!"
        if "HOSTNAME" in os.environ:
            os.environ["LOG_PLATFORM"] = os.environ["HOSTNAME"]
        else: