Skip to content

Commit

Permalink
Add trixi2vtk wrapper for InitialCondition (#546)
Browse files Browse the repository at this point in the history
* add wrapper

* modify kwarg

* implement suggestions
  • Loading branch information
LasNikas authored Jun 19, 2024
1 parent 5deebdd commit 4af461d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/visualization/write2vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,32 @@ function trixi2vtk(coordinates; output_directory="out", prefix="", filename="coo
return file
end

"""
trixi2vtk(initial_condition::InitialCondition; output_directory="out",
prefix="", filename="initial_condition", custom_quantities...)
Convert [`InitialCondition`](@ref) data to VTK format.
# Arguments
- `initial_condition`: [`InitialCondition`](@ref) to be saved.
# Keywords
- `output_directory="out"`: Output directory path.
- `prefix=""`: Prefix for the output file.
- `filename="coordinates"`: Name of the output file.
# Returns
- `file::AbstractString`: Path to the generated VTK file.
"""
function trixi2vtk(initial_condition::InitialCondition; output_directory="out",
prefix="", filename="initial_condition", custom_quantities...)
(; coordinates, velocity, density, mass, pressure) = initial_condition

return trixi2vtk(coordinates; output_directory, prefix, filename,
density=density, initial_velocity=velocity, mass=mass,
pressure=pressure)
end

function write2vtk!(vtk, v, u, t, system; write_meta_data=true)
vtk["velocity"] = view(v, 1:ndims(system), :)

Expand Down

0 comments on commit 4af461d

Please sign in to comment.