|
| 1 | +# extract contour plots from the 90 degree bend from Sudo et al. |
| 2 | +# check below the different places to modify the details of the contour |
| 3 | + |
| 4 | +# trace generated using paraview version 5.11.0-RC2 |
| 5 | + |
| 6 | +# diameter |
| 7 | +D = 0.104 |
| 8 | +# radius of curvature |
| 9 | +R = 0.208 |
| 10 | +# |
| 11 | + |
| 12 | +#### import the simple module from the paraview |
| 13 | +from paraview.simple import * |
| 14 | +#### disable automatic camera reset on 'Show' |
| 15 | +paraview.simple._DisableFirstRenderCameraReset() |
| 16 | +import numpy as np |
| 17 | +import math |
| 18 | + |
| 19 | +# create a new 'XML MultiBlock Data Reader' |
| 20 | +sudovtm = XMLMultiBlockDataReader(registrationName='sudo.vtm', FileName=['sudo.vtm']) |
| 21 | +sudovtm.PointArrayStatus = ['Pressure', 'Velocity', 'Turb_Kin_Energy', 'Omega', 'Pressure_Coefficient', 'Density', 'Laminar_Viscosity', 'Skin_Friction_Coefficient', 'Heat_Flux', 'Y_Plus', 'Residual_Pressure', 'Residual_Velocity', 'Residual_TKE', 'Residual_Omega', 'Eddy_Viscosity'] |
| 22 | + |
| 23 | +# set active source |
| 24 | +SetActiveSource(sudovtm) |
| 25 | + |
| 26 | +# get active view |
| 27 | +renderView1 = GetActiveViewOrCreate('RenderView') |
| 28 | + |
| 29 | +# create a new 'Slice' |
| 30 | +slice1 = Slice(registrationName='Slice1', Input=sudovtm) |
| 31 | +slice1.SliceType = 'Plane' |
| 32 | + |
| 33 | + |
| 34 | +################################################################################ |
| 35 | +# ### 1/5 change the location of the slice plane ### # |
| 36 | +################################################################################ |
| 37 | +# CASE 1 |
| 38 | +# Z/D = -1.0 |
| 39 | +#slice1.SliceType.Origin = [0.0, 0.0, -0.104] |
| 40 | +#slice1.SliceType.Normal = [0.0, 0.0, 1.0] |
| 41 | + |
| 42 | +# CASE 2 |
| 43 | +# Z/D = 0.0 (phi=0.0) |
| 44 | +slice1.SliceType.Origin = [0.208, 0.0, 0.0] |
| 45 | +slice1.SliceType.Normal = [0.0, 0.0, 1.0] |
| 46 | + |
| 47 | +# CASE 3 |
| 48 | +# phi=30.0 |
| 49 | +#ALPHA=30.0 |
| 50 | +#slice1.SliceType.Origin = [0.208, 0.0, 0.0] |
| 51 | +#slice1.SliceType.Normal = [np.sin(math.radians(ALPHA)), 0.0, np.cos(math.radians(ALPHA))] |
| 52 | + |
| 53 | +# CASE 4 |
| 54 | +# phi=60.0 |
| 55 | +#ALPHA=60 |
| 56 | +#slice1.SliceType.Origin = [0.208, 0.0, 0.0] |
| 57 | +#slice1.SliceType.Normal = [np.sin(math.radians(ALPHA)), 0.0, np.cos(math.radians(ALPHA))] |
| 58 | + |
| 59 | +# CASE 5 |
| 60 | +# phi = 90.0 |
| 61 | +#slice1.SliceType.Origin = [0.208, 0.0, 0.0] |
| 62 | +#slice1.SliceType.Normal = [1.0, 0.0, 0.0] |
| 63 | + |
| 64 | +# CASE 6 |
| 65 | +# Z/D = +1.0 |
| 66 | +#slice1.SliceType.Origin = [0.312, 0.0, 0.0] |
| 67 | +#slice1.SliceType.Normal = [1.0, 0.0, 0.0] |
| 68 | +################################################################################ |
| 69 | +################################################################################ |
| 70 | + |
| 71 | +# create a new 'Calculator' |
| 72 | +calculator1 = Calculator(registrationName='Calculator1', Input=slice1) |
| 73 | + |
| 74 | +# Properties modified on calculator1 |
| 75 | +################################################################################ |
| 76 | +# ### 2/5 compute the normalized velocity in the plane ### # |
| 77 | +################################################################################ |
| 78 | +# CASE 1 |
| 79 | +# Z/D = -1.0 |
| 80 | +#calculator1.Function = 'Velocity_Z/8.7' |
| 81 | + |
| 82 | +# CASE 2 |
| 83 | +# Z/D = 0.0 (phi=0) |
| 84 | +calculator1.Function = 'Velocity_Z/8.7' |
| 85 | + |
| 86 | +# CASE 3 |
| 87 | +# phi=30 |
| 88 | +#calculator1.Function = '(0.5*Velocity_X+0.5*sqrt(3)*Velocity_Z)/(8.7)' |
| 89 | + |
| 90 | +# CASE 4 |
| 91 | +# phi=60 |
| 92 | +#calculator1.Function = '(0.5*sqrt(3)*Velocity_X+0.5*Velocity_Z)/(8.7)' |
| 93 | + |
| 94 | +# CASE 5 |
| 95 | +# phi=90 |
| 96 | +#calculator1.Function = 'Velocity_X/8.7' |
| 97 | + |
| 98 | +# CASE 6 |
| 99 | +# Z/D = 1.0 |
| 100 | +#calculator1.Function = 'Velocity_X/8.7' |
| 101 | +################################################################################ |
| 102 | +################################################################################ |
| 103 | + |
| 104 | +# show data in view |
| 105 | +calculator1Display = Show(calculator1, renderView1, 'GeometryRepresentation') |
| 106 | +# hide color bar/color legend |
| 107 | +calculator1Display.SetScalarBarVisibility(renderView1, False) |
| 108 | + |
| 109 | +# get color transfer function/color map for 'Result' |
| 110 | +resultLUT = GetColorTransferFunction('Result') |
| 111 | +# Apply a preset using its name. Note this may not work as expected when presets have duplicate names. |
| 112 | +resultLUT.ApplyPreset('Black-Body Radiation', True) |
| 113 | +# Properties modified on resultLUT |
| 114 | +resultLUT.NumberOfTableValues = 32 |
| 115 | + |
| 116 | +# create a new 'Contour' |
| 117 | +contour1 = Contour(registrationName='Contour1', Input=calculator1) |
| 118 | +contour1.ContourBy = ['POINTS', 'Result'] |
| 119 | +# Properties modified on contour1 |
| 120 | +################################################################################ |
| 121 | +# ### 3/5 set the specific isocontour lines for the plane ### # |
| 122 | +################################################################################ |
| 123 | + |
| 124 | +# CASE 1 |
| 125 | +# Z/D = -1.0 |
| 126 | +#contour1.Isosurfaces = [0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20] |
| 127 | + |
| 128 | +# CASE 2 |
| 129 | +# Z/D = 0.0 |
| 130 | +contour1.Isosurfaces = [0.85, 0.9, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20] |
| 131 | + |
| 132 | +#CASE 3 |
| 133 | +# phi = 30.0 |
| 134 | +#contour1.Isosurfaces = [0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20] |
| 135 | + |
| 136 | +# CASE 4 |
| 137 | +# phi = 60.0 |
| 138 | +#contour1.Isosurfaces = [0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20] |
| 139 | + |
| 140 | +# CASE 5 |
| 141 | +# phi = 90.0 |
| 142 | +#contour1.Isosurfaces = [0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.05] |
| 143 | + |
| 144 | +# CASE 6 |
| 145 | +# Z/D = +1.0 |
| 146 | +#contour1.Isosurfaces = [0.75, 0.80, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15] |
| 147 | +################################################################################ |
| 148 | + |
| 149 | + |
| 150 | +# show data in view |
| 151 | +contour1Display = Show(contour1, renderView1, 'GeometryRepresentation') |
| 152 | +# turn off scalar coloring |
| 153 | +ColorBy(contour1Display, None) |
| 154 | +# Hide the scalar bar for this color map if no visible data is colored by it. |
| 155 | +HideScalarBarIfNotNeeded(resultLUT, renderView1) |
| 156 | +# change solid color to black |
| 157 | +contour1Display.DiffuseColor = [0.0, 0.0, 0.0] |
| 158 | +# increase the line thickness |
| 159 | +contour1Display.LineWidth = 2.0 |
| 160 | + |
| 161 | +# create a new 'Extract Block' |
| 162 | +extractBlock1 = ExtractBlock(registrationName='ExtractBlock1', Input=calculator1) |
| 163 | +# Properties modified on extractBlock1 |
| 164 | +extractBlock1.Selectors = ['/Root/Zone0IncompFluid/Boundary/wall_1', '/Root/Zone0IncompFluid/Boundary/wall_2', '/Root/Zone0IncompFluid/Boundary/wall_bend'] |
| 165 | +# show data in view |
| 166 | +extractBlock1Display = Show(extractBlock1, renderView1, 'GeometryRepresentation') |
| 167 | +# change solid color |
| 168 | +extractBlock1Display.DiffuseColor = [0.0, 0.0, 0.0] |
| 169 | + |
| 170 | +# Hide orientation axes |
| 171 | +renderView1.OrientationAxesVisibility = 0 |
| 172 | + |
| 173 | +# reset view to fit data |
| 174 | +renderView1.ResetCamera(False) |
| 175 | + |
| 176 | +# get layout |
| 177 | +layout1 = GetLayout() |
| 178 | + |
| 179 | +# layout/tab size in pixels |
| 180 | +layout1.SetSize(1304, 746) |
| 181 | + |
| 182 | +################################################################################ |
| 183 | +# 4/5 current camera placement for renderView1, view is distance L before the plane |
| 184 | +################################################################################ |
| 185 | + |
| 186 | +L = 0.115 |
| 187 | + |
| 188 | +# CASE 1 |
| 189 | +# view for Z/D=-1 |
| 190 | +#renderView1.CameraFocalPoint = [0.0, 0.026, -0.104] |
| 191 | +#renderView1.CameraPosition = [0.0, 0.026, -0.104-L] |
| 192 | + |
| 193 | +# CASE 2 |
| 194 | +# view for Z/D=0 |
| 195 | +renderView1.CameraFocalPoint = [0.0, 0.026, 0.000] |
| 196 | +renderView1.CameraPosition = [0.0, 0.026, -0.000-L] |
| 197 | + |
| 198 | +# CASE 3 |
| 199 | +# view for phi=30 |
| 200 | +#ALPHA=30 |
| 201 | +#X = R - R * np.cos(math.radians(ALPHA)) |
| 202 | +#Z = R * np.sin(math.radians(ALPHA)) |
| 203 | +#renderView1.CameraFocalPoint = [X, 0.026, Z] |
| 204 | +#Xp = X - L*np.sin(math.radians(ALPHA)) |
| 205 | +#Zp = Z - L*np.cos(math.radians(ALPHA)) |
| 206 | +#renderView1.CameraPosition = [Xp, 0.026, Zp] |
| 207 | + |
| 208 | +# CASE 4 |
| 209 | +# view for phi=60 |
| 210 | +#ALPHA=60 |
| 211 | +#X = R - R * np.cos(math.radians(ALPHA)) |
| 212 | +#Z = R * np.sin(math.radians(ALPHA)) |
| 213 | +#renderView1.CameraFocalPoint = [X, 0.026, Z] |
| 214 | +#Xp = X - L*np.sin(math.radians(ALPHA)) |
| 215 | +#Zp = Z - L*np.cos(math.radians(ALPHA)) |
| 216 | +#renderView1.CameraPosition = [Xp, 0.026, Zp] |
| 217 | + |
| 218 | +# CASE 5 |
| 219 | +# view for phi=90 |
| 220 | +#renderView1.CameraFocalPoint = [0.208, 0.026, 0.208] |
| 221 | +#renderView1.CameraPosition = [0.208-L, 0.026, 0.208] |
| 222 | + |
| 223 | +# CASE 6 |
| 224 | +# view for Z/D = +1 |
| 225 | +#renderView1.CameraFocalPoint = [0.312, 0.026, 0.208] |
| 226 | +#renderView1.CameraPosition = [0.312-L, 0.026, 0.208] |
| 227 | + |
| 228 | +# |
| 229 | +renderView1.CameraViewUp = [0.0, 1.0, 0.0] |
| 230 | +renderView1.CameraParallelScale = 0.058 |
| 231 | +################################################################################ |
| 232 | + |
| 233 | +# update the view to ensure updated data information |
| 234 | +renderView1.Update() |
| 235 | + |
| 236 | +# 5/5 save screenshot |
| 237 | +# CASE 1 |
| 238 | +#SaveScreenshot('./slice_ZD_minus_1.png', renderView1, ImageResolution=[1304, 746]) |
| 239 | +# CASE 2 |
| 240 | +SaveScreenshot('./slice_ZD_0.png', renderView1, ImageResolution=[1304, 746]) |
| 241 | +# CASE 3 |
| 242 | +#SaveScreenshot('./slice_phi_30.png', renderView1, ImageResolution=[1304, 746]) |
| 243 | +# CASE 4 |
| 244 | +#SaveScreenshot('./slice_phi_60.png', renderView1, ImageResolution=[1304, 746]) |
| 245 | +# CASE 5 |
| 246 | +#SaveScreenshot('./slice_phi_90.png', renderView1, ImageResolution=[1304, 746]) |
| 247 | +# CASE 1 |
| 248 | +#SaveScreenshot('./slice_ZD_plus_1.png', renderView1, ImageResolution=[1304, 746]) |
| 249 | + |
0 commit comments