Abstract: In this chapter, we consider a portable open source software package for visualizing scientific datasets: ParaView10. Basic data formats used in the program are described below. We also discuss the preparation of input data on the basis of simple examples. Finally, the feature of parallel visualization is demonstrated.
We can download ParaView installation files from the official website (for Windows, Linux, and Mac). Here the focus is on the Ubuntu version. To install the application, we use the following command:
ParaView allows visualization of scientific datasets, both on local computers and on parallel computing systems. The program has client-server architecture; it was developed on the basis of the visualization ToolKit (VTK) library11. It is possible to work with ParaView via the graphical user interface (GUI) or in batch mode using the Python programming language. The visualizer supports standard features of scientific visualization with the focus on two- and three-dimensional data. Other products, such as Tecplot12, visIt13, and Ensight14 can be considered analogs.
ParaView supports datasets defined on uniform and non-uniform, rectilinear and curvilinear, general non-structured and multiblock grids. The VTK format is the basic data format. ParaView can also import a large number of other data formats, i.e.,STL15, NetCDF16, CAS17 and more.
ParaView provides a large set of useful filters for data analysis. Users can also create their own filters. The program allows visualization of scalar and vector fields. Using filters, we can extract contours and isosurfaces, intersect domains with a plane or a given function, conduct data analysis, display streamlines for vector fields, and plot distribution of data values over given lines. We can also save screenshots and animation for time-dependent fields.
The VTK format has two different styles of data presentation: serial and XML based formats. The serial formats are text files, which can be easily written and read. The XML based formats support random access and parallel input/output. These formats also provide better data compression.
The serial formats consist of the following five basic parts:
This structure of serial files provides freedom to select dataset and geometry and to change data files using filters of VTK or other tools.
VTK supports five different dataset formats: structured points, structured grid, rectilinear grid, unstructured grid, and polygonal representation.
This file format allows storage of a structured point dataset. Grids are defined by the dimensions nx, ny, nz, the coordinates of the origin point x, y, z, and the data spacing sx, sy, sz.
This file format allows storage of a structured grid dataset. Grids are described by the dimensions nx, ny, nz and the number of points, n. The POINT section consists of the coordinates of each point.
This file format is oriented to store a rectilinear grid dataset. Grids are defined by the dimensions nx, ny, nz, and three lists of coordinate values.
This format provides storage of an unstructured grid dataset and consists of arbitrary combinations of primitives (surfaces, lines, points, polygons, triangle strips). Grids are described by POINTS, VERTICES, LINES, POLYGONS, TRIANGLE_STRIPS. Note that here POINTS is the same as the POINTS in structured grid.
This format is designed for storing unstructured grid datasets. An unstructured grid is defined by vertices and cells. The CELLS keyword requires two parameters: the number of cells n, and the size of the cell list size. The cell list size indicates the total number of integer values required to represent cells. The CELL_TYPES keyword requires the only parameter, i.e. the number of cells n that should be equal to the value in CELLS. The cell types data are integer values specifying the type of each cell.
Data formats based on XML syntax provide many more features. The main feature is data streaming and parallel input/output. These data formats also provide data compression, random access, multiple file representation of data, and new file extensions for different VTK dataset types.
There are two different types of XML formats:
In the XML format, datasets are divided into two categories: structured and unstructured categories.
A structured dataset is a regular grid. The structured dataset types are vtkImage Data, vtkRectilinearGrid, and vtkStructuredGrid.
An unstructured dataset defines an irregular grid that is a set of points and cells. The unstructured dataset types are vtkPolyData or vtkUnstructuredGrid.
XML formats are designed similarly to serial formats. A more detailed description can be found in the ParaView documentation.
Let us consider simple examples of how to prepare data using the given data visualization formats. We present the implementation of writing the results of mathematical modeling in a file.
Using the above description of the serial data representation format, we write values of a two-dimensional grid function in a VTK file. We use the following function to generate the grid dataset:
Function values are calculated on the uniform rectangular grid 100 x 100.
Consider the implementation of the program. First, to work with mathematical functions and to write to a file, we include the standard libraries as shown in Listing 5.1.
Further, we set the dimensions of the grid as follows:
Define the function to calculate a 2D structured dataset as shown Listing 5.3.
Next, we set the function which writes the dataset to a file with VTK serial format as follows in Listing 5.4.
In the main function, it is necessary to specify domain parameters, generate the coordinates vectors x, y, calculate values of the function v, and write into a file as shown in Listing 5.5 below.
Finally, we visualize the resulting file vtk2d.vtk using ParaView as shown in Figure 5.1.
Here we present an example of generating a structured 3D grid dataset and writing it to a VTK file.
The dataset corresponds to the following function:
with the regular uniform grid 100 x 100 x 50.
The complete code of the program is shown in Listing 5.6 below; the implementation is the same as in the 2D example.
We visualize the resulting file vtk3d.vtk via ParaView (Figure 5.2).
In the case of unstructured 2D grids, it is reasonable to employ special software. Of course, we can use the VTK library itself, but there are other libraries which are more convenient for writing VTK files.
Let us consider the visIt library18, and in particular the visit_writer module. This module provides a convenient interface for writing VTK files and allows the writing of unstructured grids.
visit_writerincludestwofiles(visit_writer.candvisit_writer.h).The following code (Listing 5.7) writes an unstructured grid dataset to a VTK file using the library.
We visualize the resulting file unsctructured2d. vtk using ParaView as demonstrated in Figures 5.3 and 5.4. It is possible to visualize the data associated with the nodes (Figure 5.5) and cells (Figure 5.6).
The user interface of ParaView consists of the following sections:
The File | open command or the Open button from the toolbar can be used to load data into ParaView. It is necessary to select a file, for example file vtk2d.vtk from the previous section (Figure 5.7). Next, we click the Apply button in Object Inspector (the Properties tab). If a data file contains more than one function for visualization, then the same color will be used over an entire dataset (solid Color).
In this case, we select a function in the Toolbars or the Display tab of object Inspector. Then the dataset will be colored based on the values of the function. The color palette of the function may be edited from the dialog that appears from clicking the Edit Color Map button.
After a file is loaded, we can use the mouse buttons to zoom, pan, rotate or roll an object. For a more detailed study of the object, filters for processing data should be applied. The most common filters are listed in Table 5.1. The results of applied filters are displayed in Pipeline browser.
Filter | Description |
---|---|
calculator | Evaluates a user-defined expression on a per-point or per-cell basis. |
contour | Extracts the points, curves, or surfaces where a scalar field is equal to a user-defined value. |
clip | Intersects an object with a half-space. |
slice | Intersects an object with a plane. |
Threshold | Extracts cells that lie within a user-defined range of a scalar field. |
Extract Subset | Extracts a subset by defining either a volume of interest or a sampling rate. |
Glyph | Places a glyph on each point in a mesh. |
Stream Tracer | Seeds a vector field with points and then traces those points through the (steady state) vector field. |
Warp | Displaces each point in a mesh by a given vector field. |
Group Datasets | Combines the output of several objects into a dataset. |
Extract Level | Extracts one or more items from a dataset. |
These filters are only a small example of the possibilities available. Currently, ParaView offers more than one hundred. For convenience, the Filters menu is divided into submenus (Table 5.2).
The use of filters to process and visualize generated 3D structured dataset is now demonstrated (file vtk3 d. vtk):
Submenu | Description |
---|---|
Search | Searches through lists of filters |
Recent | Recently used filters |
Common | Common filters |
Cosmology | Filters developed at LANL for cosmology research |
Data Analysis | Filters designed to obtain quantitative values |
Statistics | Filters which provide descriptive statistics of data |
Temporal | Filters which analyze or modify data that changes over time |
Alphabetical | Alphabetical list of filters |
In addition, we can display the color legend of an object by clicking the button . Clicking the button , we edit the color map (palette) as well as the number of colors in the color map (Resolution slider). To save screenshots, the File | save Screenshot menu command is available.
In order to work with transient fields, we need to create a pvd file which contains information about the time steps and files with data of this time step:
Each individual file can contain a grid of any type: vtu = unstructured, vtp = polydata, vtr = rectilinear, vti = imagedata. At the same time, the file can be binary, text, compressed or not compressed.
We can play a time-history with the VCR control toolbar. In addition, it is possible to save the current time series as an animation using the File | save Animation menu command.
ParaView provides the possibility of parallel visualization and data processing to work with large datasets. We now briefly describe the architecture of ParaView to help understand this parallelism.
ParaView has a three-level client-server architecture and consists of the following parts:
These parts of the program may be located on different computing systems, but they are often integrated into a single application. There are three modes of starting ParaView:
Modern computers are parallel computing systems and can provide significant performance improvement due to multiprocessor architecture. Here we consider running ParaView in the Client/Server mode. To do this, we run the server using the following command:
This command runs the parallel server in four processes.
Further actions are associated with connecting the client to the parallel server. We invoke ParaView and click on the Connect button. Next, in the opened dialog, we click on the button Add server and set the name or ip address. Finally, we can open files as usual, for instance, the file vtk3 d. vtk as presented in Figure 5.12.
After applying the filter Process Id Scalars, we can choose the array ProcessId to display subdomains belonging to different processes (Figure 5.13).