Results form Sailfish simulations can saved to disk for processing in external applications or visualized in real-time. These options are not exclusive, so concurrent visualization and data saving is fully supported.
Sailfish supports a number of output data formats. The data format is selected using the --output_format command line option, which can take one of the values listed in the “Parameter name” column below:
Data format | Parameter name | Required Python modules |
---|---|---|
HDF5 (flat) | h5flat | pytables |
HDF5 (nested) | h5nested | pytables |
VTK | vtk | tvtk |
numpy archive | npy | numpy |
MatLab array | mat | scipy |
In all modes, the name of the output file is specified using the --output command line option, though the exact meaning of this is different for different file formats.
In the h5nested mode, a single HDF5 file is created. The file contains a single group called results. The group contains a single table and each record in this table corresponds to the state of the simulation at a specific iteration. The table contains columns for velocity components (vx, vy and vz), density (rho), the current iteration (iter), and possibly also other scalar and vector fields used in the simulation.
In the h5flat mode, also a single HDF5 file is created. The file contains multiple groups, called iterXXX where XXX is the iteration number. Each of the groups contains a number of arrays with the scalar and vector field data.
In the vtk, npy and mat modes, multiple files are generated, each containing the state of the simulation at a specific iteration. The file names are generated by appending the iteration number to the base name provided via the --output option, e.g. if --output=poiseuille is used, poiseuille00400.xml will contain data for the 400th iteration.
Sailfish supports on-line data visualization regardless of whether any results are written out to files on disk. If you don’t want any visualization, start your simulations with the --batch option. The visualization modules for 2D and 3D are different, and thus will be discussed separately.
2D simulations can be monitored using an interactive pygame-based interface. The interface supports a number of color maps, which can be changed interactively (see below).
The initial size of the visualization window can be controlled with command line parameters. One can specify its size explicitly using the --scr_w and --scr_h options to set the width and height, respectively. Alternatively, the --scr_scale option can be used to make the window dimensions directly proportional to those of the lattice, e.g. if --scr_scale=3 is used the window will be 3 times larger than the lattice and each lattice site will be visualized as a 3x3 square.
Interaction with the simulation is provided via mouse: left key presses place walls (i.e. nodes with the no-slip boundary condition, with no intrinsic velocity) in the simulation domain, and right key presses remove them. Moving the mouse with the Ctrl key pressed, will impart velocity to the fluid under the mouse cursor. The --imparted_velocity and --imparted_diameter options can be used to control this process.
The visualization module can be controlled from the keyboard, and the following keys are defined:
- | previous scalar field |
= | next scalar field |
[ | previous color map |
] | next color map |
i | toggle visibility of text info about the state of the simulation (MLUPS, iteration etc.) |
v | toggle visualization of the velocity vector field |
t | toggle visualization of the fluid tracer particles |
c | toggle convolution of the visualization with a Gaussian kernel (this has a smoothing effect) |
e | apply the emboss filter to the visualization (useful to monitor sound waves) |
r | reset the simulation geometry (this clears any obstacles added interactively) |
q | quit the simulation |
s | take a screenshot |
, | decrease the max value used in the color map |
. | increase the max value used in the color map |
3D data visualization is provided via the mayavi package. This visualization is not interactive at this time.
3D data can also be visualized in cutplane mode, using the pygame-based interface. To select this mode, use the --vis=cutplane command line option. Only cutplanes perpendicular to a domain axis are currently supported. The x, y and z keys can be used to select the cutplane. The ; and ' keys can be used to move the cutplane along the selected axis. Tracer particles are not supported in the cutplane mode.