Skip to content

Commit

Permalink
fix multi-threading, trajectory [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
islent committed Dec 2, 2021
1 parent b1840c0 commit f6c55c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/src/manual/mosaic.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@

```@example mosaic
using AstroPlot
plot_positionslice("mosaic/", "snapshot_", collect(1:9:100), ".gadget2", gadget2(),
dpi = 300, resolution = (800,800),
xlims = (-0.06, +0.06), ylims = (-0.06, +0.06),
times = collect(0.0:0.00005:0.005) * u"Gyr",
markersize = 5.0,
);
mosaicview("mosaic", "pos_", collect(1:9:100), ".png"; fillvalue = 0.5, npad = 3, ncol = 4, rowmajor = true)
```
4 changes: 4 additions & 0 deletions src/analyse/energy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ function sum_kinetic(data::StructArray)
s = similar(data.Potential) .* zero(data.Mass[1])
block = ceil(Int64, length(data) / Threads.nthreads())
Threads.@threads for k in 1:Threads.nthreads()
if k > length(s)
continue
end

Head = block * (k-1) + 1
Tail = block * k
if k == Threads.nthreads()
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/trajectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ $_common_keyword_lims
$_common_keyword_snapshot
"""
function plot_trajectory!(scene, layout, ax, folder::String, filenamebase::String, Counts::Array{Int64,1},
ids::Array{Int64,1}, suffix::String, FileType::AbstractOutputType, u = u"kpc";
ids::Array{Int64,1}, suffix::String, FileType::AbstractOutputType, units = uAstro, fileunits = uGadget2;
xaxis = :x,
yaxis = :y,
xlims = nothing,
Expand All @@ -229,7 +229,7 @@ function plot_trajectory!(scene, layout, ax, folder::String, filenamebase::Strin
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))

if FileType == gadget2()
header, data = read_gadget2(filename)
header, data = read_gadget2(filename, units, fileunits)
elseif FileType == jld2()
data = read_jld(filename)
end
Expand All @@ -242,6 +242,6 @@ function plot_trajectory!(scene, layout, ax, folder::String, filenamebase::Strin
next!(progress, showvalues = [("iter", i), ("file", filename)])
end

return plot_trajectory!(scene, layout, ax, pos, u;
return plot_trajectory!(scene, layout, ax, pos, getuLength(units);
xaxis, yaxis, xlims, ylims, colors,kw...)
end

0 comments on commit f6c55c1

Please sign in to comment.