class Pipeline:

            # Define source of pipeline
            grid = coprocessor.CreateProducer(datadescription, "input")

            if (write_full_output == True):
                fullWriter = pvs.XMLPUnstructuredGridWriter(
                    Input=grid, DataMode="Appended", CompressorType="ZLib")
                coprocessor.RegisterWriter(fullWriter,
                                           filename='full_output_%t.pvtu',
                                           freq=1)

            # Create a spherical slice
            slice = pvs.Slice(Input=grid)
            slice.SliceType = 'Sphere'
            slice.Triangulatetheslice = 0
            slice.SliceOffsetValues = [0.0]
            slice.SliceType.Radius = sphere_radius

            # Create writer for this data and register it with the pipeline
            sliceWriter = pvs.XMLPPolyDataWriter(Input=slice,
                                                 DataMode="Appended",
                                                 CompressorType="ZLib")
            coprocessor.RegisterWriter(sliceWriter,
                                       filename='spherical_slice_%t.pvtp',
                                       freq=1)
        class Pipeline:

            # Define source of pipeline
            grid = coprocessor.CreateProducer(datadescription, "input")

            if (write_full_output == True):
                fullWriter = pvs.XMLPUnstructuredGridWriter(
                    Input=grid, DataMode="Appended", CompressorType="ZLib")
                coprocessor.RegisterWriter(fullWriter,
                                           filename='full_output_%t.pvtu',
                                           freq=1)

            # Determine grid bounds
            gridBounds = grid.GetClientSideObject().GetOutputDataObject(
                0).GetBounds()

            # Plane slice at the desired longitude
            slice = pvs.Slice(Input=grid)
            slice.SliceType = 'Plane'
            slice.Triangulatetheslice = 0
            slice.SliceOffsetValues = [0.0]
            slice.SliceType.Origin = [
                longitude / 180.0 * math.pi, 0, gridBounds[4]
            ]
            slice.SliceType.Normal = [1, 0, 0]

            # Create new writer
            sliceWriter = pvs.XMLPPolyDataWriter(Input=slice,
                                                 DataMode="Appended",
                                                 CompressorType="ZLib")
            coprocessor.RegisterWriter(sliceWriter,
                                       filename='meridional_slice_%t.pvtp',
                                       freq=1)
        class Pipeline:

            # Define source of pipeline
            grid = coprocessor.CreateProducer(datadescription, "input")

            if (write_full_output == True):
                fullWriter = pvs.XMLPUnstructuredGridWriter(
                    Input=grid, DataMode="Appended", CompressorType="ZLib")
                coprocessor.RegisterWriter(fullWriter,
                                           filename='full_output_%t.pvtu',
                                           freq=1)

            # Create a spherical slice
            slice = pvs.Slice(Input=grid)
            slice.SliceType = 'Sphere'
            slice.Triangulatetheslice = 0
            slice.SliceOffsetValues = [0.0]
            slice.SliceType.Radius = sphere_radius

            # Generate ghost cells - needed by CellDatatoPointData filter
            ghosts = pvs.GhostCellsGenerator(Input=grid)
            ghosts.BuildIfRequired = 0
            ghosts.MinimumNumberOfGhostLevels = 1

            # Convert cell data to point data, which is required for good contour results
            # Request "piece invariance" to ensure consistent values at
            # partition boundaries.
            #
            # CAUTION: THIS FILTER AVERAGES DATA FROM ALL CELLS SURROUNDING A POINT,
            #          WHICH REDUCES ACCURACY
            cell2point = pvs.CellDatatoPointData(Input=ghosts)

            # Create contours
            # Note that the "tube" filter can be used to highlight contours if needed.
            contours = pvs.Contour(Input=cell2point)
            contours.Isosurfaces = contour_values
            contours.ContourBy = ['POINTS', 'rho']
            contours.PointMergeMethod = 'Uniform Binning'

            # Create writers for slice and contour data and register them with the pipeline
            # Note that slice and contours generate separate datasets, so they need to be
            # written to separate files.
            sliceWriter = pvs.XMLPPolyDataWriter(Input=slice,
                                                 DataMode="Appended",
                                                 CompressorType="ZLib")
            coprocessor.RegisterWriter(sliceWriter,
                                       filename='spherical_slice_%t.pvtp',
                                       freq=1)

            # Create a new render view
            renderView = pvs.CreateView('RenderView')
            renderView.ViewSize = [1500, 768]
            renderView.AxesGrid = 'GridAxes3DActor'
            renderView.StereoType = 0
            renderView.CameraPosition = [0.0, 1.0, 0.3]
            renderView.CameraViewUp = [0.0, 0.0, 1.0]
            renderView.CameraParallelScale = 1.0
            renderView.Background = [0.32, 0.34, 0.43]
            renderView.ViewTime = datadescription.GetTime()

            # 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(renderView,
                                     filename='contours_%t.png',
                                     freq=1,
                                     fittoscreen=1,
                                     magnification=1,
                                     width=1500,
                                     height=768,
                                     cinema={})

            # Create colour transfer function for field
            LUT = pvs.GetColorTransferFunction('rho')
            LUT.RGBPoints = [
                dataRange[0], 0.23, 0.30, 0.75, 0.5 * sum(dataRange), 0.87,
                0.87, 0.87, dataRange[1], 0.71, 0.016, 0.15
            ]
            LUT.ScalarRangeInitialized = 1.0

            # Show surface and colour by field value (which is cell data) using lookup table
            sphereDisplay = pvs.Show(slice, renderView)
            sphereDisplay.Representation = 'Surface'
            sphereDisplay.ColorArrayName = ['CELLS', 'rho']
            sphereDisplay.LookupTable = LUT

            # Show coastlines
            contourDisplay = pvs.Show(contours, renderView)
            contourDisplay.Representation = 'Surface'
            contourDisplay.ColorArrayName = [None, '']
            contourDisplay.OSPRayScaleArray = 'theta '
            contourDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
            contourDisplay.SelectOrientationVectors = 'None'
            contourDisplay.ScaleFactor = 1193042.2418936265
            contourDisplay.SelectScaleArray = 'None'
            contourDisplay.GlyphType = 'Arrow'
            contourDisplay.GlyphTableIndexArray = 'None'
            contourDisplay.DataAxesGrid = 'GridAxesRepresentation'
            contourDisplay.PolarAxes = 'PolarAxesRepresentation'
            contourDisplay.GaussianRadius = 596521.1209468133
            contourDisplay.SetScaleArray = ['POINTS', 'theta ']
            contourDisplay.ScaleTransferFunction = 'PiecewiseFunction'
            contourDisplay.OpacityArray = ['POINTS', 'theta ']
            contourDisplay.OpacityTransferFunction = 'PiecewiseFunction'
Exemplo n.º 4
0
        class Pipeline:

            # Define source of pipeline
            grid = coprocessor.CreateProducer(datadescription, "input")

            if (write_full_output == True):
                fullWriter = pvs.XMLPUnstructuredGridWriter(
                    Input=grid, DataMode="Appended", CompressorType="ZLib")
                coprocessor.RegisterWriter(fullWriter,
                                           filename='full_output_%t.pvtu',
                                           freq=1)

            # Create a spherical slice
            slice = pvs.Slice(Input=grid)
            slice.SliceType = 'Sphere'
            slice.Triangulatetheslice = 0
            slice.SliceOffsetValues = [0.0]
            slice.SliceType.Radius = sphere_radius

            # Create writer for this data and register it with the pipeline
            sliceWriter = pvs.XMLPPolyDataWriter(Input=slice,
                                                 DataMode="Appended",
                                                 CompressorType="ZLib")
            coprocessor.RegisterWriter(sliceWriter,
                                       filename='spherical_slice_%t.pvtp',
                                       freq=1)

            # Create a new render view
            renderView = pvs.CreateView('RenderView')
            renderView.ViewSize = [1500, 768]
            renderView.AxesGrid = 'GridAxes3DActor'
            renderView.StereoType = 0
            renderView.CameraPosition = [-5, -2, 4]
            renderView.CameraViewUp = [0.5, 0.3, 0.8]
            renderView.CameraParallelScale = 1.7
            renderView.Background = [0.32, 0.34, 0.43]
            renderView.ViewTime = datadescription.GetTime()

            # 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(renderView,
                                     filename='spherical_slice_%t.png',
                                     freq=1,
                                     fittoscreen=1,
                                     magnification=1,
                                     width=1500,
                                     height=768,
                                     cinema={})

            # Create colour transfer function for field
            LUT = pvs.GetColorTransferFunction(fieldname)
            LUT.RGBPoints = [
                dataRange[0], 0.23, 0.30, 0.75, 0.5 * sum(dataRange), 0.87,
                0.87, 0.87, dataRange[1], 0.71, 0.016, 0.15
            ]
            LUT.ScalarRangeInitialized = 1.0

            # Show surface and colour by field value (which is cell data) using lookup table
            sphereDisplay = pvs.Show(slice, renderView)
            sphereDisplay.Representation = 'Surface'
            sphereDisplay.ColorArrayName = ['CELLS', fieldname]
            sphereDisplay.LookupTable = LUT
Exemplo n.º 5
0
# executed by rank 0. Check this assumption.
assert mpi4py.MPI.COMM_WORLD.rank == 0

# Output directory provided on command line.
outdir = sys.argv[1]

# Render a cone.
pv.Cone()
pv.Show()
pv.Render()
print("rendered")

# PNG image (serial).
filename = "%s/cone.png" % outdir
pv.SaveScreenshot(filename)
print(filename)

# Legacy VTK file (ASCII, serial).
filename = "%s/cone.vtk" % outdir
pv.SaveData(filename, FileType="Ascii")
print(filename)

# XML VTK files (parallel).
filename = ("%s/cone.pvtp" % outdir)
writer = pv.XMLPPolyDataWriter(FileName=filename)
writer.UpdatePipeline()
print(filename)

# Done.
print("done")