VisuSimple: An interactive visualization utility for scientific computing T. Dunne1 , R. Becker2 Institut f¨ ur Angewandte Mathematik
[email protected],
[email protected]
Summary. In this work we describe an easy to use and easy to modify open-source program that was developed for the needs of several projects in the SFB 359. The utility is based on the powerful open-source visualization toolkit VTK, the de facto industry standard for visualization. It is an interactive visualization and graphics/movie-generation utility for multicomponent 2D- and 3D-data in the VTK-format. The data is the result of numerical computations such as e.g. computational fluid dynamics or computational structure mechanics. The main features of VisuSimple are shown based on examples.
1 Introduction Motivation. Most software used in research is written for two simple reasons: to enable and facilitate research. Applications range from small systems of simulating and modeling fluids, structures, fluid-structure interaction, chemistry, reactive flows to large systems encountered in astrophysics, [1, 2, 3, 4]. All calculations create large amounts of visual data that needs to be visualized. Due to the wide range of topics in our group there is a long list of demands that the software has to satisfy. It should be capable or processing 2D- and 3D-data, generating output in several formats as an image (jpeg, ps, pdf) or a movie (mpeg, avi), capable of processing locally refined meshes with hanging nodes, capable of processing meshes based on different geometric types (triangles, quads, hexaeders, tetraeders), capable of extracting features (isolines, isosurfaces, cutplanes). In the course of time we have come to use multiple other tools for visualization. And we encountered the typical common problems with “outside” software. In some way or the other it does not do what one wants and it is not possible to modify it in the needed way; or it is possible but the needed investment is too large. The costs of either the software licenses or the required modifications were simply too high. Creation. With the introduction of the open-source library VTK ([5, 6])
2
T. Dunne, R. Becker
for processing visual data the possibility of developing our own visualization software became feasible. VisuSimple was initially written 1999 by Roland Becker1 . It is presently being maintained and further developed by Thomas Dunne2 and Dominik Meidner3 . It is written in the scripting language Tcl ([7, 8]) , a programming language that can be learned quite quickly. Like VTK the authors chose to distribute the source code based on an open-source model. Based on this source code and knowledge of the VTK library it has become almost trivial to add new visualization methods or fix and extend present features. Capabilities. VisuSimple is being used to visualize multicomponent 2D- or 3D- data by multiple projects in the SFB 359 [1, 2, 3, 4]. It aims to have a wide range of use and to be independent of discipline. It offers functions that are based on the standard methods of visualizing scalar and vector fields and subsets thereof such as cutplanes and isolines. Additionally it is capable of visualizing suites of data based on a series of results from stationary or instationary numerical computations. Presently one can (among other things) use VisuSimple to: · read structured or unstructured, optionally compressed data files in VTK-format and the lesser known INP-format; · visualize a 2D- or 3D- grid with optional local refinement based on hanging nodes; the grid may contain any mix of basic graphics elements (triangles, quads, hexaeders, tetraeders); · process data files that contain an arbitrary amount of component data in scalar or vector form based on the nodes or cells of the mesh; · visualize carpets of 2D scalar data, shading; · visualize vector fields (as glyphs - multiple types pickable e.g. arrows, pins, lines... - normable, scalable, selectable visualization ranges); · with all visualizations provide a selectable colormap; · multiple camera positions can be changed, saved and loaded; · interactively move and zoom around the visualization; · extract values and grid-data off of the grid or mesh with the mouse; · save the visualizations to common graphics formats: jpg, ps, pdf and tiff; · make movie animations. Code. Since visual data processing is not trivial, learning to use the VTK library (in Tcl or any other language) is not as easy as initially learning to use Tcl. Still, the VTK library facilitates this task considerably. The VTK library has practically become an industry standard as a visual data processing toolkit, so VisuSimple can also be seen as an excellent learning opportunity to using the VTK library. 1
[email protected] [email protected] 3
[email protected] 2
VisuSimple
3
We provide the code of VisuSimple free to the public under an MIT-likelicense - anyone is free to download it and apply their own modifications and even redistribute these under basic restrictions. Since VisuSimple is programmed using the scripting language Tcl and the excellent visual data processing toolkit VTK, modifications can be literally tested and integrated interactively into the source4 . The language Tcl is easily learned and so modifications can even be made by Tcl-quickstarters. VisuSimple is written in Tcl/Tk, using VTK’s Tcl/Tk interface. Its version is at the moment 3.44 (as of 10.10.2005). In the following sections we will briefly show the core functions of VisuSimple based on its individual actors. We refrain from explaining the basic inner workings of the code since essentially VisuSimple is based on the principles of VTK and VTK’s actor based approach of processing data. Actors are responsible for the different aspects of visualizing data: displaying a mesh, displaying isolines, displaying hedgehogs, etc.. More details of the use of VisuSimple can be found in the user’s guide.
2 The actors After having loaded a file and selected which scalar and/or vector datasets should be processed, one can specify in which ways they are exactly to be processed. All functions of visualization - be it the simple mesh, the carpet on the mesh, isolines, isosurfaces, vector-arrows, etc - are rendered into the view area by actors. Actors can individually be turned on and off in the “Actors” menu.
Fig.1. “Actors” menu opened.
Presently VisuSimple offers the following functions as actors: 4
This is possible using the Interactor dialog box
4
T. Dunne, R. Becker
· Mesh: shows a wireframe of the mesh. · Mesh2: same as Mesh, for mirroring purposes. · Carpet: maps a texture onto the mesh, based on the selected scalar dataset and colormap. · Carpet2: same as the Carpet actor, for mirroring purposes. · Isos: displays isolines of the selected scalar field on the flat mesh or as an adjustable height field. · OtherIsos: displays isolines of an arbitrarily selected scalar field on the flat mesh or as an adjustable height field. · OtherIsos2: same as above for any other scalar field. · Hedgehogs: displays the selected vector field as glpyhs e.g. in the form of arrows, pins or lines. · Scalarbar: shows a legend of the selected dataset based on the colormap. · Pinpointer: with this one can continuously pick and display datavalues out of the visualized grid with the mouse. · DrawBoundary: puts a black line on the boundary of the mesh. · Outline: draws a bounding box around the whole geometry. · NodeIds: displays the indices of all nodes in the mesh. · CutPlane: shows the intersection of a plane with the mesh. All actors can be configured in two manners: · The “Parameter” menu: in this menu many common and usually quick-to-do options are provided, such as changing the color or scaling of an actor. Each actor has its own submenu in the “Parameter” menu and in this menu each actor option itself has a submenu.
Fig.2. “Parameter” menu.
· The “DetailedParameter” menu: Each actor has its own item in the “DetailedParameter” menu which when selected will open a actor-specific dialog box. Each actor’s dialog box will provide a means of changing all of the important configuration options. Some of the options in the “Parameter” menu will not be provided, such as mirroring or changing the actor’s color. In the following sections we will occasionally describe an actor’s configuration possiblities, either just to give an initial description or due to the sheer volume of configuration options, but otherwise in general will we refrain from going into too great detail.
VisuSimple
5
3 The Mesh actor The Mesh actor is responsible for displaying the wireframe grid that all datasets are based on. If the dataset contains a volume then only the bounding wireframe of the dataset will be shown. The Mesh actor has options available in both the “Parameter” menu and the “DetailedParameter” menu. The options provided in the “Parameter” menu are setting the color, mirroring the actor and scaling a certain value associated with the actor. Fig.3. “Parameter” menu. For this actor the scale option specifically changes the opacity of the mesh. The dialog box that can be opened by selecting the “Mesh” item in the “DetailedParameter” menu. It offers many frequently occurring options: turning an actor on/off, setting the opacity, shifting the actor around in the viewing area and specifying that all changes are to be applied immediately. If no other actors are present these two options will not be very useful. The opacity option is good if multiple actors are active e.g. the Mesh and the Carpet. With the help of this option one can dim down the intensity of the Mesh so that it will not distract too Fig.4. Mesh dialog box. much while viewing the Carpet actor. Below we show an example of a data file where the opacity of the Mesh actor has been reduced to 20%. (The border of the mesh is visible due to an additional actor: the DrawBoundary actor.)
6
T. Dunne, R. Becker
Fig.5. Mesh with reduced opacity.
With the shift-options one can move the Mesh actor up or down (e.g. by changing the z-value) and so away from the Carpet actor. This way the mesh can still be provided in the viewing Fig.6. Control for changing position. area but it will be less distracting. Almost all dialog boxes will have a grouping of graphical elements similar to the grouping of elements associated here with the “shift x” value. The setup of the elements is the following: the left element contains the value that is being setup. This element can be edited directly. The scale to the right of the element enables you to more easily change the value by sliding the scale button. More often then not though you will want to adjust the bounds or the step size of the scale. For this reason the editable elements above the scale are provided. They represent respectively the left bound, the resolution and the right bound of the scale. These values upon changing are applied immediately. You do not need to press enter oder wave the mouse around.
The Mesh2 actor The Mesh2 actor is in its function identical to the Mesh actor. It serves the purpose of acting as the second halve of an incomplete axially symmetric geometry that can be flipped or mirrored with the help of the mirroring options in its “Parameter” menu.
VisuSimple
7
4 The Carpet actor The Carpet actor is responsible for “putting a carpet” onto the wireframe grid that all datasets are based on. This is also known as texture mapping. An example of the Carpet actor was shown in the previous section. Initially the carpet will be placed on top of the mesh. Alternatively one can scale the carpet to a certain height based on the selected scalar field. The Carpet actor has options availible in both the “Parameter” menu and the “DetailedParameter” menu. The options provided in the “Parameter” menu are setting the color, mirroring the actor and scaling a certain value associated with the actor. The only difference for this actor is the scale option, here it specifically changes the height of the carpet. Fig.7. “Parameter” menu. The dialog box can be opened by selecting the “Mesh” item in the “DetailedParameter” menu. It offers options similar to those of the Mesh actor dialog box: turning an actor on/off, setting the opacity and shifting the actor around in the viewing area. Additionally these functions are provided. · The texture on the Carpet actor can be turned off with the show surface option. · The height of the Carpet actor can be normalized based on the minimum and maximum values of the selected scalar dataset. · The scaling of the Carpet actor can be adjusted. · The scaling of the Carpet actor can be quickly modified with factors -1,0 or 1. This way the Carpet actor can easily Fig.8. Carpet actor dialog box. either be flipped around or made flat. Normalizing the height of the carpet has the effect that VisuSimple will try to fit the height of the Carpet actor to the viewing area. It is still possible to scale the carpet though. Usually normalization will be turned on, but there are situations where one will want to see how the absolute values of the carpet diminish. In these cases simply turn normalization off.
8
T. Dunne, R. Becker
The Carpet2 Actor The Carpet2 actor is in its function identical to the Carpet actor. It serves the purpose of acting as the second halve of an incomplete axially symmetric geometry that can be flipped or mirrored with the help of the mirroring options in its “Parameter” menu.
5 The Isos actor The Isos actor will show the isolines of the selected scalar dataset. A wide range of options and values can be configured with this actor. Here are the options and the values they will initially be set to: · Position: it will not be shifted in position. · Scaled height: the height will not be scaled or normalized to any value (similar to a carpet). That means: it will be placed on top of the mesh and flat. · Number of lines: it will consist of 10 lines. · Spread of lines: the lines will be between the maximum and minimum values of the selected scalar dataset. · Opacity: its opacity value will be set to 1.0. · Color: it will be colored black. As an example we show isolines with modified options. Most notably the height of the isolines have been set to indicate the scalar value.
Fig.9. Example of Isos actor with height and reduced opacity.
VisuSimple
9
Similar to other actors the Isos actor has options available in both the “Parameter” menu and the “DetailedParameter” menu. The actors dialog box offers many frequently occurring options: turning an actor on/off, setting the opacity and shifting the actor around in the viewing area. Additionally following functions are provided. · The manner in which the isolines are to be shown. · The number of isolines to be shown. · The range of where isolines are to be shown. · The Isos actor can be assigned a height to indicate the value of the selected scalar field. The height can be scaled and normalized based on the minimum and maximum values of the selected scalar dataset. The values for the range are relatively based values between 0 and 1. The relative numbers are internally scaled to the minimum and maximum values of the selected scalar dataset. This way one can for example specify that the isolines are to be shown between the 40% and 60% marks of the datasets extreme values. Fig.10. Isos actor dialog box.
The OtherIsos and OtherIsos2 actors These actors are in their function identical to the Isos actor. Additionally they let the user select different scalar fields to which the isolines are to be applied. This is useful when the isolines are to be shown for a fixed scalar component of the data and allows the user to change the selected component.
6 The Hedgehogs actor The Hedgehogs actor will show the vector field of the selected vector dataset. This is achieved by positioning glyphs - small arrows, pins or lines - at points on the mesh. Initially the glyphs are spread on all points, but it is also possible to only show a reduced number of glyphs spread out evenly on the mesh. The size of the glyphs will also initially be set to indicate the length of the
10
T. Dunne, R. Becker
respective vector, but one can also set the actor to show all glyphs at a normalized length5 . This is good when one for example only wants to see the general behavior of the vector field. Additionally one can specify that only vectors whose length is in a certain range are to be shown. This is very handy when for example visualizing an almost dormant flow in a crevice surrounded by otherwise quick flow. As an example we show the actor with normalized glyphs and a lower density value.
Fig.11. Example of Hedgehos actor with normalized glyphs at a lower density.
Similar to other actors the Hedgehogs actor has options available in both the “Parameter” menu and the “DetailedParameter” menu. A wide range of options and values can be configured with this actor. Here are some of the actor specific options and what they will initially be set to:
5
The glyphs will still be scalable, albeit they will all have the same length.
VisuSimple
· Normalized size: the vectors will not be normalized to the length 1. · Density: Set at 1-to-1. Alternatively one could for example only show one glyph for every 10 vectors. · Placement: the arrows will be placed on all mesh points within the dataset. Alternatively they could be placed on a reduced number of points or spread out evenly independent of the mesh points. · Scaled size: the size of vectors will be scaled to 1.0. · Cutoff: all vectors between the minimum length and the maximum length will be shown. · Arrow type: VisuSimple’s own arrow type nr. 1 will be used.
11
Fig.12. Hedgehogs actor dialog box.
7 The ScalarBar actor The ScalarBar actor will show a colorbar based on the value range of the selected scalar dataset. The actor can be set to change the title and show the scalar value range alongside the colorbar. As a graphic example we show the ScalarBar actor where some of the options have been changed.
12
T. Dunne, R. Becker
Fig.13. Example of Scalabar actor.
Similar to other actors the ScalarBar actor has options available in both the “Parameter” menu and the “DetailedParameter” menu. The actor’s dialog box offers many frequently occurring options: turning an actor on/off, setting the opacity and shifting the actor around in the viewing area. A wide range of options and values can be configured with this actor. Here are the options and what they will initially be set to: · Position: it will be positioned on the right side of the viewing area. Its bottom left corner will be positioned at (82%,10%) of the width and height. · Scaled size: the size of ScalarBar will be (20%,80%) of the width and height of the viewing area. · Shadowed: the displayed text will have a shadow. · Number of ticks: how many values should be shown for aligning colors to values. · Orientation: the ScalarBar will be vertical. · Title: the title will be that of the Fig.14. Scalarbar actor dialog box. selected dataset.
VisuSimple
13
8 The Pinpointer actor The Pinpointer actor is a tool for obtaining mesh information and scalar and vector data from the viewing area. The actor is represented by a small sphere that can either be moved around on the mesh or the carpet. Placement and movement of the actor is achieved by simply moving the mouse to the respective position on the mesh or carpet. The data and information to be shown can be specified and viewed in the data window dialog box. This dialog box can be opened from the Pinpointer dialog box. Here are the actor’s options and the values they will initially be set to: · Position: it will be positioned in the middle of the mesh. · Size: its size will be adjusted to the size of the mesh. · Size adjustment: its size will be adjusted to the size of the cells. · Attachement : by default it is attached to the Mesh actor (and not the Carpet actor). · Data window: the data window will not be shown and no information or datasets are selected. As a graphic example we show the Pinpointer actor where some of the options have been changed. The size of the Pinpointer as purposely been enlarged to make it visible.
Fig.15. Pinpointer actor as a large sphere with dialog box and data window.
The Pinpointer actor can only be configured by means of the its dialog box. The dialog box offers the following options: turning the actor on/off, activating the Pinpointer actor to follow the mouse, opening the data window, attaching the actor to the mesh or carpet and manually positioning the actor. Additionally the dialog box offers an option of opening an additional dialog
14
T. Dunne, R. Becker
box: the data window. The data window is used to view requested information and data at the point of the Pinpointer actor. The following information and data can be set to be viewed. · The ids of the selected cell or node. · The celldata of selected cell, i.e. the cell id and the ids of its points. · The pointdata of the selected node, i.e. its id and coordinates. · The scalar or vector values of the selected fields at the present point. Fig.16. Pinpointer actors data window.
9 The NodeIds actor The NodeIds actor will display the id of each node at each node. This actor is only useful for situations where one needs to see the ids of many nodes simultaneously. If it is only necessary to see the ids at certain points, then using the Pinpointer actor would be a better approach. That actor is faster and uses less memory in comparison to this actor. The NodeIds actor has two options available in the “Parameter” menu so that the displayed ids can be mirrored and the size of the ids can be scaled. As an example we show the actor when used with the file example.vtk from VisuSimple’s examples diFig.17. Example of NodeIds actor. rectory.
VisuSimple
15
10 The CutPlane actor The CutPlane actor is meant to be used with 3D data. As the name suggests, it intersects the data with a plane. In this plane the selected scalar field will be shown. Technically it can also be used for 2D data. In this case the cut will result in a line. Some options that can be configured with this actor. · Plane: which plane to be used can be chosen. Initially the xy-plane is set. · Position: where within the bounding box the plane will be position. Initially it will be positioned at the center. · Isos: if isolines are to be shown on the cutplane or not. Initially no. As an example we show the CutPlane actor where some of the options have been changed.
Fig.18. Example of Cutplane actor.
11 The DrawBoundary actor The DrawBoundary actor will draw the exact boundary of the mesh. A similar actor is the Outline actor. The Outline actor though only draws a simple bounding box around the mesh. Only a minimum number options can be configured with this actor. Here are the options and the values they will initially be set to: · Position: the boundary shown will be positioned where the boundary of the mesh is. · Opacity: its opacity will be set to 0.5.
16
T. Dunne, R. Becker
As an example we show the actor in combination with Mesh actor. Take note that the inner boundary has also been recognized and “outlined”.
Fig.19. Example of DrawBoundary actor.
12 The Outline actor The Outline actor will draw a bounding box around the mesh. In most cases its output will be equal to that of the DrawBoundary actor. The DrawBoundary actor differs from this actor by displaying the exact boundary of the mesh. No options can be configured with this actor. As an example we use the mesh from the previous section and show the actor in combination with Mesh actor. Take note that the inner boundary has not been recognized nor “outlined”.
Fig.20. Example of Outline actor.
VisuSimple
17
References 1. R. Becker, M. Braack, R. Rannacher and T. Richter, “Mesh and model adaptivity for flow problems”, in Reactive Flows, Diffusion and Transport (R. Rannacher, ed.), Springer, Berlin, 2005. 2. R. Becker, M. Braack, and T. Richter, “Parallel multigrid on locally refined meshes”, in Reactive Flows, Diffusion and Transport (R. Rannacher, ed.), Springer, Berlin, 2005. 3. M. Braack and T. Richter, “Solving multidimensional reactive flow problems with adaptive finite elements”, in Reactive Flows, Diffusion and Transport (R. Rannacher, ed.), Springer, Berlin, 2005. 4. R. Becker, M. Braack, D. Meidner, R. Rannacher and B. Vexler, “Adaptive finite element methods for PDE-constrained optimal control problems”, in Reactive Flows, Diffusion and Transport (R. Rannacher, ed.), Springer, Berlin, 2005. 5. Will Schroeder, Ken Martin, Bill Lorensen “The Visualization Toolkit, An Object-Oriented Approach To 3D Graphics”, Kitware, Inc. publishers, ISBN 1-930934-12-2 6. Kitware, Inc. , “The Visualization Toolkit User’s Guide”, Kitware, Inc publishers. ISBN 1-930934-13-0 7. Paul Raines, Jeff Tranter, “Tcl/Tk in a Nutshell” O’Reilly, ISBN: 1-56592433-9 8. Paul Raines, “Tcl/Tk Pocket Reference”, O’Reilly, ISBN: 1-56592-498-3