def __generate_field_line_obj(self, direction='BOTH'): """ Generates the field line object and saves it locally. Requires paraview.simple.StreamTracer :param direction: :return: """ field_line_obj = pv.StreamTracer(Input=self.dataObj, SeedType='Point Source') field_line_obj.Vectors = self.vector field_line_obj.InterpolatorType = 'Interpolator with Point Locator' # self.fieldLineObj.SurfaceStreamlines = 0 field_line_obj.IntegrationDirection = direction field_line_obj.IntegratorType = 'Runge-Kutta 4-5' field_line_obj.IntegrationStepUnit = 'Cell Length' field_line_obj.InitialStepLength = 0.02 field_line_obj.MinimumStepLength = 1e-12 field_line_obj.MaximumStepLength = 0.45 field_line_obj.MaximumSteps = 100000 field_line_obj.MaximumStreamlineLength = 60000.0 field_line_obj.TerminalSpeed = 1e-12 field_line_obj.MaximumError = self.error_tol field_line_obj.ComputeVorticity = 0 # init the 'Point Source' selected for 'SeedType' field_line_obj.SeedType.Center = self.startLoc field_line_obj.SeedType.NumberOfPoints = 1 field_line_obj.SeedType.Radius = 1e-10 return field_line_obj
from paraview import simple from paraview.web.dataset_builder import * # ----------------------------------------------------------------------------- # Pipeline creation # ----------------------------------------------------------------------------- reader = simple.OpenDataFile(inputFile) reader.PointVariables = ['Temp', 'V', 'Pres', 'AsH3', 'GaMe3', 'CH4', 'H2'] clip = simple.Clip(Input=reader) clip.ClipType.Normal = [0.0, 1.0, 0.0] streamLines = simple.StreamTracer(Input=reader, SeedType="High Resolution Line Source", Vectors=['POINTS', 'V'], MaximumStreamlineLength=20.16) streamLines.SeedType.Point2 = [5.75, 5.75, 10.15999984741211] streamLines.SeedType.Point1 = [-5.75, -5.75, -10.0] streamTubes = simple.Tube(Input=streamLines, Radius=0.2) sections = { "LookupTables": { "AsH3": { "range": [0.0804768, 0.184839], "preset": "wildflower" }, "Pres": { "range": [0.00678552, 0.0288185], "preset": "cool" },
def Save_PV_data_to_picture_file(inputFileName, field_name, node_or_cell,outputFileName ): pvs._DisableFirstRenderCameraReset() #pvs.HideAll(view=None)#Not available in paraview 5.1.2 view = pvs.GetActiveView() sources = pvs.GetSources().values() for aSource in sources: pvs.Hide(aSource, view) # create a new 'XML Unstructured Grid Reader' reader = pvs.XMLUnstructuredGridReader(FileName=[inputFileName]) if node_or_cell== 'CELLS': reader.CellArrayStatus = [field_name] elif node_or_cell== 'NODES': reader.PointArrayStatus = [field_name] else: raise ValueError("unknown type : should be CELLS or NODES") # get active view renderView1 = pvs.GetActiveViewOrCreate('RenderView') # uncomment following to set a specific view size # renderView1.ViewSize = [1057, 499] # show data in view display = pvs.Show(reader, renderView1); # trace defaults for the display properties. display.ColorArrayName = [None, ''] display.GlyphType = 'Arrow' display.ScalarOpacityUnitDistance = 0.02234159571242408 # reset view to fit data renderView1.ResetCamera() # set scalar coloring if node_or_cell== 'CELLS': pvs.ColorBy(display, ('CELLS', field_name)) elif node_or_cell== 'NODES': pvs.ColorBy(display, ('POINTS', field_name)) else: raise ValueError("unknown type : should be CELLS or NODES") # rescale color and/or opacity maps used to include current data range display.RescaleTransferFunctionToDataRange(True) # show color bar/color legend display.SetScalarBarVisibility(renderView1, True) pvs.SaveScreenshot(outputFileName+".png", magnification=1, quality=100, view=renderView1) display.SetScalarBarVisibility(renderView1, False) if field_name=='Velocity' : #pvs.HideAll(view=None)#Not available in paraview 5.1.2 view = pvs.GetActiveView() sources = pvs.GetSources().values() for aSource in sources: pvs.Hide(aSource, view) # create a new 'Stream Tracer' streamTracer1 = pvs.StreamTracer(Input=reader, SeedType='Point Source') streamTracer1.Vectors = ['CELLS', 'Velocity'] # init the 'Point Source' selected for 'SeedType' streamTracer1.SeedType.Center = [0.5, 0.5, 0.0] streamTracer1.SeedType.Radius = 0.0 # Properties modified on streamTracer1 streamTracer1.SeedType = 'High Resolution Line Source' # Properties modified on streamTracer1.SeedType streamTracer1.SeedType.Point1 = [0.0, 0.0, 0.0] streamTracer1.SeedType.Point2 = [1.0, 1.0, 0.0] streamTracer1.SeedType.Resolution = 20# Pb : claims attribute Resolution does not exist # show data in view streamTracer1Display = pvs.Show(streamTracer1, renderView1) # create a new 'Stream Tracer' streamTracer2 = pvs.StreamTracer(Input=reader, SeedType='Point Source') streamTracer2.Vectors = ['CELLS', 'Velocity'] # init the 'Point Source' selected for 'SeedType' streamTracer2.SeedType.Center = [0.5, 0.5, 0.0] streamTracer2.SeedType.Radius = 0.0 # Properties modified on streamTracer2 streamTracer2.SeedType = 'High Resolution Line Source' # Properties modified on streamTracer2.SeedType streamTracer2.SeedType.Point1 = [0.0, 1.0, 0.0] streamTracer2.SeedType.Point2 = [1.0, 0.0, 0.0] streamTracer2.SeedType.Resolution = 25# Pb : claims attribute Resolution does not exist # show data in view streamTracer2Display = pvs.Show(streamTracer2, renderView1) pvs.SaveScreenshot(outputFileName+"_streamlines.png", magnification=1, quality=100, view=renderView1) pvs.Delete()
def makeStream(self): # get color transfer function/color map for the data to color with. dataLUT = simple.GetColorTransferFunction(self.plotRecipe.get('EnumColorVariable')) # create a new 'Stream Tracer' streamTracer = simple.StreamTracer(Input=self.dataObject.getData(), SeedType='High Resolution Line Source') # Properties modified on streamTracer.SeedType streamTracer.SeedType.Resolution = 450 # Properties modified on streamTracer streamTracer.MaximumSteps = 600 # show data in view streamTracerDisplay = simple.Show(streamTracer, self.dataObject.renderView) # trace defaults for the display properties. streamTracerDisplay.Representation = 'Surface' # show color bar/color legend streamTracerDisplay.SetScalarBarVisibility(self.dataObject.renderView, False) # update the view to ensure updated data information self.dataObject.renderView.Update() # create a new 'Ribbon' ribbon = simple.Ribbon(Input=streamTracer) # Properties modified on ribbon ribbon.Scalars = ['POINTS', self.plotRecipe.get('EnumColorVariable')] # show data in view ribbonDisplay = simple.Show(ribbon, self.dataObject.renderView) # trace defaults for the display properties. ribbonDisplay.Representation = 'Surface' # hide data in view simple.Hide(streamTracer, self.dataObject.renderView) # show color bar/color legend ribbonDisplay.SetScalarBarVisibility(self.dataObject.renderView, True) # update the view to ensure updated data information self.dataObject.renderView.Update() # set scalar coloring ColorBy(ribbonDisplay, ('POINTS', self.plotRecipe.get('EnumColorVariable'))) # Hide the scalar bar for this color map if no visible data is # colored by it. simple.HideScalarBarIfNotNeeded(dataLUT, self.dataObject.renderView) # rescale color and/or opacity maps used to include current data range ribbonDisplay.RescaleTransferFunctionToDataRange(True, False) # show color bar/color legend ribbonDisplay.SetScalarBarVisibility(self.dataObject.renderView, True) # get color transfer function/color map for 'uds_0_scalar' colorLUT = simple.GetColorTransferFunction(self.plotRecipe.get('EnumColorVariable')) # Properties modified on ribbon ribbon.Width = 0.003 self.dataObject.renderView.ResetCamera() # update the view to ensure updated data information self.dataObject.renderView.Update() # set active source simple.SetActiveSource(streamTracer) # Properties modified on streamTracer.SeedType streamTracer.SeedType.Resolution = 200 # update the view to ensure updated data information self.dataObject.renderView.Update()