[vtkusers] HELP Wanted: Visualizing data from an OpenFOAM simulation

Andre Zimmer andre.zimmer at rwth-aachen.de
Tue Nov 8 13:08:40 EST 2016


Hi,
by now I have spend days trying to visualize data from the OpenFOAM 
sample function object.
Here is a small test case:
https://www.dropbox.com/s/5bhic1ms0anzrno/U_nearWalls.vtk?dl=0

No matter what I do I always get a gray car. I have tried specifically 
setting the scalar, vector, array, transforming and all kinds of stuff 
without success.
In the simplest form I think the Python code should look like this:

import vtk
  
file_name = "U_nearWalls.vtk"

reader = vtk.vtkPolyDataReader()
reader.SetFileName(file_name)
reader.ReadAllScalarsOn()
reader.ReadAllVectorsOn()
reader.Update()

mapper=vtk.vtkPolyDataMapper()
mapper.SetInputConnection(reader.GetOutputPort())

actor=vtk.vtkActor()
actor.SetMapper(mapper)

renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(0.1, 0.2, 0.4)
  
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetSize(300, 300)
  
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)

interactor.Initialize()
render_window.Render()
interactor.Start()


I am using Fedora 24, Python 2.7, VTK 6.3.
I assume it is only a small mistake I am making so hopefully someone can 
help.

Thank you in advance,
André


More information about the vtkusers mailing list