1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-09-17 18:51:17 +00:00

Better bundle paths

This commit is contained in:
Mo8it 2022-01-24 21:27:43 +01:00
parent 3e02920067
commit 0d6c590061
2 changed files with 11 additions and 11 deletions

View file

@ -76,7 +76,7 @@ function save_bundle(dir::String, bundle::Bundle, n_bundle::Int64, T::Float64)
bundles_dir = "$dir/bundles"
mkpath(bundles_dir)
JLD2.save_object("$bundles_dir/bundle_$n_bundle.jld2", bundle)
JLD2.save_object("$bundles_dir/$n_bundle.jld2", bundle)
JLD2.save_object("$dir/sim_state.jld2", SimState(n_bundle, round(T; digits=3)))
@ -84,18 +84,18 @@ function save_bundle(dir::String, bundle::Bundle, n_bundle::Int64, T::Float64)
end
function sorted_bundle_paths(dir::String; rev::Bool=false)
bundle_paths = readdir("$dir/bundles"; join=true, sort=false)
bundles_dir = "$dir/bundles"
bundle_paths = readdir(bundles_dir; join=true, sort=false)
n_bundles = length(bundle_paths)
bundle_nums = Vector{Int64}(undef, n_bundles)
extension_length = 5 # == length(".jld2")
for i in 1:n_bundles
bundle_path = bundle_paths[i]
bundle_num_string = bundle_path[(findfirst("bundle_", bundle_path).stop + 1):(end - extension_length)]
bundle_nums[i] = parse(Int64, bundle_num_string)
@simd for bundle_ind in 1:n_bundles
bundle_path = bundle_paths[bundle_ind]
bundle_name = splitdir(bundle_path)[2]
bundle_num_string = splitext(bundle_name)[1]
bundle_nums[bundle_ind] = parse(Int64, bundle_num_string)
end
sort_perm = sortperm(bundle_nums; rev=rev)
@ -113,8 +113,8 @@ function append_bundle_properties!(
) where {N}
bundle_paths = ReCo.sorted_bundle_paths(sim_dir)
for i in first_bundle:length(bundle_paths)
bundle::ReCo.Bundle = JLD2.load_object(bundle_paths[i])
for bundle_ind in first_bundle:length(bundle_paths)
bundle::ReCo.Bundle = JLD2.load_object(bundle_paths[bundle_ind])
for (v_ind, v) in enumerat(vs)
property = properties[v_ind]

View file

@ -74,7 +74,7 @@ function run_sim(
end
bundles_dir = "$dir/bundles"
bundle::Bundle = JLD2.load_object("$bundles_dir/bundle_$n_bundles.jld2")
bundle::Bundle = JLD2.load_object("$bundles_dir/$n_bundles.jld2")
particles = gen_particles(bundle, sim_consts.n_particles)