1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-11-12 22:40:44 +00:00
ReCo.jl/src/data.jl

41 lines
815 B
Julia
Raw Normal View History

2021-11-10 14:41:04 +00:00
struct Solution
t::Vector{Float64}
2021-11-10 23:24:07 +00:00
center::Matrix{Vector{Float64}}
2021-11-10 14:41:04 +00:00
φ::Matrix{Float64}
function Solution(N::Int64, n_frames::Int64)
return new(zeros(n_frames), [zeros(2) for i in 1:N, j in 1:n_frames], zeros((N, n_frames)))
end
end
2021-11-10 23:24:07 +00:00
function save_frame!(sol, frame, t, particles)
frame += 1
sol.t[frame] = t
@simd for p in particles
p_id = p.id
pre_pos = sol.center[p_id, frame]
@simd for i in 1:2
pre_pos[i] = p.c[i]
end
sol.φ[p_id, frame] = p.φ
end
return frame
end
2021-11-10 14:41:04 +00:00
function save_data_jld(sol, args, name_part)
println("Saving data...")
data_path = "exports/$name_part.jld2"
jldsave(data_path; sol, args, name_part)
println("Data saved to $data_path.")
return nothing
end