Introduction to Paraview and VTK

Description

  • VTK is a object-oriented high-level library for data processing and visualization, providing sophisticated functions like contouring, cutting, triangulation and mesh smoothing. The graphical output is hardware-accelerated by using the OpenGL library. The library is written in C++, but there are bindings available for some other languages, especially the scripting languages Tcl and Python.
  • Paraview is a graphical user interface based on VTK, hence, data can be processed without writing code. Since Paraview implements a client-server architecture around the VTK modules, not all VTK functions is supported.

Both programs are developed by Kitware Inc. and available as Open Source Software.

Basic Concept

The basic concept is a user-defined pipeline which passes the data from the source (= the input file) to the sink (= image on the screen or output file) through several filters.

  • The program sequence results from the desired data flow, so the user does not have to worry about the program logic — if there are several parallel data pipelines, then the processing is automatically parallelized (similar to a Unix shell script or a LabView program).
  • In VTK, every processing step is represented by a self-contained object which takes its input from the previous element in the pipeline and passes its output to the next one. In Tcl, this looks like that:
    pipelineObject SetInput [previousObject GetOutput]
  • Lazy evaluation: Only if a data sink requests an update, the data in the pipeline is recomputed. Starting from the sink, the update requests are handed on to the previous elements in the pipeline until the necessary source data is available; the newly computed data travels then downstream through the pipeline until the requesting sink is reached.

Geowall

Paraview has a 3D mode which can be activated with the command line parameter --stereo:

user@some_pc:~$ paraview --stereo

By default, a red-blue 3D mode is used, but with a small patch in the source code this can be changed to a full color stereo mode which works with polarized glasses on a computer with a dual-head graphics card, like the Geowall.

MPI

One remarkable feature of Paraview is its ability to handle large datasets. This can either be done by running Paraview on several machines:

$ mpirun -np 10 -machinefile mf.txt /usr/bin/paraview

Because X connections are disabled, distributed rendering must be switched off (View/3D View Properties: Composite off); the data and the processing can be done on the remote machines, but not the rendering.

Paraview can also be run on a computing cluster; the server process is started on the cluster head. The user interface must be run on an external machine (Paraview version 3.x and above):

user@clusterhead:~$ /usr/bin/pvserver
user@other_pc:~$ /usr/bin/paraview

Then: Go to the menu item File/Connect, enter the server name, and connect to it (use "manual connection").

If Paraview should be run on the cluster with MPI (only this makes really sense), the command line looks like that:

user@clusterhead:~$ mpirun -np 128 -machinefile mf.txt /usr/bin/pvserver --use-offscreen-rendering
user@other_pc:~$ /usr/bin/paraview

Usage — VTK

VTK can be found in the directory /home/SOFTWARE/VTK/; a typical Tcl script would look like this (opens the file given as the first command line parameter, writes it to the file given in the second parameter):

#!/usr/bin/tclsh8.4

package require vtk

vtkPolyDataReader reader
	reader SetFileName [lindex $argv 0]

vtkPolyDataWriter writer
	writer SetInput [reader GetOutput]
	writer SetFileName [lindex $argv 1]
	writer SetFileTypeToBinary
	writer Write

exit

Further Reading

  • My diploma thesis gives further details and examples.
  • The Paraview Guide: It mentions the basic concepts, starting from the user interface and very simple examples, and goes up to extending the user interface and writing custom modules. But there are only few practical examples
  • The VTK User's Guide, a boot about VTK, is currently discontinued. It is not a tutorial; but there are many example Tcl scripts for inspiration.