|
| 1 | +# state file generated using paraview version 5.11.0 |
| 2 | +import paraview |
| 3 | +paraview.compatibility.major = 5 |
| 4 | +paraview.compatibility.minor = 11 |
| 5 | + |
| 6 | +#### import the simple module from the paraview |
| 7 | +from paraview.simple import * |
| 8 | +import os, re |
| 9 | +#### disable automatic camera reset on 'Show' |
| 10 | +paraview.simple._DisableFirstRenderCameraReset() |
| 11 | + |
| 12 | +# ---------------------------------------------------------------- |
| 13 | +# setup views used in the visualization |
| 14 | +# ---------------------------------------------------------------- |
| 15 | + |
| 16 | +# get the material library |
| 17 | +materialLibrary1 = GetMaterialLibrary() |
| 18 | + |
| 19 | +# Create a new 'Render View' |
| 20 | +renderView1 = CreateView('RenderView') |
| 21 | +renderView1.ViewSize = [2328, 1162] |
| 22 | +renderView1.InteractionMode = '2D' |
| 23 | +renderView1.AxesGrid = 'GridAxes3DActor' |
| 24 | +renderView1.CenterOfRotation = [0.5, 0.5, 0.0] |
| 25 | +renderView1.StereoType = 'Crystal Eyes' |
| 26 | +renderView1.CameraPosition = [0.5, 0.5, 2.7320508075688776] |
| 27 | +renderView1.CameraFocalPoint = [0.5, 0.5, 0.0] |
| 28 | +renderView1.CameraFocalDisk = 1.0 |
| 29 | +renderView1.CameraParallelScale = 0.7071067811865476 |
| 30 | +renderView1.BackEnd = 'OSPRay raycaster' |
| 31 | +renderView1.OSPRayMaterialLibrary = materialLibrary1 |
| 32 | + |
| 33 | +SetActiveView(None) |
| 34 | + |
| 35 | +# ---------------------------------------------------------------- |
| 36 | +# setup view layouts |
| 37 | +# ---------------------------------------------------------------- |
| 38 | + |
| 39 | +# create new layout object 'Layout #1' |
| 40 | +layout1 = CreateLayout(name='Layout #1') |
| 41 | +layout1.AssignView(0, renderView1) |
| 42 | +layout1.SetSize(2328, 1162) |
| 43 | + |
| 44 | +# ---------------------------------------------------------------- |
| 45 | +# restore active view |
| 46 | +SetActiveView(renderView1) |
| 47 | +# ---------------------------------------------------------------- |
| 48 | + |
| 49 | +# ---------------------------------------------------------------- |
| 50 | +# setup the data processing pipelines |
| 51 | +# ---------------------------------------------------------------- |
| 52 | + |
| 53 | +# create a new 'VisItSiloReader' |
| 54 | +case_dir=os.getcwd() |
| 55 | +print(case_dir) |
| 56 | +# create a new 'VisItSiloReader' |
| 57 | +files = glob.glob(f"{case_dir}/silo_hdf5/root/*") |
| 58 | +print(files) |
| 59 | +sorted_files = sorted(files, key=lambda x: int(x.rsplit('_', 1)[-1][:-5])) |
| 60 | +print(sorted_files) |
| 61 | +collection_0silo = VisItSiloReader(registrationName='collection_0.silo*', FileName=sorted_files) |
| 62 | +collection_0silo.MeshStatus = ['rectilinear_grid'] |
| 63 | +collection_0silo.CellArrayStatus = ['alpha1', 'alpha2', 'alpha_rho1', 'alpha_rho2', 'pres', 'vel1', 'vel2'] |
| 64 | + |
| 65 | +# ---------------------------------------------------------------- |
| 66 | +# setup the visualization in view 'renderView1' |
| 67 | +# ---------------------------------------------------------------- |
| 68 | + |
| 69 | +# show data from collection_0silo |
| 70 | +collection_0siloDisplay = Show(collection_0silo, renderView1, 'UniformGridRepresentation') |
| 71 | + |
| 72 | +# get 2D transfer function for 'vtkBlockColors' |
| 73 | +vtkBlockColorsTF2D = GetTransferFunction2D('vtkBlockColors') |
| 74 | + |
| 75 | +# get color transfer function/color map for 'vtkBlockColors' |
| 76 | +vtkBlockColorsLUT = GetColorTransferFunction('vtkBlockColors') |
| 77 | +vtkBlockColorsLUT.InterpretValuesAsCategories = 1 |
| 78 | +vtkBlockColorsLUT.AnnotationsInitialized = 1 |
| 79 | +vtkBlockColorsLUT.TransferFunction2D = vtkBlockColorsTF2D |
| 80 | +vtkBlockColorsLUT.Annotations = ['0', '0', '1', '1', '2', '2', '3', '3', '4', '4', '5', '5', '6', '6', '7', '7', '8', '8', '9', '9', '10', '10', '11', '11'] |
| 81 | +vtkBlockColorsLUT.ActiveAnnotatedValues = ['0', '1', '2', '3'] |
| 82 | +vtkBlockColorsLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.63, 0.63, 1.0, 0.67, 0.5, 0.33, 1.0, 0.5, 0.75, 0.53, 0.35, 0.7, 1.0, 0.75, 0.5] |
| 83 | + |
| 84 | +# get opacity transfer function/opacity map for 'vtkBlockColors' |
| 85 | +vtkBlockColorsPWF = GetOpacityTransferFunction('vtkBlockColors') |
| 86 | + |
| 87 | +# trace defaults for the display properties. |
| 88 | +collection_0siloDisplay.Representation = 'Surface' |
| 89 | +collection_0siloDisplay.ColorArrayName = ['FIELD', 'vtkBlockColors'] |
| 90 | +collection_0siloDisplay.LookupTable = vtkBlockColorsLUT |
| 91 | +collection_0siloDisplay.SelectTCoordArray = 'None' |
| 92 | +collection_0siloDisplay.SelectNormalArray = 'None' |
| 93 | +collection_0siloDisplay.SelectTangentArray = 'None' |
| 94 | +collection_0siloDisplay.OSPRayScaleFunction = 'PiecewiseFunction' |
| 95 | +collection_0siloDisplay.SelectOrientationVectors = 'None' |
| 96 | +collection_0siloDisplay.ScaleFactor = 0.1 |
| 97 | +collection_0siloDisplay.SelectScaleArray = 'None' |
| 98 | +collection_0siloDisplay.GlyphType = 'Arrow' |
| 99 | +collection_0siloDisplay.GlyphTableIndexArray = 'None' |
| 100 | +collection_0siloDisplay.GaussianRadius = 0.005 |
| 101 | +collection_0siloDisplay.SetScaleArray = [None, ''] |
| 102 | +collection_0siloDisplay.ScaleTransferFunction = 'PiecewiseFunction' |
| 103 | +collection_0siloDisplay.OpacityArray = [None, ''] |
| 104 | +collection_0siloDisplay.OpacityTransferFunction = 'PiecewiseFunction' |
| 105 | +collection_0siloDisplay.DataAxesGrid = 'GridAxesRepresentation' |
| 106 | +collection_0siloDisplay.PolarAxes = 'PolarAxesRepresentation' |
| 107 | +collection_0siloDisplay.ScalarOpacityUnitDistance = 0.06564197879454707 |
| 108 | +collection_0siloDisplay.ScalarOpacityFunction = vtkBlockColorsPWF |
| 109 | +collection_0siloDisplay.TransferFunction2D = vtkBlockColorsTF2D |
| 110 | +collection_0siloDisplay.OpacityArrayName = ['CELLS', 'alpha1'] |
| 111 | +collection_0siloDisplay.ColorArray2Name = ['CELLS', 'alpha1'] |
| 112 | +collection_0siloDisplay.SliceFunction = 'Plane' |
| 113 | +collection_0siloDisplay.SelectInputVectors = [None, ''] |
| 114 | +collection_0siloDisplay.WriteLog = '' |
| 115 | + |
| 116 | +# init the 'Plane' selected for 'SliceFunction' |
| 117 | +collection_0siloDisplay.SliceFunction.Origin = [0.5, 0.5, 0.0] |
| 118 | + |
| 119 | +# setup the color legend parameters for each legend in this view |
| 120 | + |
| 121 | +# get color legend/bar for vtkBlockColorsLUT in view renderView1 |
| 122 | +vtkBlockColorsLUTColorBar = GetScalarBar(vtkBlockColorsLUT, renderView1) |
| 123 | +vtkBlockColorsLUTColorBar.Title = 'vtkBlockColors' |
| 124 | +vtkBlockColorsLUTColorBar.ComponentTitle = '' |
| 125 | + |
| 126 | +# set color bar visibility |
| 127 | +vtkBlockColorsLUTColorBar.Visibility = 1 |
| 128 | + |
| 129 | +# show color legend |
| 130 | +collection_0siloDisplay.SetScalarBarVisibility(renderView1, True) |
| 131 | + |
| 132 | +# ---------------------------------------------------------------- |
| 133 | +# setup color maps and opacity mapes used in the visualization |
| 134 | +# note: the Get..() functions create a new object, if needed |
| 135 | +# ---------------------------------------------------------------- |
| 136 | + |
| 137 | +# ---------------------------------------------------------------- |
| 138 | +# restore active source |
| 139 | +SetActiveSource(collection_0silo) |
| 140 | +# ---------------------------------------------------------------- |
| 141 | + |
| 142 | +# Ensure all time steps are considered |
| 143 | +timeKeeper = GetTimeKeeper() |
| 144 | +timeSteps = timeKeeper.TimestepValues |
| 145 | + |
| 146 | +animationScene = GetAnimationScene() |
| 147 | + |
| 148 | +directory_path = f"{case_dir}/render" |
| 149 | +os.makedirs(directory_path, exist_ok=True) |
| 150 | + |
| 151 | +i = 0 |
| 152 | +# Save all timesteps |
| 153 | +for t in timeSteps: |
| 154 | + animationScene.AnimationTime = t |
| 155 | + SaveScreenshot(f"{case_dir}/render/pic.{i:04d}.png", renderView1, ImageResolution=[2110,722]) |
| 156 | + print(i) |
| 157 | + i = i + 1 |
| 158 | + |
0 commit comments