Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support gather/scatter #42

Closed
wants to merge 7 commits into from
Closed

Conversation

Joroks
Copy link
Collaborator

@Joroks Joroks commented Jun 20, 2024

Adresses #41

I've decided to roll lammps_gather(), lammps_gather_subset() into one function. I've done the same for gather_atoms() and scatter!()

Copy link
Member

@vchuravy vchuravy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also need to add some tests

src/LAMMPS.jl Outdated
elseif T === Float64
dtype = 1
"""
gather_atoms(lmp::LMP, name::String, T::Union{Type{Int32}, Type{Float64}}, count::Integer, ids::Union{Nothing, Array{Int32}}=nothing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding the docstring a bit would be nice.

src/LAMMPS.jl Outdated
if ids === nothing
natoms = get_natoms(lmp)
data = Array{T, 2}(undef, (count, natoms))
API.lammps_gather(lmp, name, dtype, count, data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between gather and gather_atomis?

Copy link
Collaborator Author

@Joroks Joroks Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like gather_atoms is basically just a more restrictive version of gather. If I've understood it correctlly, gather_atoms only works on normal atom data, so the data you could get by calling extract_atoms while gather works on any per-atom property such as computes and fixes.

I've left gather_atoms in because I didn't want to remove any already existing methods

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use the same logic from extract_atom in gather_atom to determine the datatype and count of the property, wich would make it a more convenient version of gather where the datatype and count are determined through the C-API

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think I would be okay with @deprecate gather_atoms gather

where the datatype and count are determined through the C-API

One downside of this is that the resulting Julia code is type-unstable.
So having the user provide the eltype of the output is probably a better API design,
but we should safety check that the LAMMPS eltype corresponds.

@Joroks Joroks marked this pull request as draft June 20, 2024 18:52
@Joroks
Copy link
Collaborator Author

Joroks commented Jun 20, 2024

I still have to implement automated tests. Hopefully I'll get to that soon. During testing I've noticed that LAMMPS crashed multiple times, taking julia with it, probably due to illegal memory access. I've added a ton of safety checks and it should now be hopefully impossible (or at least considerably more difficult) to crash LAMMPS due to bad input.

@Joroks Joroks closed this Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants