Visualization
Export VTK files
You can export particle data as VTK files by using the SolutionSavingCallback
. All our predefined examples are already using this callback to export VTK files to the out
directory (relative to the directory that you are running Julia from). VTK files can be read by visualization tools like ParaView and VisIt.
ParaView
Follow these steps to view the exported VTK files in ParaView:
- Click
File -> Open
. - Navigate to the
out
directory (relative to the directory that you are running Julia from). - Open both
boundary_1.pvd
andfluid_1.pvd
. - Click "Apply", which by default is on the left pane below the "Pipeline Browser".
- Hold the left mouse button to move the solution around.
You will now see the following:
To now view the result variables first make sure you have "fluid_1.pvd" highlighted in the "Pipeline Browser" then select them in the variable selection combo box (see picture below). Let's, for example, pick "density". To now view the time progression of the result hit the "play button" (see picture below).
API
TrixiParticles.trixi2vtk
— Methodtrixi2vtk(vu_ode, semi, t; iter=nothing, output_directory="out", prefix="",
write_meta_data=true, max_coordinates=Inf, custom_quantities...)
Convert Trixi simulation data to VTK format.
Arguments
vu_ode
: Solution of the TrixiParticles ODE system at one time step. This expects anArrayPartition
as returned in the examples assol.u[end]
.semi
: Semidiscretization of the TrixiParticles simulation.t
: Current time of the simulation.
Keywords
iter=nothing
: Iteration number when multiple iterations are to be stored in separate files. This number is just appended to the filename.output_directory="out"
: Output directory path.prefix=""
: Prefix for output files.write_meta_data=true
: Write meta data.max_coordinates=Inf
The coordinates of particles will be clipped if their absolute values exceed this threshold.custom_quantities...
: Additional custom quantities to include in the VTK output. Each custom quantity must be a function of(v, u, t, system)
, which will be called for every system, wherev
andu
are the wrapped solution arrays for the corresponding system andt
is the current simulation time. Note that working with thesev
andu
arrays requires undocumented internal functions of TrixiParticles. See Custom Quantities for a list of pre-defined custom quantities that can be used here.
Example
trixi2vtk(sol.u[end], semi, 0.0, iter=1, output_directory="output", prefix="solution")
# Additionally store the kinetic energy of each system as "my_custom_quantity"
trixi2vtk(sol.u[end], semi, 0.0, iter=1, my_custom_quantity=kinetic_energy)
TrixiParticles.trixi2vtk
— Methodtrixi2vtk(coordinates; output_directory="out", prefix="", filename="coordinates",
custom_quantities...)
Convert coordinate data to VTK format.
Arguments
coordinates
: Coordinates to be saved.
Keywords
output_directory="out"
: Output directory path.prefix=""
: Prefix for the output file.filename="coordinates"
: Name of the output file.custom_quantities...
: Additional custom quantities to include in the VTK output.
Returns
file::AbstractString
: Path to the generated VTK file.
TrixiParticles.trixi2vtk
— Methodtrixi2vtk(initial_condition::InitialCondition; output_directory="out",
prefix="", filename="initial_condition", custom_quantities...)
Convert InitialCondition
data to VTK format.
Arguments
initial_condition
:InitialCondition
to be saved.
Keywords
output_directory="out"
: Output directory path.prefix=""
: Prefix for the output file.filename="coordinates"
: Name of the output file.custom_quantities...
: Additional custom quantities to include in the VTK output.
Returns
file::AbstractString
: Path to the generated VTK file.