Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or...

21
Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK Rasmus Hemph December 13:th 2007 OpenFOAM Introdutory Course Chalmers University of Technology Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brie

Transcript of Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or...

Page 1: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Visualization and Post Processing ofOpenFOAM results

— a Brief Introduction to VTK

Rasmus Hemph

December 13:th 2007OpenFOAM Introdutory Course

Chalmers University of Technology

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 2: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Post Processing in OF

No built in post processing tool.Choose your weapon.

Ensight, Fieldview,OpenDX, ParaView, GMVConverters (VTK, Fluent,GMV) or readers (Ensight,OpenDX, Paraview)

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 3: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

ParaView

ParaView. Developedsince 2002 by Kitware Incand Los Alamos NationalLaboratory (USA).Open SourceCan do parallelvisualization of largemeshes (> 1 billion cells)Plotting, meshing, probing,vectors, volumetricvisualizationScriptable (Python)

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 4: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

ParaView and OpenFOAM

Different ways of connecting ParaView to OF.With paraFoam (included in distribution)

+ Easy to use, just a wrapper script around ParaView– Old version

With ParaView from www.paraview.org.+ Easy to use– Need to run foamToVTK every time

Compile ParaView from www.paraview.org.+ Can read foam files directly (With reader from foammailing list)+ Better animations (divX)– More work involved

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 5: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Paraview (below the surface)

ParaView is a graphical userinterface to the VTK-library.VTK (The Visualization Toolkit).It is an open source, freelyavailable software system for3D computer graphics, imageprocessing, and visualization.Written in C++. Wrappersexists for Java, Tcl and Python.

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 6: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Paraview (below the surface)

With some knowledge in VTK,most visualization/post-processing/data-handlingneeds can be handledautomatically.

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 7: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

Want to display the pressure field of the elbow tutorial andoutput the result to an image file.

Step 1. Run the case: icoFoam . elbowStep 2. Run the utility foamToVTK on the case so that weget VTK-readable files.foamToVTK . elbow.This creates a VTK-folder in elbow directory.Step 3. Run python-script on output.

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 8: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

Step 3. Run python-script on output. ./plotElbow.py

import osfrom vtk import *

#set the fileName for the current case

myFileName = ’elbow/VTK/elbow200.vtk’

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 9: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

#Need a reader for unstructured gridsreader = vtkUnstructuredGridReader()reader.SetFileName(myFileName)reader.Update()

#In OpenFOAM all results are Field-data.#This has no concept of cells or nodes.#Need to filter to cells.

toCellFilter = vtkFieldDataToAttributeDataFilter()toCellFilter.SetInput(reader.GetOutput())toCellFilter.SetInputFieldToCellDataField()

toCellFilter.SetOutputAttributeDataToCellData()

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 10: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

Assign here which field#we are interested in.toCellFilter.SetScalarComponent(0,’p’,0)

#This is all we need to do do calculations.#To get 3D image, need some more components.

#First a window

renWin = vtkRenderWindow()

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 11: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

#Then a renderer. Renders data to an image.ren1 = vtkRenderer()

#Add renderer to windowrenWin.AddRenderer(ren1)

#Add pressure data to the renderer.#Mapping assigns data to colors and geometry.mapper = vtkDataSetMapper()mapper.SetInput(toCellFilter.GetOutput())

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 12: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

#The object is assigned to an actor.actor = vtkActor()actor.SetMapper(mapper)

#Add actor to renderer.ren1.AddActor(actor)

#Finally render image

renWin.Render()

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 13: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Example

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 14: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Basic work flow with VTK

Read fileFilter data (Extract regions, create vectors etc)Map data to colorsRender image

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 15: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

More examples – ideas

Keep track of longsimulations. Publish imageon web server.Difficult to do probing ordata treatment.Simple custom GUIcreation (through Tk).Advanced animations.Image maps.”Anything” – by help ofPython modules. :

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 16: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

More examples – ideas

Keep track of longsimulations. Publish imageon web server.Difficult to do probing ordata treatment.Simple custom GUIcreation (through Tk).Advanced animations.Image maps.”Anything” – by help ofPython modules. :

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 17: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

More examples – ideas

Keep track of longsimulations. Publish imageon web server.Difficult to do probing ordata treatment.Simple custom GUIcreation (through Tk).Advanced animations.Image maps.”Anything” – by help ofPython modules. :

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 18: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

More examples – ideas

Keep track of longsimulations. Publish imageon web server.Difficult to do probing ordata treatment.Simple custom GUIcreation (through Tk).Advanced animations.Image maps.”Anything” – by help ofPython modules. :

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 19: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

More examples – ideas

Keep track of longsimulations. Publish imageon web server.Difficult to do probing ordata treatment.Simple custom GUIcreation (through Tk).Advanced animations.Image maps.”Anything” – by help ofPython modules. :

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 20: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

Learn More

VTK booksNGSSC Course in scientific visualization (?)VTK Wiki

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK

Page 21: Visualization and Post Processing of OpenFOAM results ... · Converters (VTK, Fluent, GMV) or readers (Ensight, ... Rasmus Hemph Visualization and Post Processing of OpenFOAM results

The End

Rasmus Hemph Visualization and Post Processing of OpenFOAM results — a Brief Introduction to VTK