Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
henry2004y committed Jul 17, 2023
1 parent 4f9e488 commit fda3991
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/vlsv/vlsvreader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const NodeVector = SubArray{Node, 1, Vector{Node}, Tuple{UnitRange{Int64}},
vmin::NTuple{3, Float64}
vmax::NTuple{3, Float64}
dv::NTuple{3, Float64}
@lazy cellsWithVDF::Vector{Int}
@lazy cellwithVDF::Vector{Int}
@lazy nblock_C::Vector{Int}
end

Expand Down Expand Up @@ -824,18 +824,17 @@ return a map of velocity cell ids `vcellids` and corresponding value `vcellf`.
function readvcells(meta::MetaVLSV, cid::Int; species::String="proton")
(;fid, nodeVLSV) = meta
(;vblock_size) = meta.meshes[species]
bsize = prod(vblock_size)

if !@isinit meta.meshes[species].cellsWithVDF
if !@isinit meta.meshes[species].cellwithVDF
for node in nodeVLSV.cellwithVDF
at = attributes(node)
if at["name"] == species
asize = Parsers.parse(Int, at["arraysize"])
offset = Parsers.parse(Int, value(node[1]))
cellsWithVDF = Vector{Int}(undef, asize)
cellwithVDF = Vector{Int}(undef, asize)
seek(fid, offset)
read!(fid, cellsWithVDF)
@init! meta.meshes[species].cellsWithVDF = cellsWithVDF
read!(fid, cellwithVDF)
@init! meta.meshes[species].cellwithVDF = cellwithVDF
break
end
end
Expand All @@ -858,7 +857,7 @@ function readvcells(meta::MetaVLSV, cid::Int; species::String="proton")
end
end

cellWithVDFIndex = findfirst(==(cid), meta.meshes[species].cellsWithVDF)
cellWithVDFIndex = findfirst(==(cid), meta.meshes[species].cellwithVDF)
if !isnothing(cellWithVDFIndex)
@inbounds nblocks = meta.meshes[species].nblock_C[cellWithVDFIndex]
if nblocks == 0
Expand All @@ -881,6 +880,8 @@ function readvcells(meta::MetaVLSV, cid::Int; species::String="proton")
end
end

bsize = prod(vblock_size)

data = let
T = dsize == 4 ? Float32 : Float64
a = mmap(fid, Vector{UInt8}, dsize*bsize*nblocks, offset_v*bsize*dsize + offset)
Expand Down

0 comments on commit fda3991

Please sign in to comment.