Using ParaView to Visualize MFIX Scalar Variables
Table of Contents
- 1.Introduction
- 1.1 Resources
- 1.2 Further Reading
- 2. Installation
- 2.1 Installing the Translator
- 2.2 Installing VTK
- 2.2.1 Preparing the VTK Directories
- 2.2.2 Compiling VTK
- 2.2.3 Avoiding the "Ambiguous" Bug
- 2.2.4 Running the Translator
- 2.3 Installing ParaView
- 3. A Quick Tour
- 3.1 Starting ParaView
- 3.2 Screen Layout
- 3.3 Reading Data
- 3.4 Adding a Cut Plane
- 3.5 Adding an Isosurface
- 3.6 Looping over Time
- 4. Tour Redux
- 4.1 Screen Layout Redux
- 4.2 Reading Data Redux
- 4.2.1 File Formats
- 4.2.2 Selecting Times
- 4.2.3 Selecting Variables
- 4.2.4 Modifying the Reader's Graphic
- 4.2.5 Moving the Objects
- 4.3 Clipping
- 4.4 Adding a Cut Plane Redux
- 4.4.1 Multiple Cuts
- 4.4.2 The Cut Function Group
- 4.4.3 The Cut Offset Group
- 4.5 Adding an Isosurface Redux
- 4.6 Looping over Time Redux
1. Introduction
This guide describes how to use ParaView, a scientific visualization application, to examine scalar variables produced by MFIX. The reader is expected to be familar with MFIX and its output variables.
Both cut plane and isosurface methods are described, along with other features that even novice ParaView users are likely to find useful.
This guide is not a complete description of using ParaView to visualize scalar MFIX variables, but does outline specific steps which can be used to quickly produce useful visualizations.
It is highly recommended that the reader obtain a copy of the book, "The ParaView Guide", available through the ParaView site, www.paraview.org. This book is the only complete documentation for ParaView, and is referenced in this document as the "PVG".
These notes refer to ParaView 2.0.1.
1.1 Resources
Additional information can be found on these sites.
- www.mfix.org
- MFIX and the MFIX translator can be downloaded from here.
- www.paraview.org
- This is the main ParaView site. Among its many useful
features are:
- The downloadable ParaView application, in both binary and source form. For most users, the binary form is best.
- Instructions for installing both the binary and source code versions on Windows, UNIX and Linux.
- A mailing list for developers and users. This list contains extremely helpful information, although novice users of ParaView may not need to belong.
- The Kitware site where you can order "The ParaView Guide".
- Screenshots. These images provide a quick review of what ParaView can do and can be used to check your installation of ParaView. However, because ParaView is still changing, your version may differ in small ways from the screenshots.
- www.kitware.com
- The Search button can be used to search the messages posted on the ParaView mailing list.
- www.vtk.org
- This site provides the latest official release of the VTK software.
- www.psc.edu/general/software/packages/paraview
- This document is no longer online. A copy can be provided if you
contact PSC User Services.
PSC's ParaView Support Page includes all of the PSC's information on ParaView including this guide and Using the ParaView Animator. Additional links to other sources of information on ParaView are provided. - www.psc.edu/general/software/packages/mfix/tools/
- PSC's MFIX Support Page contains the Center's documentation on MFIX.
1.2 Further Reading
After working with this guide and getting comfortable with ParaView the reader may wish to delve deeper into this flexible application.
The PVG's Part I, "User Guide", is a good next step, particularly Chapters 1 through 9 and the tutorial "A Simple Example".
The term "animation", as used with ParaView, refers to any series of changes that can be played automatically. Unfortunately, the first edition of the PVG, released in 2004, does not describe ParaView's current animator. The PVG's Chapter 8, "Animation", and tutorial 13.3, "Isosurface Animation", should be avoided. The reader is advised to instead refer to the PSC document Using the ParaView Animator.
Finally, the ambitious user will want to join the mailing list.
2. Installation
ParaView 2.0.1 cannot read MFIX data. A translator from MFIX to VTK (Visualization ToolKit), which ParaView uses, must be installed.
ParaView includes the Visualization Toolkit (VTK); unfortunately, the copy of VTK included with ParaView has been modified and cannot be used by the translator. Therefore, VTK must also be installed separately.
2.1 Installing the Translator
The MFIX translator is available at www.mfix.org. It reads MFIX output files and writes VTK files. The latter can then be read by ParaView. Once downloaded, the translator package can be unpacked with the command
tar xzf mfix_to_vtk.tar.gz
This will create the directory mfix_to_vtk. This directory includes the file README.html containing instructions for preparing and using the translator. The packages VTK, CMake and TCL must be installed to use the translator.
2.2 Installing VTK
VTK is a very large library and its installation can be frustrating. This section describes the installation and some pitfalls, and should be read if you have never before installed VTK.
VTK is available at www.vtk.org. Download the latest, stable VTK source.
It is strongly recommended that VTK be compiled from source on your system. Precompiled binaries are less likely to work and usually do not include the TCL support.
2.2.1 Preparing the VTK Directories
VTK is built using the CMake application, available from www.cmake.org. Explicit instructions for CMake are included in the VTK installation instructions.
Unpack the downloaded VTK file. This will create directory VTK.
CMake supports a feature called an "out of tree build". This means that all source code is in one directory and all generated code is in another directory. It is strongly recommended that this feature be used.
To create an out of tree build, user "me" might have, in his home directory, directories named /home/me/VTK (for the binaries) and /home/me/VTKsrc (for the source). The rest of these hints will assume this arrangement; please adapt these hints to your situation.
The source code was unpacked into directory VTK; rename it /home/me/VTKsrc then create the empty directory /home/me/VTK.
2.2.2 Compiling VTK
Go to directory VTK and enter cmake -i ../VTKsrc. You will be asked to set several parameters. For most, the answer is obvious. You can accept the current value of a parameter by just pressing enter. The following hints may help with the less obvious questions:
- "Would you like to see advanced options?"
- No
- "Install path prefix ..."
- If you have put the VTK source and binary directories under your home directory, this parameter should look something like /home/me.
- "Wrap VTK classes into the TCL language?"
- On
When CMake is done, enter make while in the VTK directory. The full compile may take a few hours.
2.2.3 Avoiding the "Ambiguous" Bug
Some versions of g++ (3.4.3 with kernel 2.6.11, for example) may fail to compile VTK 4.2 and stop with a message that includes the phrase
ISO C++ says that these are ambiguous
If you encounter this problem, you need to edit places where "seekg" is called with its first argument equal to the sum of two or more terms (e.g., a+b or a+b+c). The fix is to just reverse the order of the terms (e.g., b+a or b+c+a). Changes will be needed in two places in each of two files, vtkBMPReader.cxx and vtkImageReader.cxx, found in VTK directory IO.
Modified versions of these two files are included with the translator. However, they should be used only with VTK 4.2. To use these files, copy them to the VTK directory IO. If you have a later version of VTK, edit the files by hand.
After making changes, enter make in the top VTK directory. There is no need to re-run CMake.
2.2.4 Running the Translator
If you see the message
mfix_translator.tk: Command not found.
the problem is actually that the TCL interpreter cannot find the TCL version of VTK. This is probably because you forget to change the first line of the file mfix_translator.tk as described in the file README.html.
2.3 Installing ParaView
The Download area at the ParaView site (www.paraview.org) provides the latest stable release of the application as both precompiled binaries and as source code. Using the binaries is recommended - the source is useful only if you plan to change ParaView or if you have a problem with the binaries.
You can also download the current development version via CVS. This is not a good way to start, and is only useful if you have a critical need for a feature or fix that has not yet made it to the latest stable release.
Installation instructions are also provided at the ParaView site.
Those instructions suggest that ParaView be installed in /usr/local. If you do this, the various parts of ParaView will be placed in /usr/local/bin, /usr/local/lib, /usr/local/share and /usr/local/doc.
This guide assumes that you have installed ParaView in /usr/local; please adapt accordingly if you have installed ParaView in another location.
3. A Quick Tour
This section will familiarize the reader with ParaView and the basic steps for creating graphics. In the following section, "Tour Redux", these steps will be repeated but with a more thorough discussion of the options.
Before beginning, make sure you have translated at least one MFIX file set to VTK.
3.1 Starting ParaView
Execute /usr/local/bin/paraview.
There are many command-line options, described in Appendix C of the PVG.
3.2 Screen Layout
Chapter 2 of the PVG, "User Interface", includes an excellent description of the layout of the ParaView screen, and should be read someday. However, it is more than is needed to get started and it is slightly out of date. Figure 1 is a simplified and updated description of the screen.
3.3 Reading Data
Select File->Open Data. In the new window, "Open ParaView File", select any one of the VTK files containing a time step. The selected time step will be read into memory and ParaView will know about all of the others when, later, you loop through time.
Once a file is selected, the property sheet area will change to show the sheet for the VTK file reader. Note that the variables found in the data set are listed here and are all on by default. On this sheet, click the green "Accept" button to actually read the data.
The reader will automatically create a simple drawing showing the outer boundary of the data, colored by the first variable.
Moving the mouse around the display area with a button pressed will move the graphic:
- button 1 (typically the left button) rotates
- button 1 plus shift rotates in 2D around the current view direction
- button 2 pans
- button 3 scales
If you get lost, the leftmost button in the Tool Bar, with popup help saying "Reset the view", will move the camera so that the drawing is visible.
Warning: the Tool Bar can be reconfigured and so this button could be absent or in another location.
3.4 Adding A Cut Plane
On the Tool Bar, click on the 6th button from the left, with popup help reading "Cut with an implicit plane".
The property sheet area will change to that for the cut filter. The defaults are reasonable and so click on the green "Accept" button.
Two additional graphics will be added to the display area. One is the 3D plane widget that can be used to move the cut plane. The other is the cut plane itself, colored by the first variable.
Warning: the plane widget can be moved with the mouse. Be careful to click outside this widget to instead move the graphics.
You may notice that the VTK file reader's graphic obscures the cut plane. At the top of most property sheets, there is a list labeled "Selection Window" with an entry for each active module. At this time, there should be two: the reader, with a name taken from the file you selected, and the cut plane, with a name like "Cut1".
The icon to the left of each module name looks like an eye and can be clicked to turn the graphic for that module on and off. Turn off the reader's graphic to see the cut plane.
3.5 Adding An Isosurface
Click the 9th button from the left in the toolbar. Its popup help will read "Generate isolines or isosurfaces". The observant reader will note that nothing happens. Two issues must be addressed to correct this.
The first problem is that each new module takes, as its input, the output of another module. The only exceptions are "sources" such as the VTK reader.
The current module will be the one just added - the cut plane, if you have been following these notes. Using this as input to the contour module will produce 2D contour lines on the cut plane instead of 3D isosurfaces on the data representation. In the "Section Window", click on the VTK reader to make it the current module (the property sheet will change to that for the reader).
The second problem is that MFIX data is attached to the cells while the isosurface module only works with data attached to the vertices. A conversion is required.
Unlike the cut and isosurface modules, the module needed is not on the Tool Bar. The Filter menu on the menu bar displays a comprehensive list of the available filters. Select the filter named "Cell Data to Point Data". Its property sheet will be displayed. Click the green "Accept" button and its drawing will be added in the display area. Since the CellToPoint module is now current, its output will be used for the isosurface.
Try the isosurface button again and click on its green "Accept" button. Turn off the CellToPoint module's graphics to see the new isosurface.
Actually, you still may not see an isosurface because there may be nothing to draw at the current time step, or ParaView's guess at the value may be poor. Changes to time will be discussed next, and the section Adding an Isosurface Redux will discuss changes to the isosurface value.
3.6 Looping Over Time
All looping in ParaView is managed by its animator component. Please read PSC's Using the ParaView Animator for a description of the animator. A few additional details on looping over time are given here.
After creating the desired visualization, expand the animation track for the VTK reader to see the track labeled "FileName". Click twice in this track, once close to the left end and once close to the right end. You have just added two keyframes. Don't worry for now if these are precisely at the start and end of the track; you can edit them later if need be.
Click the animation control button "Play" to step through time.
The default duration for the animation is 10 seconds with 15 frames per second (fps). This works out to 150 frames. If you have more than 150 data time steps, ParaView will randomly skip some.
Alternatively, you can choose a subset of the data time steps to be displayed, or you can change the duration or frame rate to change the number of animation time steps.
ParaView may not be able to update the screen at the requested rate. This can result in not all animation time steps being displayed. The "Play Mode" button in the animation menu offers options in this situation.
The default "Play Mode" is "Sequence", which means that no animation time step will be skipped. In this mode, the animation can take longer than the requested duration to display all the animation time steps. In "Real Time" play mode, the requested frame rate is maintained, but some animation time steps may be skipped.
4. Tour Redux
This section repeats the steps from the previous section but with additional notes and references to the PVG.
Please use Edit->Delete All Modules to begin with a clean environment.
4.1 Screen Layout Redux
What is shown in the main window is controlled from many places.
The menu bar View menu can select between "Source" (usually the current module), the animator, 3D view options (including lookmarks) and general application settings. Turning on the animator display shows both its property sheet, its tracks, and the controls below the tracks.
The menu bar Source menu selects from the modules currently in use.
The menu bar Windows menu controls the display of the property sheet, animation tracks, and parts of the tool bars. Note that the first three tool bar check options control groups of buttons in the main tool bar, while the last controls the set of animation controls shown below the animation tracks.
When viewing a property sheet that shows the "Selection Window", clicking on any module in that list will display that module's property sheet.
For example, screen layout can be configured for a live presentation so that only the display area, Menu Bar and animation controls are shown.
4.2 Reading Data Redux
Select File->Open Data to display the "Open ParaView File" window.
4.2.1 File Formats
Your data can be in any of the file formats supported by your version of ParaView:
- ones described in the PVG's Chapter 3, "Loading Data"
- new formats added after the PVG was written
- formats added by you
ParaView will select the reader using the file extension. Select a file and then click "Open".
4.2.2 Selecting Times
If you wish to select only certain times, or just wish to see what is going on, click the "Timesteps" button on the VTK reader's property sheet. It is at the right end of a group of widgets labeled "Filename", "Browse" and "Timesteps". A popup menu will be shown where the files in the list on the right are the ones that will be read. Edit this list as you wish.
Later, you can return to this option to change the times that are in use. Be sure to click "Accept" for your changes to take effect.
4.2.3 Selecting Variables
Variables will be listed in two groups, though MFIX users only have variables in the Cell Array group. Later, you can return to this option to change the variables that are in use.
4.2.4 Modifying the Reader's Graphic
Select the "Display" tab on the property sheet to change the reader's drawing. As you probably already suspect, all ParaView modules will have a Display tab with the same features.
The "View" group's "Data" button has the same function as the eye button, i.e., it turns the drawing from this module on and off. The "Scalar Bar" and "Cube Axes" enable auxillary display features (try them). The "Label Point Ids" can be useful, or, it can be a big mistake (for large grids). Finally, the "Set View to Data" button can return you to known space if you have become lost.
The "Color" group is useful only if the display style is "Surface" (next group). The "Color by" pulldown menu selects the MFIX variable used to color the surface. The pseudo variable "Property" means you can select a solid color using the "Actor Color" button.
The "Display Style" group lets you select from several "Representations" where most are affected by the other options in this group:
- outline (affected by line width)
- surface (affected by interpolation and opacity)
- wireframe (affected by line width)
- points (affected by point size)
- volume rendering (doesn't work well)
The final group, "Actor Control", only includes one feature that is particularly useful for simple situations: opacity. It only affects the graphic when the representation uses a surface.
4.2.5 Moving the Objects
Moving objects with the mouse is just the start of the many options that control the virtual camera. The PVG's Chapter 6, "Interaction", describes all the options. You may find the section titled "Saving Camera Positions" particularly useful.
The four buttons at the right end of the tool bar affect the center of rotation. These buttons are fairly intuitive. You may have noticed a set of 3D crosshairs in the center of the drawing (change the drawing to Outline or Wireframe to see them). These crosshairs show the center of rotation, and can be turned off.
4.3 Clipping
During the quick tour, all of the data provided by the reader was used. Let's add one additional filter this time to select only a subset of the data (see Figure 2).
Figure 2. The original data (purple) has been
clipped using a box (white) and then cut using a plane (green
and red).
Click on the image for a larger version.
Click on the Tool Bar button with the popup help saying "Clip with an implicit plane ..." (the 7th from the left). Change the "Clip Function" to "Box", select the "Inside Out" option and then click "Accept".
This has selected the data inside the box, i.e., all of it. Drag the spheres (part of the 3D box widget) to change the size of the box (remember to click "Accept" to see the change). You may need to rotate the drawing to get at some of the spheres.
Once additional drawings have been added (e.g., a cut plane and an isosurface) you may wish to come back to this module to fine-tune the size of the clip box. Any changes to the clipping will cause an update to other modules that use the clip module's output.
4.4 Adding A Cut Plane Redux
First, make sure that the clip module is active so that only the clipped part of the data is used for this cut.
Then, click the 6th button from the left on the Tool Bar, "Cut with an implicit plane", to add the cut module. Click "Accept" to make the cut.
The options on the cut plane's property sheet, under the "Parameters" tab, select the shape, orientation and number of cut planes. The "Display" tab selects the variable used to color the cut. See the section "Modifying the Reader's Graphic", for a discussion of the Display tab.
The PVG's Appendix B, "Filters", includes a discussion of the cut filter along with all other filters.
4.4.1 Multiple Cuts
Multiple cut planes that are parallel to each other and which show the same variable can be created with one instance of the cut module.
However, multiple cut planes using different orientations or showing different MFIX variables will require multiple copies of the cut module. Be sure, when adding additional cut modules, that the clip module is the current module. Otherwise, you will be generating the new cut using only the data selected by a previous cut.
4.4.2 The Cut Function Group
This group of options, on the "Parameters" tab, selects the basic geometry of the cut. A pulldown menu selects between a plane or a sphere. Various other options, concerning location, size and orientation, will be displayed or hidden according to which are appropriate for the selected shape.
When using a plane to make the cut, the mouse (left button down) can be used to move the 3D widget and the cut plane. Drag the widget's arrow to change the plane's normal; drag its rectangular frame to move the cut along its normal. As always, click the green button "Accept" for your changes to take effect.
The plane and sphere widgets, used to move the cut, will be shown only when this module is the current module. In addition, you can use the button at the bottom of this group, labeled "Visibility", to turn the widget on or off. You may wish to turn off the widget to avoid selecting it when you actually want to move the entire graphic display.
4.4.3 The Cut Offset Group
These options, on the "Parameters" tab, set the "offset". For a plane, this is the distance of the cut, along the plane's normal, from the basic cut plane. The default offset is 0, and changing it is no different than moving the basic cut plane.
Use these options if you wish to create a series of cuts by selecting several offsets.
4.5 Adding An Isosurface Redux
First, make sure that the clip module is active so that only the clipped part of the data is used for the isosurface. Then, add the CellToPoint and Contour modules as described in the section "Adding an Isosurface".
Isosurfaces or contour lines are created when the input is 3D or 2D, respectively.
Two variables can be used with an isosurface: the "Scalars" pulldown menu, on the "Parameters" tab, selects the variable used to create the shape of the isosurface, while the "Color by" pulldown menu, on the "Display" tab, selects the variable used to color the isosurface.
Back on the "Parameters" tab, the option groups labeled "Contour Values", "Add value" and "Generate range of Values" are used to set the value(s) used to generate the isosurface. Changing the value, even if you are using only one, is awkward: you must set the new value, add it, delete the old, and then click "Accept".
4.6 Looping Over Time Redux
The PSC guide "Using the ParaView Animator" is a good source of information on animation and looping. The animator is relatively new and subject to change. Currently, the camera location cannot be animated.
The button saying "Save animation as a movie or images" provides a popup menu labeled "Save Animation Images". Use its browser to select the directory and file name for the output. Use the pulldown list for selecting the output format. The MPEG2 format creates a single movie file.
When "Save" is clicked, ParaView will play and record the animation. Warning: anything shown on top of the ParaView display area will be captured as part of the recording.
