Sunday, 28 September 2014

Scientific Visualisation - from 1's and 0's to pretty pictures

What is Scientific Visualisation? It is actually far more than just pretty pictures. It's a means of representing vast amounts of data in a manner that we can better appreciate and understand. I'm going to run through an example of scientific visualisation by generating an image of a three-dimensional turbulent flow over an aerofoil surface (eg: aircraft wing, wind turbine blade) at one instance in time. By then repeating the process at multiple instances we can generate a movie illustrating how the turbulence evolves in time. I produced the data used in this blog post during my PhD, using the Stanford University Center for Turbulence Research code, CDP [1]. You can find further detail on the data in [2,3].

The software tool I will be using to visualise this data is the open source code, Paraview. It is a graphical user interface to VTK++ (www.vtk.org), which is a C++ library (including Python and Tcl wrappers) defining how to read and write the VTK file format and perform the visualisations described below (and much more). Paraview has also been written to use multiple computer processing units (CPUs) at once to visual massive data sets, that could not ordinarily be visualised using only one CPU. If you like you can download the necessary software / data and follow the steps outlined below.

Step 1) If you do not already have it installed, download and install the freely available open source software Paraview from www.paraview.org.

Step 2) Download the required VTK files. You will need two files:
aerofoil_surface.vtk - this VTK file defines the aerofoil surface geometry.
aerofoil_data.vtk - this VTK file contains the flow field data around the aerofoil surce. It is not the complete flow field, but a small subset of the flow over just the front portion of the aerofoil. In this file you will find the velocity components (vector u) in all three dimensions, and the pressure field (scalar p). In addition, you will also find the invariants of the velocity gradient tensor P,Q,R and the discriminant D, which can be used to define the boundary of a vortex [4].

Step 3) Open Paraview, go to File->Load and select the aerofoil_surface.vtk file. You will need to click the green "Apply" button in the "Properties" tab. You now should be able to rotate and zoom into the aerofoil surface.

Step 4) Again go to File->Load and this time load the aerofoil_data.vtk file, remembering to click the "Apply" button. You should now see the subset of the flow field placed with respect to the aerofoil surface. This is a three-dimensional volume of discrete points. You can change the "Surface" drop down menu to "Wireframe" or "Surface With Edges" to see the individual discrete points.

Step 5) Now go to Filters->Alphabetical->Contour. Just make sure that you still have the aerofoil_data.vtk file selected in the pipeline browser. In the "Properties" tab change the pressure variable "p" to the variable "Q". Also change the isosurface value below the subsection "Value Range" to 250, and click "Apply". This should generate a series of surfaces all of which have a value of Q=250. This makes it easier to visualise what is going on inside the three-dimensional volume.

Step 6) At the top of the program interface, change the colour-by drop down menu from "Solid Color" to "vorticity". You can also play around with the colour mapping properites on the right hand side and rotate the object to get it to look just the way you want.

Paraview also has the functionality to load multiple files from consecutive instances in time all at once. It will repeat the visualisation process outlined above for each individual file (representative of each instant in time), and then generate a movie autmatically. The movie generated for the associated aerofoil flow can be seen below. In this movie, however, I used the entire flow field instead of the small subset provided for you to play around with.


I also generated an annimation for turbulent flow inside a channel, between a top and bottom wall. Here the iso-surfaces of are D, and are coloured by the velocity in the  direction of the flow. I generated the data used for this visualisation using the code developed in [5,6]. You can find many other annimations generated using this process on my youTube channel.


Once you're familiar with the steps, you in fact do not need to use Paraview at all. You can write either a C++, Python of Tcl code to do all of the operations outlined above automatically.

The data used in this blog post is in fact by today's standards quite small. Each file is approximately 117Mb in size for the small domain size provided, and we used 512 to generate the movie, for a total size of the database of 59Gb. In my current work one instant in time contains 100 billion degrees of freedom, with each data file 400Gb in size. To make a movie of the same number of fields as outlined above the total size of the database would be 204,800Gb = 200Tb = 0.2Pb.

Finally the scientific visualisation methods described above are not only applicable to turbulence, but many fields of including medical imaging, socio-economic geo-spatial data, genetics, and in fact any data set that varying in time and space. So if you have time varying spatial data (like the data presented here), you can generate movies automatically without having to do any frame by frame animation like you would have to do in traditional animation.

There is another field of visualisation that aims to present data that depends on more than 3 dimensions, as is the case in design applications. This, however, will be the subject of a future post.

References:
[1] Mahesh, K., Constantinescu, G. & Moin, P., 2004, A numerical method for large eddy simulations in complex geometries, J. Comput. Phys. 197, 215–240.
[2] Kitsios, V., Cordier, L., Bonnet, J.-P., Ooi, A. & Soria, J., 2011, On the coherent structures and stability properties of a leading-edge separated aerofoil with turbulent recirculation, J. Fluid Mech., 683, 395–416.
[3] Kitsios, V., 2010, Recovery of fluid mechanical modes in unsteady separated flows, PhD thesis, The University of Melbourne & Universite de Poitiers.
[3] Perry, A. E. & Chong, M. S., 1987, A description of eddying motions and flow patterns using critical-point concepts, Ann. Rev. Fluid Mech. 19, 125–155.
[5] Kim J., Moin P. and Moser R., 1987, Turbulence statistics in fully developed channel flow at low Reynolds number, J. Fluid Mech. 177 133–166.
[6] Del Alamo, J. C.  & Jimenez, J., 2003, Spectra of the very large anisotropic scales in turbulent channels, Phys. Fluids, 15 L41–L44.