|
[Sponsors] |
[OpenFOAM] Paraview python script, creating data using only CLI, saving in csv/excel file |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 24, 2021, 12:17 |
Paraview python script, creating data using only CLI, saving in csv/excel file
|
#1 |
Member
|
Hello All,
I have less knowledge and experience about paraview python scripting. I have paraview python script, partly generated by paraview and partly created by me (thanks to the ‘macro record’ option creator, I hope the person live long enough). Script functionality: 1.The script essentially takes the file readable by paraview from openfoam avilable in that directory 2.processes some graphical option changes and adjustments 3.then moves towards calculation of ‘isovolumedisplay’ and from that calculates ‘alpha.water’ using ‘integrateVariable’ 4.Shows calculated value in shreadsheet format. From that I copy the value manually and paste it in Excel cell. Program: Code:
#!usr/bin/python #script to automate the process of calculating volume fraction (also called as void fraction) alpha #and show graphically #### import the simple module from the paraview from paraview.simple import * #### disable automatic camera reset on 'Show' paraview.simple._DisableFirstRenderCameraReset() # create a new 'OpenFOAMReader' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM = OpenFOAMReader(registrationName='3D_Case20_halfGeom_(70)_FlR_0_0009631_Water.OpenFOAM', FileName='E:\\CCS\\3D_cases\\H2O_Cases\\halfGeom\\3D_Case20_halfGeom_(70)_FlR_0_0009631_Water\\3D_Case20_halfGeom_(70)_FlR_0_0009631_Water.OpenFOAM') a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.MeshRegions = ['internalMesh'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.CellArrays = ['U', 'UMean', 'UPrime2Mean', 'alpha.water', 'alpha.waterMean', 'alpha.waterPrime2Mean', 'p', 'pMean', 'pPrime2Mean', 'p_rgh'] # get animation scene animationScene1 = GetAnimationScene() # update animation scene based on data timesteps animationScene1.UpdateAnimationUsingDataTimeSteps() # Properties modified on a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.LabelSize = '64-bit' # get active view renderView1 = GetActiveViewOrCreate('RenderView') # show data in view a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay = Show(a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM, renderView1, 'UnstructuredGridRepresentation') # get color transfer function/color map for 'p' pLUT = GetColorTransferFunction('p') # get opacity transfer function/opacity map for 'p' pPWF = GetOpacityTransferFunction('p') # trace defaults for the display properties. a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.Representation = 'Surface' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ColorArrayName = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.LookupTable = pLUT a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectTCoordArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectNormalArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectTangentArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OSPRayScaleArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OSPRayScaleFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectOrientationVectors = 'U' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleFactor = 0.01 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectScaleArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GlyphType = 'Arrow' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GlyphTableIndexArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GaussianRadius = 0.0005 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SetScaleArray = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleTransferFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityArray = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityTransferFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.DataAxesGrid = 'GridAxesRepresentation' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.PolarAxes = 'PolarAxesRepresentation' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScalarOpacityFunction = pPWF a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScalarOpacityUnitDistance = 0.0018 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityArrayName = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 606.7, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 606.7, 1.0, 0.5, 0.0] # reset view to fit data renderView1.ResetCamera() # get the material library materialLibrary1 = GetMaterialLibrary() # show color bar/color legend a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # create a new 'Clip' clip1 = Clip(registrationName='Clip1', Input=a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM) clip1.ClipType = 'Plane' clip1.HyperTreeGridClipper = 'Plane' clip1.Scalars = ['POINTS', 'p'] clip1.Value = 491.24 # init the 'Plane' selected for 'ClipType' clip1.ClipType.Origin = [0, 0, 0.0065] # init the 'Plane' selected for 'HyperTreeGridClipper' clip1.HyperTreeGridClipper.Origin = [0, 0, 0.0065] # Properties modified on clip1.ClipType clip1.ClipType.Origin = [0.0, -0.045, 0.0] clip1.ClipType.Normal = [0.0, 1.0, 0.0] # show data in view clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') # trace defaults for the display properties. clip1Display.Representation = 'Surface' clip1Display.ColorArrayName = ['POINTS', 'p'] clip1Display.LookupTable = pLUT clip1Display.SelectTCoordArray = 'None' clip1Display.SelectNormalArray = 'None' clip1Display.SelectTangentArray = 'None' clip1Display.OSPRayScaleArray = 'p' clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' clip1Display.SelectOrientationVectors = 'U' clip1Display.ScaleFactor = 0.0024 clip1Display.SelectScaleArray = 'p' clip1Display.GlyphType = 'Arrow' clip1Display.GlyphTableIndexArray = 'p' clip1Display.GaussianRadius = 0.00012 clip1Display.SetScaleArray = ['POINTS', 'p'] clip1Display.ScaleTransferFunction = 'PiecewiseFunction' clip1Display.OpacityArray = ['POINTS', 'p'] clip1Display.OpacityTransferFunction = 'PiecewiseFunction' clip1Display.DataAxesGrid = 'GridAxesRepresentation' clip1Display.PolarAxes = 'PolarAxesRepresentation' clip1Display.ScalarOpacityFunction = pPWF clip1Display.ScalarOpacityUnitDistance = 0.00113 clip1Display.OpacityArrayName = ['POINTS', 'p'] clip1Display.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip1Display.ScaleTransferFunction.Points = [418.45, 0.0, 0.5, 0.0, 592.33, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip1Display.OpacityTransferFunction.Points = [418.45, 0.0, 0.5, 0.0, 592.33, 1.0, 0.5, 0.0] # hide data in view Hide(a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM, renderView1) # show color bar/color legend clip1Display.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # Properties modified on clip1 clip1.Invert = 0 # update the view to ensure updated data information renderView1.Update() # create a new 'Clip' clip2 = Clip(registrationName='Clip2', Input=clip1) clip2.ClipType = 'Plane' clip2.HyperTreeGridClipper = 'Plane' clip2.Scalars = ['POINTS', 'p'] clip2.Value = 491.24 # init the 'Plane' selected for 'ClipType' clip2.ClipType.Origin = [0, 0.0038, 0.0065] # init the 'Plane' selected for 'HyperTreeGridClipper' clip2.HyperTreeGridClipper.Origin = [0, 0.0038, 0.0065] # Properties modified on clip2.ClipType clip2.ClipType.Origin = [0.0, 0.045, 0.0] clip2.ClipType.Normal = [0.0, 1.0, 0.0] # show data in view clip2Display = Show(clip2, renderView1, 'UnstructuredGridRepresentation') # trace defaults for the display properties. clip2Display.Representation = 'Surface' clip2Display.ColorArrayName = ['POINTS', 'p'] clip2Display.LookupTable = pLUT clip2Display.SelectTCoordArray = 'None' clip2Display.SelectNormalArray = 'None' clip2Display.SelectTangentArray = 'None' clip2Display.OSPRayScaleArray = 'p' clip2Display.OSPRayScaleFunction = 'PiecewiseFunction' clip2Display.SelectOrientationVectors = 'U' clip2Display.ScaleFactor = 0.009 clip2Display.SelectScaleArray = 'p' clip2Display.GlyphType = 'Arrow' clip2Display.GlyphTableIndexArray = 'p' clip2Display.GaussianRadius = 0.00045 clip2Display.SetScaleArray = ['POINTS', 'p'] clip2Display.ScaleTransferFunction = 'PiecewiseFunction' clip2Display.OpacityArray = ['POINTS', 'p'] clip2Display.OpacityTransferFunction = 'PiecewiseFunction' clip2Display.DataAxesGrid = 'GridAxesRepresentation' clip2Display.PolarAxes = 'PolarAxesRepresentation' clip2Display.ScalarOpacityFunction = pPWF clip2Display.ScalarOpacityUnitDistance = 0.0016 clip2Display.OpacityArrayName = ['POINTS', 'p'] clip2Display.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip2Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip2Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # hide data in view Hide(clip1, renderView1) # show color bar/color legend clip2Display.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # create a new 'Clip' clip3 = Clip(registrationName='Clip3', Input=clip2) clip3.ClipType = 'Plane' clip3.HyperTreeGridClipper = 'Plane' clip3.Scalars = ['POINTS', 'p'] clip3.Value = 466.04 # init the 'Plane' selected for 'ClipType' clip3.ClipType.Origin = [0.0, 0.0, 0.0065] # init the 'Plane' selected for 'HyperTreeGridClipper' clip3.HyperTreeGridClipper.Origin = [0.0, 0.0, 0.0065] # Properties modified on clip3 clip3.Invert = 0 # Properties modified on clip3.ClipType clip3.ClipType.Origin = [0.0, 0.0, 0.0017] clip3.ClipType.Normal = [0.0, 0.0, 1.0] # show data in view clip3Display = Show(clip3, renderView1, 'UnstructuredGridRepresentation') # trace defaults for the display properties. clip3Display.Representation = 'Surface' clip3Display.ColorArrayName = ['POINTS', 'p'] clip3Display.LookupTable = pLUT clip3Display.SelectTCoordArray = 'None' clip3Display.SelectNormalArray = 'None' clip3Display.SelectTangentArray = 'None' clip3Display.OSPRayScaleArray = 'p' clip3Display.OSPRayScaleFunction = 'PiecewiseFunction' clip3Display.SelectOrientationVectors = 'U' clip3Display.ScaleFactor = 0.009 clip3Display.SelectScaleArray = 'p' clip3Display.GlyphType = 'Arrow' clip3Display.GlyphTableIndexArray = 'p' clip3Display.GaussianRadius = 0.00045 clip3Display.SetScaleArray = ['POINTS', 'p'] clip3Display.ScaleTransferFunction = 'PiecewiseFunction' clip3Display.OpacityArray = ['POINTS', 'p'] clip3Display.OpacityTransferFunction = 'PiecewiseFunction' clip3Display.DataAxesGrid = 'GridAxesRepresentation' clip3Display.PolarAxes = 'PolarAxesRepresentation' clip3Display.ScalarOpacityFunction = pPWF clip3Display.ScalarOpacityUnitDistance = 0.0017 clip3Display.OpacityArrayName = ['POINTS', 'p'] clip3Display.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip3Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip3Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # hide data in view Hide(clip2, renderView1) # show color bar/color legend clip3Display.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # create a new 'Iso Volume' isoVolume1 = IsoVolume(registrationName='IsoVolume1', Input=clip3) isoVolume1.InputScalars = ['POINTS', 'p'] isoVolume1.ThresholdRange = [375.79, 556.30] # Properties modified on isoVolume1 isoVolume1.InputScalars = ['POINTS', 'alpha.water'] isoVolume1.ThresholdRange = [0.91, 1.0] # show data in view isoVolume1Display = Show(isoVolume1, renderView1, 'UnstructuredGridRepresentation') # trace defaults for the display properties. isoVolume1Display.Representation = 'Surface' isoVolume1Display.ColorArrayName = ['POINTS', 'p'] isoVolume1Display.LookupTable = pLUT isoVolume1Display.SelectTCoordArray = 'None' isoVolume1Display.SelectNormalArray = 'None' isoVolume1Display.SelectTangentArray = 'None' isoVolume1Display.OSPRayScaleArray = 'p' isoVolume1Display.OSPRayScaleFunction = 'PiecewiseFunction' isoVolume1Display.SelectOrientationVectors = 'U' isoVolume1Display.ScaleFactor = 0.009 isoVolume1Display.SelectScaleArray = 'p' isoVolume1Display.GlyphType = 'Arrow' isoVolume1Display.GlyphTableIndexArray = 'p' isoVolume1Display.GaussianRadius = 0.00045 isoVolume1Display.SetScaleArray = ['POINTS', 'p'] isoVolume1Display.ScaleTransferFunction = 'PiecewiseFunction' isoVolume1Display.OpacityArray = ['POINTS', 'p'] isoVolume1Display.OpacityTransferFunction = 'PiecewiseFunction' isoVolume1Display.DataAxesGrid = 'GridAxesRepresentation' isoVolume1Display.PolarAxes = 'PolarAxesRepresentation' isoVolume1Display.ScalarOpacityFunction = pPWF isoVolume1Display.ScalarOpacityUnitDistance = 0.0048 isoVolume1Display.OpacityArrayName = ['POINTS', 'p'] isoVolume1Display.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' isoVolume1Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 554.07, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' isoVolume1Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 554.07, 1.0, 0.5, 0.0] # hide data in view Hide(clip3, renderView1) # show color bar/color legend isoVolume1Display.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # set scalar coloring ColorBy(isoVolume1Display, ('POINTS', 'alpha.water')) # Hide the scalar bar for this color map if no visible data is colored by it. HideScalarBarIfNotNeeded(pLUT, renderView1) # rescale color and/or opacity maps used to include current data range isoVolume1Display.RescaleTransferFunctionToDataRange(True, False) # show color bar/color legend isoVolume1Display.SetScalarBarVisibility(renderView1, True) # get color transfer function/color map for 'alphawater' alphawaterLUT = GetColorTransferFunction('alphawater') # get opacity transfer function/opacity map for 'alphawater' alphawaterPWF = GetOpacityTransferFunction('alphawater') # create a new 'Integrate Variables' integrateVariables1 = IntegrateVariables(registrationName='IntegrateVariables1', Input=isoVolume1) # Create a new 'SpreadSheet View' spreadSheetView1 = CreateView('SpreadSheetView') spreadSheetView1.ColumnToSort = '' spreadSheetView1.BlockSize = 1024 # show data in view integrateVariables1Display = Show(integrateVariables1, spreadSheetView1, 'SpreadSheetRepresentation') # get layout layout1 = GetLayoutByName("Layout #1") # add view to a layout so it's visible in UI AssignViewToLayout(view=spreadSheetView1, layout=layout1, hint=0) # update the view to ensure updated data information renderView1.Update() # update the view to ensure updated data information spreadSheetView1.Update() # Properties modified on spreadSheetView1 spreadSheetView1.FieldAssociation = 'Cell Data' # Properties modified on spreadSheetView1 spreadSheetView1.HiddenColumnLabels = [] # Properties modified on spreadSheetView1 spreadSheetView1.HiddenColumnLabels = ['Cell ID', 'Cell Type', 'UMean', 'UMean_Magnitude', 'UPrime2Mean', 'UPrime2Mean_Magnitude', 'U', 'U_Magnitude', 'pMean', 'pPrime2Mean', 'Block Number'] # set active source SetActiveSource(integrateVariables1) SelectIDs(IDs=[-1, 0], FieldType=0, ContainingCells=0) #================================================================ # addendum: following script captures some of the application # state to faithfully reproduce the visualization during playback #================================================================ #-------------------------------- # saving layout sizes for layouts # layout/tab size in pixels layout1.SetSize(1079, 835) #----------------------------------- # saving camera placements for views # current camera placement for renderView1 renderView1.CameraPosition = [0.163, -0.067, -0.107] renderView1.CameraFocalPoint = [0.0, 0.0, 0.0065] renderView1.CameraViewUp = [0.137, 0.927, -0.35] renderView1.CameraParallelScale = 0.054 #-------------------------------------------- # uncomment the following to render all views # RenderAllViews() # alternatively, if you want to write images, you can use SaveScreenshot(...). 1.Get rid of all the graphical aspects of above mentioned python script and make it CLI basis (I run the script using Terminal and the output should takes place) 2.Later I want to ru nthe script using For loop for multiple ‘recorded time’ values for any case. 3.For each ‘recorded time’ the script should copy the alpha.water value and paste it in excel file. Result: Failure, Paraview sent out error, and crashed Where did I go wrong? How can I improve it? Is there anyone having similar scripting idea? |
|
September 24, 2021, 12:23 |
|
#2 |
Member
|
Hence, with that in mind I changed the script as the following way:
Program_moded: Code:
#!usr/bin/python #script to automate the process of calculating volume fraction (also called as void fraction) alpha #and show graphically #### import the simple module from the paraview from paraview.simple import * I = [20, 30, 40, 60, 70, 90] J = [0001338, 0004013, 0009631, 0024078, 0033441] for i in I: for j in J: # create a new 'OpenFOAMReader' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM = OpenFOAMReader(registrationName='3D_Case20_halfGeom_('I')_FlR_0_'J'_Water.OpenFOAM', FileName='3D_Case20_halfGeom_('I')_FlR_0_'J'_Water.OpenFOAM') a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.MeshRegions = ['internalMesh'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.CellArrays = ['U', 'UMean', 'UPrime2Mean', 'alpha.water', 'alpha.waterMean', 'alpha.waterPrime2Mean', 'p', 'pMean', 'pPrime2Mean', 'p_rgh'] # update animation scene based on data timesteps animationScene1.UpdateAnimationUsingDataTimeSteps() # Properties modified on a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM.LabelSize = '64-bit' # get color transfer function/color map for 'p' pLUT = GetColorTransferFunction('p') # get opacity transfer function/opacity map for 'p' pPWF = GetOpacityTransferFunction('p') # trace defaults for the display properties. a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.Representation = 'Surface' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ColorArrayName = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.LookupTable = pLUT a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectTCoordArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectNormalArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectTangentArray = 'None' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OSPRayScaleArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OSPRayScaleFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectOrientationVectors = 'U' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleFactor = 0.01 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SelectScaleArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GlyphType = 'Arrow' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GlyphTableIndexArray = 'p' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.GaussianRadius = 0.0005 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.SetScaleArray = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleTransferFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityArray = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityTransferFunction = 'PiecewiseFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.DataAxesGrid = 'GridAxesRepresentation' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.PolarAxes = 'PolarAxesRepresentation' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScalarOpacityFunction = pPWF a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScalarOpacityUnitDistance = 0.0018 a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityArrayName = ['POINTS', 'p'] a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ExtractedBlockIndex = 1 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 606.7, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAMDisplay.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 606.7, 1.0, 0.5, 0.0] # create a new 'Clip' clip1 = Clip(registrationName='Clip1', Input=a3D_Case20_halfGeom_70_FlR_0_0009631_WaterOpenFOAM) clip1.ClipType = 'Plane' clip1.HyperTreeGridClipper = 'Plane' clip1.Scalars = ['POINTS', 'p'] clip1.Value = 491.24 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip1Display.ScaleTransferFunction.Points = [418.45, 0.0, 0.5, 0.0, 592.33, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip1Display.OpacityTransferFunction.Points = [418.45, 0.0, 0.5, 0.0, 592.33, 1.0, 0.5, 0.0] # create a new 'Clip' clip2 = Clip(registrationName='Clip2', Input=clip1) clip2.ClipType = 'Plane' clip2.HyperTreeGridClipper = 'Plane' clip2.Scalars = ['POINTS', 'p'] clip2.Value = 491.24 # init the 'Plane' selected for 'ClipType' clip2.ClipType.Origin = [0, 0.0038, 0.0065] # init the 'Plane' selected for 'HyperTreeGridClipper' clip2.HyperTreeGridClipper.Origin = [0, 0.0038, 0.0065] # Properties modified on clip2.ClipType clip2.ClipType.Origin = [0.0, 0.045, 0.0] clip2.ClipType.Normal = [0.0, 1.0, 0.0] # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip2Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip2Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # create a new 'Clip' clip3 = Clip(registrationName='Clip3', Input=clip2) clip3.ClipType = 'Plane' clip3.HyperTreeGridClipper = 'Plane' clip3.Scalars = ['POINTS', 'p'] clip3.Value = 466.04 # init the 'Plane' selected for 'ClipType' clip3.ClipType.Origin = [0.0, 0.0, 0.0065] # init the 'Plane' selected for 'HyperTreeGridClipper' clip3.HyperTreeGridClipper.Origin = [0.0, 0.0, 0.0065] # Properties modified on clip3 clip3.Invert = 0 # Properties modified on clip3.ClipType clip3.ClipType.Origin = [0.0, 0.0, 0.0017] clip3.ClipType.Normal = [0.0, 0.0, 1.0] # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' clip3Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' clip3Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 556.30, 1.0, 0.5, 0.0] # create a new 'Iso Volume' isoVolume1 = IsoVolume(registrationName='IsoVolume1', Input=clip3) isoVolume1.InputScalars = ['POINTS', 'p'] isoVolume1.ThresholdRange = [375.79, 556.30] # Properties modified on isoVolume1 isoVolume1.InputScalars = ['POINTS', 'alpha.water'] isoVolume1.ThresholdRange = [0.91, 1.0] # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' isoVolume1Display.ScaleTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 554.07, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' isoVolume1Display.OpacityTransferFunction.Points = [375.79, 0.0, 0.5, 0.0, 554.07, 1.0, 0.5, 0.0] # hide data in view Hide(clip3, renderView1) # show color bar/color legend isoVolume1Display.SetScalarBarVisibility(renderView1, True) # update the view to ensure updated data information renderView1.Update() # set scalar coloring ColorBy(isoVolume1Display, ('POINTS', 'alpha.water')) # Hide the scalar bar for this color map if no visible data is colored by it. HideScalarBarIfNotNeeded(pLUT, renderView1) # rescale color and/or opacity maps used to include current data range isoVolume1Display.RescaleTransferFunctionToDataRange(True, False) # show color bar/color legend isoVolume1Display.SetScalarBarVisibility(renderView1, True) # get color transfer function/color map for 'alphawater' alphawaterLUT = GetColorTransferFunction('alphawater') # get opacity transfer function/opacity map for 'alphawater' alphawaterPWF = GetOpacityTransferFunction('alphawater') # create a new 'Integrate Variables' integrateVariables1 = IntegrateVariables(registrationName='IntegrateVariables1', Input=isoVolume1) # Create a new 'SpreadSheet View' spreadSheetView1 = CreateView('SpreadSheetView') spreadSheetView1.ColumnToSort = '' spreadSheetView1.BlockSize = 1024 # show data in view integrateVariables1Display = Show(integrateVariables1, spreadSheetView1, 'SpreadSheetRepresentation') # get layout layout1 = GetLayoutByName("Layout #1") # add view to a layout so it's visible in UI AssignViewToLayout(view=spreadSheetView1, layout=layout1, hint=0) # update the view to ensure updated data information renderView1.Update() # update the view to ensure updated data information spreadSheetView1.Update() # Properties modified on spreadSheetView1 spreadSheetView1.FieldAssociation = 'Cell Data' # Properties modified on spreadSheetView1 spreadSheetView1.HiddenColumnLabels = [] # Properties modified on spreadSheetView1 spreadSheetView1.HiddenColumnLabels = ['Cell ID', 'Cell Type', 'UMean', 'UMean_Magnitude', 'UPrime2Mean', 'UPrime2Mean_Magnitude', 'U', 'U_Magnitude', 'pMean', 'pPrime2Mean', 'Block Number'] # set active source SetActiveSource(integrateVariables1) SelectIDs(IDs=[-1, 0], FieldType=0, ContainingCells=0) |
|
Tags |
paraview, python, python script |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 18:13 |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 07:31 |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 21:53 |
centOS 5.6 : paraFoam not working | yossi | OpenFOAM Installation | 2 | October 9, 2013 01:41 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 03:23 |