Skip to content

Commit 1ccaf76

Browse files
authored
Merge pull request #248 from marinlauber/fix_readvtk_fieldnames
Better restart field specification for ReadVTK extension
2 parents 2d41ba1 + ab46b9c commit 1ccaf76

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ext/WaterLilyReadVTKExt.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ The time step is also updated to match the time step of the vtk file, such that
2020
Keyword arguments considered are `fname="WaterLily.pvd"` and `attrib=default_attrib()`.
2121
"""
2222
function load!(a::AbstractSimulation, ::Val{:pvd}; kwargs...)
23-
kwargs_dict = Dict(kwargs)
24-
fname = get(kwargs_dict, :fname, "WaterLily.pvd")
25-
attrib = get(kwargs_dict, :attrib, default_attrib())
23+
fname = get(Dict(kwargs), :fname, "WaterLily.pvd")
24+
attrib = get(Dict(kwargs), :attrib, default_attrib())
2625
vtk = VTKFile(PVDFile(fname).vtk_filenames[end])
2726
extent = filter(!iszero,ReadVTK.get_whole_extent(vtk)[2:2:end]);
2827
# check dimensions match
2928
text = "The dimensions of the simulation do not match the dimensions of the vtk file."
3029
@assert extent.+1 == collect(size(a.flow.p)) text
3130
# fill the arrays for pressure and velocity
3231
point_data = ReadVTK.get_point_data(vtk)
33-
copyto!(a.flow.p, WaterLily.squeeze(Array(get_data_reshaped(point_data["Pressure"]))));
34-
copyto!(a.flow.u, WaterLily.squeeze(components_last(Array(get_data_reshaped(point_data["Velocity"])))));
32+
pressure = get(Dict(kwargs), :pressure, "Pressure")
33+
velocity = get(Dict(kwargs), :velocity, "Velocity")
34+
copyto!(a.flow.p, WaterLily.squeeze(Array(get_data_reshaped(point_data[pressure]))));
35+
copyto!(a.flow.u, WaterLily.squeeze(components_last(Array(get_data_reshaped(point_data[velocity])))));
3536
# reset time to work with the new time step
3637
a.flow.Δt[end] = PVDFile(fname).timesteps[end]*a.L/a.U
3738
push!(a.flow.Δt,WaterLily.CFL(a.flow))

0 commit comments

Comments
 (0)