VisIt Tutorial: Difference between revisions

From Fluids Wiki
Jump to navigation Jump to search
(Created page with "VisIt is an open source data visualization and analyzation tool. This tutorial will focus on how to create visually pleasing 3D images of fluid mechanics flows. == Convertin...")
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
VisIt is an open source data visualization and analyzation tool. This tutorial will focus on how to create visually pleasing 3D images of fluid mechanics flows.  
VisIt is an open source data visualization and analyzation tool. This tutorial will focus on how to create visually pleasing 3D images of fluid mechanics flows.  


== Converting SPINS outputs to NetCDF files ==
== NetCDF files ==


VisIt prefers to work with NetCDF (.nc) files as opposed to the binary files that SPINS produces.  
VisIt prefers to work with netCDF (.nc) files as opposed to the binary files. You will either need to convert your data into a netCDF file or have your simulation output netCDF files in the first place.
 
'''Converting SPINS outputs to netCDF files:'''
 
To convert SPINS outputs to .nc files, use [[spins2netcdf]].
 
'''Creating netCDF files with the MITgcm:'''
 
[in progress]


== Opening VisIt and Accessing Files ==
== Opening VisIt and Accessing Files ==


Open visit by typing "visit -np #" in the directory you made your .nc files in, where # is the number of processors you wish to use. Two screens will pop up- VisIt's graphical user interface (GUI) and the Visualization Window.  
Open visit by typing "visit -np #" in the directory you made your .nc files in, where # is the number of processors you wish to use. Two screens will pop up- VisIt's graphical user interface (GUI) and the Visualization Window.  
Click ''Open'' in the GUI and chose '''.nc database''' to open all your .nc files at once.
Click ''Open'' in the GUI and chose ''.nc database'' to open all your .nc files at once.


== Expressions ==
== Expressions ==
Line 14: Line 22:
You will have the option to make a plot of one of the primary variables outputted by SPINS (eg. Temperature) or a secondary variable you create yourself (eg. Kinetic Energy).  To plot secondary variables, create an expression by clicking ''Controls -> Expressions'' and adding the variable to the expressions list. Curly braces are used for vectors and tensors. When finished, click ''Apply''.
You will have the option to make a plot of one of the primary variables outputted by SPINS (eg. Temperature) or a secondary variable you create yourself (eg. Kinetic Energy).  To plot secondary variables, create an expression by clicking ''Controls -> Expressions'' and adding the variable to the expressions list. Curly braces are used for vectors and tensors. When finished, click ''Apply''.


[Super side note: If you need derivatives for these secondary variables, you can use spins_3d_derivs and uncomment all the lines for which you want derivatives. (Derivatives are huge so use this sparingly.) Make sure you have a spins.conf that outlines your domain (see sample spins.conf for the bare minimum). Eg. spins_3d_derivs('u',200) will make ux, uy, uz for time output 200. These must also be put into the .nc file for this time output.]
[Side note: If you need derivatives for these secondary variables, you can use derivatives.x in SPINS.]


== Making a 3D Plot ==
== Making a 3D Plot ==
Line 73: Line 81:
  >> f.close()
  >> f.close()
You can now find name.py in your directory in bash and edit it with vim. [However, you must delete the 4 lines containing 'silr' for the script to work (don't ask why).] You can edit many things in the script (eg. colourbar, location of plot, etc.)- play around with it! To run the script from the CLI, type:
You can now find name.py in your directory in bash and edit it with vim. [However, you must delete the 4 lines containing 'silr' for the script to work (don't ask why).] You can edit many things in the script (eg. colourbar, location of plot, etc.)- play around with it! To run the script from the CLI, type:
  >> Source("name.py")
  >> Source("script_name.py")
A useful script is  'visitImageSaver.py' by Jared - this will automatically save a series of images.
A useful script is  'visitImageSaver.py' by Jared - this will automatically save a series of images.
A more detailed python scripting tutorial can be found [http://www.visitusers.org/index.php?title=VisIt-tutorial-Python-scripting here].

Latest revision as of 16:00, 17 April 2018

VisIt is an open source data visualization and analyzation tool. This tutorial will focus on how to create visually pleasing 3D images of fluid mechanics flows.

NetCDF files

VisIt prefers to work with netCDF (.nc) files as opposed to the binary files. You will either need to convert your data into a netCDF file or have your simulation output netCDF files in the first place.

Converting SPINS outputs to netCDF files:

To convert SPINS outputs to .nc files, use spins2netcdf.

Creating netCDF files with the MITgcm:

[in progress]

Opening VisIt and Accessing Files

Open visit by typing "visit -np #" in the directory you made your .nc files in, where # is the number of processors you wish to use. Two screens will pop up- VisIt's graphical user interface (GUI) and the Visualization Window. Click Open in the GUI and chose .nc database to open all your .nc files at once.

Expressions

You will have the option to make a plot of one of the primary variables outputted by SPINS (eg. Temperature) or a secondary variable you create yourself (eg. Kinetic Energy). To plot secondary variables, create an expression by clicking Controls -> Expressions and adding the variable to the expressions list. Curly braces are used for vectors and tensors. When finished, click Apply.

[Side note: If you need derivatives for these secondary variables, you can use derivatives.x in SPINS.]

Making a 3D Plot

Click 'Add' in the GUI and choose any data visualization method you see fit. For visualizing a scalar value in a flow, a volume plot is a good choice (however contours may be good too). This tutorial will focus on volume plots. To create a volume plot, click Add -> Volume and then choose the variable from the list you wish to plot. This will cause a new entry in the plots list to appear. Clicking Draw will create the plot in the Visualization Window. While this is a good start, it's probably not as pretty as you were hoping.

To access volume plot attributes, double click on Volume in the plot list. This will bring up a new window. Change your rendering method from splatting. Ray Casting: Compositing is the most visually pleasing, however it isn't parallelized. If you wish for a quicker option, choose SILVR.

You may also wish to change the colorbar. In the Volume Attributes window, go to the Colorbar (?) tab to see these options. Here you may choose a new colorbar, set new maximum and minimum colorbar values, and change the opacity of parts of the colorbar. Clicking and filling in areas of the 1D Transfer Function will change the opacity of the colours- where entirely filled in means that color will be opaque, and no fill means that color will be completely translucent. Click Apply to make these changes.

Use the slider to change which time output you're viewing. To rotate the image, click and drag. To shift the image, hold the shift button on the keyboard and drag. Click 'Controls->Lighting' to adjust the lighting.

Annotations

To change annotations, click Controls -> Annotations and choose the 3D Annotations tab.

Here in the General 3D tab, you may change the width of your bounding box, turn off the triad, etc. By unchecking Set Scale Values and Set Label Values (?? double check), you may manually set the x, y, and z axis tick marks and locations in their respective tabs. You may also change the font size and wording of their titles.

In the Objects tab, you may change the properties of the legend (ie. location, values, font size, etc.).

Saving a picture

Click File -> Set Save Options to change your preferred file type, name, directory, etc. Clicking Save will save the window as you've laid it out.

Saving a movie

Make sure your .nc database contains all the time outputs you want as frames in your movie. You'll be able to disclude the first few and/or last few frames. Click File->Save Movie. Your options are to save a new simple movie, a new template movie, or an existing template movie.

New Simple Movie:

This creates a movie that iterates through each of the frames in your .nc database, as you've set up in the visualization window.

  • Choose mpeg4 as the format, then click '->' to add to output.
  • Change the frames per seond, first frame, last frame, etc.
  • Continue clicking next until done.

New Template Movie:

This can create a movie using multiple visualization windows. To create new visualization windows, you may select a new window in the drop down menu on the GUI and create it as you please. You may also add different effects such as transitions and rotations. Once you've clicked New Template Movie:

  • Create your layout to have as many viewports (to corrospond to active windows) as you wish. Move the viewports around to your liking. Click Next.
  • Map each window to a viewport.
  • Click 'Sequences' (?) to add effects, such as:
    • Transitions (such as fade in or out)
    • Rotations (this will rotate either the image or the screen around the axis of your choosing).
  • Finish the movie as you would a simple movie.

Existing Template Movie:

Choose from any of the 3 options and finish as you would any other type of movie. A useful template shows slices of your domain in the x, y, and z axes.

Scripting

You may use python scripts to help run more precise VisIt commands. One useful script outlined here is a script for re-creating the current window. This script will save the current window settings. If you run this script in the future, it will create the same layout that you have made. This will be helpful if you don't want to fiddle around with VisIt for hours trying to make the same plot today that you did yesterday.

To save the script of your current window, click Controls->Launch cli. The CLI is a command line interface for VisIt. In the CLI, type:

>> f = Open("script_name.py","wt")
>> WriteScript(f)
>> f.close()

You can now find name.py in your directory in bash and edit it with vim. [However, you must delete the 4 lines containing 'silr' for the script to work (don't ask why).] You can edit many things in the script (eg. colourbar, location of plot, etc.)- play around with it! To run the script from the CLI, type:

>> Source("script_name.py")

A useful script is 'visitImageSaver.py' by Jared - this will automatically save a series of images.

A more detailed python scripting tutorial can be found here.