Hi everybody,

I was working with a colleague to get his simulation running with coprocessing 
and I am totally stumped on the problem. I have been able to set up and render 
some very complex things with our code, but for some reason this simulation 
just won't work as expected. 

We generated the coprocessing script with version 4.3 and we are running it on 
a cluster with the same version, using off-screen rendering. I have attached 
the script, it really just takes a slice through the center of the domain. 

It is producing images of the colorbar and nothing else. I tried to save the 
slice data to an xdmf file from the coprocessing script and it all reports 
dimensions of zero. So the slice doesn't seem to be actually doing anything. 

We took the exact lines from the Pipeline class and moved them to their own 
python file. We then removed the coprocessor.RegisterView and changed the 
coprocessor.CreateProducer line so it loads a datafile off disk instead. We 
then ran it through the python shell in the paraview GUI and we get exactly the 
slice we expected to get.

So, for some reason, this renders fine in the GUI but outputs the background 
with just the colorbar when we are using coprocessing. 

Any ideas or glaring problems in the coprocessing script that we are missing?

Thanks,

Tim
import os
from paraview.simple import *
from paraview import coprocessing
import sys
sys.path.append('/nv/hp25/ptudisco3/leslie_SC/leslie')
import lesliepy.setup as ls

#--------------------------------------------------------------
# Code generated from cpstate.py to create the CoProcessor.
# ParaView 4.3.1 64 bits
# ----------------------- CoProcessor definition -----------------------

def CreateCoProcessor():
  def _CreatePipeline(coprocessor, datadescription):
    class Pipeline:
      # state file generated using paraview version 4.3.1
      path = ls.load_paths('./')

      # ----------------------------------------------------------------
      # setup views used in the visualization
      # ----------------------------------------------------------------
      #### disable automatic camera reset on 'Show'
      paraview.simple._DisableFirstRenderCameraReset()

      # Create a new 'Render View'
      renderView1 = CreateView('RenderView')
      renderView1.ViewSize = [869, 804]
      renderView1.OrientationAxesLabelColor = [0.0, 0.0, 0.0]
      renderView1.CenterOfRotation = [0.038513511419296265, 0.0, 0.0]
      renderView1.StereoType = 0
      renderView1.CameraPosition = [0.038513511419296265, -1.3453612593869777, 0.0]
      renderView1.CameraFocalPoint = [0.038513511419296265, 0.0, 0.0]
      renderView1.CameraViewUp = [0.0, 0.0, 1.0]
      renderView1.CameraParallelScale = 0.34891316953088275
      renderView1.Background = [1.0, 1.0, 1.0]

      # register the view with coprocessor
      # and provide it with information such as the filename to use,
      # how frequently to write the images, etc.
      coprocessor.RegisterView(renderView1,
          filename=path['outdir']+'/post/image_%t.png', freq=2, fittoscreen=0, magnification=1, width=869, height=804)
          #filename='image_%t.png', freq=2, fittoscreen=0, magnification=1, width=869, height=804)

      # ----------------------------------------------------------------
      # setup the data processing pipelines
      # ----------------------------------------------------------------

      # create a new 'XDMF Reader'
      # create a producer from a simulation input
      rest_00162xmf = coprocessor.CreateProducer(datadescription, 'input')

      slice1 = Slice(Input=rest_00162xmf)
      slice1.SliceType = 'Plane'
      slice1.SliceOffsetValues = [0.0]

      # init the 'Plane' selected for 'SliceType'
      slice1.SliceType.Origin = [0.038513501831054994, 2.23867583030307e-06, 0.0]
      slice1.SliceType.Normal = [0.0, 1.0, 0.0]

      # ----------------------------------------------------------------
      # setup color maps and opacity mapes used in the visualization
      # note: the Get..() functions create a new object, if needed
      # ----------------------------------------------------------------

      # get color transfer function/color map for 'Densitykgm3'
      densitykgm3LUT = GetColorTransferFunction('Density [kg/m^3]')
      densitykgm3LUT.RGBPoints = [0.39550596307672914, 0.231373, 0.298039, 0.752941, 4.067091855020146, 0.865003, 0.865003, 0.865003, 7.738677746963562, 0.705882, 0.0156863, 0.14902]
      densitykgm3LUT.ScalarRangeInitialized = 1.0

      # get opacity transfer function/opacity map for 'Densitykgm3'
      densitykgm3PWF = GetOpacityTransferFunction('Density [kg/m^3]')
      densitykgm3PWF.Points = [0.39550596307672914, 0.0, 0.5, 0.0, 7.738677746963562, 1.0, 0.5, 0.0]
      densitykgm3PWF.ScalarRangeInitialized = 1

      # ----------------------------------------------------------------
      # setup the visualization in view 'renderView1'
      # ----------------------------------------------------------------
      # show data from slice1
      slice1Display = Show(slice1, renderView1)
      # trace defaults for the display properties.
      slice1Display.ColorArrayName = ['CELLS', 'Density [kg/m^3]']
      slice1Display.LookupTable = densitykgm3LUT

      # show color legend
      slice1Display.SetScalarBarVisibility(renderView1, True)

      # setup the color legend parameters for each legend in this view

      # get color legend/bar for densitykgm3LUT in view renderView1
      densitykgm3LUTColorBar = GetScalarBar(densitykgm3LUT, renderView1)
      densitykgm3LUTColorBar.Position = [0.37357142857142844, 0.8753549190535492]
      densitykgm3LUTColorBar.Position2 = [0.42999999999999994, 0.11999999999999955]
      densitykgm3LUTColorBar.Orientation = 'Horizontal'
      densitykgm3LUTColorBar.Title = 'Density [kg/m^3]'
      densitykgm3LUTColorBar.ComponentTitle = ''
      densitykgm3LUTColorBar.TitleColor = [0.0, 0.0, 0.0]
      densitykgm3LUTColorBar.LabelColor = [0.0, 0.0, 0.0]

      #curdir = os.getcwd()
      #os.chdir(path['outdir']+"/post")

      #writer = XdmfWriter(slice1)
      #writer.FileName = "Slice.xmf"
      #writer.UpdatePipeline()

      #os.chdir(curdir)

    return Pipeline()

  class CoProcessor(coprocessing.CoProcessor):
    def CreatePipeline(self, datadescription):
      self.Pipeline = _CreatePipeline(self, datadescription)

  coprocessor = CoProcessor()
  # these are the frequencies at which the coprocessor updates.
  freqs = {'input': [2]}
  coprocessor.SetUpdateFrequencies(freqs)
  return coprocessor

#--------------------------------------------------------------
# Global variables that will hold the pipeline for each timestep
# Creating the CoProcessor object, doesn't actually create the ParaView pipeline.
# It will be automatically setup when coprocessor.UpdateProducers() is called the
# first time.
coprocessor = CreateCoProcessor()

#--------------------------------------------------------------
# Enable Live-Visualizaton with ParaView
coprocessor.EnableLiveVisualization(False, 1)


# ---------------------- Data Selection method ----------------------

def RequestDataDescription(datadescription):
    "Callback to populate the request for current timestep"
    global 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

    # setup requests for all inputs based on the requirements of the
    # pipeline.
    coprocessor.LoadRequestedData(datadescription)

# ------------------------ Processing method ------------------------

def DoCoProcessing(datadescription):
    "Callback to do co-processing for current timestep"
    global coprocessor

    # 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)

    # Write output data, if appropriate.
    coprocessor.WriteData(datadescription);

    # Write image capture (Last arg: rescale lookup table), if appropriate.
    coprocessor.WriteImages(datadescription, rescale_lookuptable=False)
    # Live Visualization, if enabled.
    coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to