1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-11-08 22:21:08 +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" bundles_dir = "$dir/bundles"
mkpath(bundles_dir) 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))) 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 end
function sorted_bundle_paths(dir::String; rev::Bool=false) 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) n_bundles = length(bundle_paths)
bundle_nums = Vector{Int64}(undef, n_bundles) bundle_nums = Vector{Int64}(undef, n_bundles)
extension_length = 5 # == length(".jld2") @simd for bundle_ind in 1:n_bundles
bundle_path = bundle_paths[bundle_ind]
for i in 1:n_bundles bundle_name = splitdir(bundle_path)[2]
bundle_path = bundle_paths[i] bundle_num_string = splitext(bundle_name)[1]
bundle_num_string = bundle_path[(findfirst("bundle_", bundle_path).stop + 1):(end - extension_length)] bundle_nums[bundle_ind] = parse(Int64, bundle_num_string)
bundle_nums[i] = parse(Int64, bundle_num_string)
end end
sort_perm = sortperm(bundle_nums; rev=rev) sort_perm = sortperm(bundle_nums; rev=rev)
@ -113,8 +113,8 @@ function append_bundle_properties!(
) where {N} ) where {N}
bundle_paths = ReCo.sorted_bundle_paths(sim_dir) bundle_paths = ReCo.sorted_bundle_paths(sim_dir)
for i in first_bundle:length(bundle_paths) for bundle_ind in first_bundle:length(bundle_paths)
bundle::ReCo.Bundle = JLD2.load_object(bundle_paths[i]) bundle::ReCo.Bundle = JLD2.load_object(bundle_paths[bundle_ind])
for (v_ind, v) in enumerat(vs) for (v_ind, v) in enumerat(vs)
property = properties[v_ind] property = properties[v_ind]

View file

@ -74,7 +74,7 @@ function run_sim(
end end
bundles_dir = "$dir/bundles" 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) particles = gen_particles(bundle, sim_consts.n_particles)