WindAroundBuildings Python script

# By Jesper G. Pedersen

from paraview.simple import *

Buildings = OpenFOAMReader(FileName='wind.foam')
Buildings.MeshRegions = ['buildings']

renderView1 = GetActiveViewOrCreate('RenderView')

BuildingsDisplay = Show(Buildings, renderView1)
BuildingsDisplay.Representation = 'Surface'
BuildingsDisplay.ColorArrayName=[None, '']
BuildingsDisplay.DiffuseColor = [0.7, 0.7, 0.7]

Ground = OpenFOAMReader(FileName='wind.foam')
Ground.MeshRegions = ['ground']
GroundDisplay = Show(Ground, renderView1)
GroundDisplay.Representation = 'Surface With Edges'
GroundDisplay.ColorArrayName=[None, '']
GroundDisplay.DiffuseColor = [0.8, 0.8, 0.8]
GroundDisplay.EdgeColor = [0, 0, 0]

sliceReader = OpenFOAMReader(FileName='wind.foam')
slice1 = Slice(Input=sliceReader)
slice1.SliceType.Normal = [0.0, 1.0, 0.0]
slice1Display = Show(slice1, renderView1)
slice1Display.Representation = 'Surface'

ColorBy(slice1Display, ('POINTS', 'U', 'Magnitude'))
slice1Display.SetScalarBarVisibility(renderView1, True)

uLUT = GetColorTransferFunction('U')
uLUT.ApplyPreset('jet', True)
uLUT.RescaleTransferFunction(0.0, 16.0)
uLUTColorBar = GetScalarBar(uLUT, renderView1)
uLUTColorBar.TitleColor = [0.0, 0.0, 0.0]
uLUTColorBar.LabelColor = [0.0, 0.0, 0.0]
uLUTColorBar.AddRangeLabels = 0
uLUTColorBar.Title = 'Wind speed'
uLUTColorBar.ComponentTitle = '[m/s]'

renderView1.UseGradientBackground=False
renderView1.Background = [1., 1 , 1.]

renderView1.CameraPosition = [465.4, -480.2, 201.9]
renderView1.CameraFocalPoint = [194.6, 53.2, 40.6]
renderView1.CameraViewUp = [-0.15, 0.2, 1.0]
renderView1.CameraParallelScale = 234.8

renderView1.OrientationAxesVisibility = 0

animationscene = GetAnimationScene()
animationscene.GoToLast()

c=0

for y in range(-45,226,1):
   c=c+1

   if c <10:
     pre = '00'
   elif c<100:
     pre = '0'
   else:
     pre = ''

   slice1.SliceType.Origin = [0.0, y, 0.0]
   renderView1.ViewSize = [800, 400]
   name = 'slice'+pre+str(c)+'.png'
   print name
   SaveScreenshot(name, magnification=1, quality=100, view=renderView1)

#Make animation from png's using Imagemagick:
#convert -delay 7 -density 100 -reverse -duplicate 1,-2-1 -loop 0 *.png  animation.gif