There are two tools provided with Trixi that allow to visualize Trixi's output files, both of which are available as Julia packages: Trixi2Vtk.jl and Trixi2Img.jl.
Trixi2Vtk converts Trixi's .h5
output files to VTK files, which can be read
by ParaView, VisIt, and other visualization tools. It
automatically interpolates solution data from the original quadrature node
locations to equidistant visualization nodes at a higher resolution, to make
up for the loss of accuracy from going from a high-order polynomial
representation to a piecewise constant representation in VTK.
In the Julia REPL, first load the package Trixi2Vtk
julia> using Trixi2Vtk
To process an HDF5 file generated by Trixi.jl, execute
julia> trixi2vtk(joinpath("out", "solution_000000.h5"), output_directory="out")
This will create two unstructured VTK files in the out/
subdirectory that can
be opened with ParaView or VisIt: solution_000000.vtu
contains the
discontinuous Galerkin solution data while solution_000000_celldata.vtu
holds
any cell-based values such as the current AMR indicator or the cell refinement
level.
This allows you to generate VTK files for solution, restart and mesh files. By
default, Trixi2Vtk generates .vtu
(unstructured VTK) files for both
cell/element data (e.g., cell ids, element ids) and node data (e.g., solution
variables). This format visualizes each cell with the same number of nodes,
independent of its size. Alternatively, you can provide format=:vti
as a
keyword argument to trixi2vtk
, which causes Trixi2Vtk to generate
.vti
(image data VTK) files for the solution files, while still using .vtu
files for cell-/element-based data. In .vti
files, a uniform resolution is
used throughout the entire domain, resulting in different number of
visualization nodes for each element. This can be advantageous to create
publication-quality images, but increases the file size.
If you want to convert multiple solution/restart files at once, you can just supply
multiple input files as the positional arguments to trixi2vtk
, e.g.,
julia> trixi2vtk("out/solution_000000.h5", "out/solution_000040.h5")
You may also use file globbing to select a range of files based on filename patterns, e.g.,
julia> trixi2vtk("out/solution_*.h5")
to convert all solution files in the out/
directory or
julia> trixi2vtk("out/restart_00[0-9]000.h5")
to convert every one-thousandth restart file (out/restart_000000.h5
,
out/restart_001000.h5
etc.).
When multiple solution/restart files are provided, Trixi2Vtk will also generate a
.pvd
file, which allows ParaView to read all .vtu
/.vti
files at once and which
uses the time
attribute in solution/restart files to inform ParaView about the
solution time. A comprehensive list of all possible arguments for
trixi2vtk
can be found in the Trixi2Vtk.jl API.
Trixi2Img can be used to directly convert Trixi's output files to image files, without having to use a third-pary visualization tool such as ParaView or VisIt. The downside of this approach is that it generally takes longer to visualize the data (especially for large files) and that it does not allow as much customization of the generated output files. Currently, PNG and PDF are supported as output formats.
In the Julia REPL, first load the package Trixi2Img
julia> using Trixi2Img
To process an HDF5 file generated by Trixi.jl, execute
julia> trixi2img(joinpath("out", "solution_000040.h5"), output_directory="out", grid_lines=true)
This will create a file solution_000040_scalar.png
in the out/
subdirectory
that can be opened with any image viewer:
To visualize 3D data generated by Trixi.jl, a 2D slice must be extracted. A slice can only lie in a plane orthogonal to one of the coordinate axes. The slice plane is defined by the axis to which it is orthogonal and an axis intercept.
For example, to create a 2D slice in the xy-plane at the axis intercept z = 0.5
from 3D data, execute
julia> trixi2img(joinpath("out", "solution_000000.h5"), output_directory="out", grid_lines=true, slice_axis=:z, slice_axis_intercept=0.5)
Similar to Trixi2Vtk, you can also provide multiple files to
trixi2img
or use file globbing, e.g.,
julia> trixi2img("out/solution_*.h5")
to convert all solution files. The default is to generate a PNG file for each
variable found in the respective file. Use format=:pdf
as a keyword argument
to create PDF files. A comprehensive list of all possible arguments for
trixi2img
can be found in the Trixi2Img.jl API.