Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing zeros in time step of exported files #182

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/auxiliary/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ end
end

@inline function _get_filename(vtk_filebase::String, ::Symbol, n::Int)
return @sprintf("%s_%06d", vtk_filebase, n) #TODO: remove trailing zeros
return @sprintf("%s_%d", vtk_filebase, n)
end

@inline function _get_filename(vtk_filebase::Dict{Symbol,String}, body_name::Symbol, n::Int)
return @sprintf("%s_%06d", vtk_filebase[body_name], n) #TODO: remove trailing zeros
return @sprintf("%s_%d", vtk_filebase[body_name], n)
end

function export_fields!(vtk, chunk, fields::Vector{Symbol})
Expand Down
12 changes: 6 additions & 6 deletions test/auxiliary/test_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ end
n_chunks = 1
Peridynamics.export_results(dh, options, chunk_id, n, t)

pvtu_file_ref = joinpath(temp_root, "vtk", "timestep_000000.pvtu")
pvtu_file_ref = joinpath(temp_root, "vtk", "timestep_0.pvtu")
@test isfile(pvtu_file_ref)
pvtu_file_n = joinpath(temp_root, "vtk", "timestep_000001.pvtu")
pvtu_file_n = joinpath(temp_root, "vtk", "timestep_1.pvtu")
@test isfile(pvtu_file_n)

r0 = read_vtk(pvtu_file_ref)
Expand Down Expand Up @@ -327,13 +327,13 @@ end
Peridynamics.export_results(dh_a, options, chunk_id, n, t)
Peridynamics.export_results(dh_b, options, chunk_id, n, t)

pvtu_file_a_ref = joinpath(temp_root, "vtk", "a_timestep_000000.pvtu")
pvtu_file_a_ref = joinpath(temp_root, "vtk", "a_timestep_0.pvtu")
@test isfile(pvtu_file_a_ref)
pvtu_file_a_n = joinpath(temp_root, "vtk", "a_timestep_000001.pvtu")
pvtu_file_a_n = joinpath(temp_root, "vtk", "a_timestep_1.pvtu")
@test isfile(pvtu_file_a_n)
pvtu_file_b_ref = joinpath(temp_root, "vtk", "b_timestep_000000.pvtu")
pvtu_file_b_ref = joinpath(temp_root, "vtk", "b_timestep_0.pvtu")
@test isfile(pvtu_file_b_ref)
pvtu_file_b_n = joinpath(temp_root, "vtk", "b_timestep_000001.pvtu")
pvtu_file_b_n = joinpath(temp_root, "vtk", "b_timestep_1.pvtu")
@test isfile(pvtu_file_b_n)

r_a = read_vtk(pvtu_file_a_ref)
Expand Down
Loading