Skip to content

Commit

Permalink
Add copy kwarg to extract_atom
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Nov 4, 2023
1 parent e67bbc4 commit c03b066
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/LAMMPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ end
"""
function extract_atom(lmp::LMP, name,
dtype::Union{Nothing, API._LMP_DATATYPE_CONST} = nothing,
axes1=nothing, axes2=nothing)
axes1=nothing, axes2=nothing; copy=true)


if dtype === nothing
Expand Down Expand Up @@ -234,7 +234,12 @@ function extract_atom(lmp::LMP, name,
ptr = API.lammps_extract_atom(lmp, name)
ptr = reinterpret(type, ptr)

unsafe_wrap(ptr, shape)
arr = unsafe_wrap(ptr, shape)
if copy
return Base.copy(arr)
else
return arr
end
end

function unsafe_extract_compute(lmp::LMP, name, style, type)
Expand Down

0 comments on commit c03b066

Please sign in to comment.