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

Make AtomView rely on struct-of-array format #68

Merged
merged 5 commits into from
Mar 22, 2023

Conversation

Liozou
Copy link
Contributor

@Liozou Liozou commented Mar 21, 2023

Hi! Here is a proposal to simplify a little bit the definition of struct-of-array systems, like FastSystem.

Currently, the two following definitions are required for each property like position:

position(s::FastSystem) = s.position
position(s::FastSystem, i) = s.position[i]

Since they are quite redundant, I suggest not requiring the latter. Instead, a position(system, i) call would be intercepted by the already existing fallback

position(sys::AbstractSystem, index) = position(sys[index])

which can be made to work simply by tweaking the definitions of position(v::AtomView). The emitted code should be identical in the end.

Also add some documentation for AtomView (since it is already exported and mentioned in the docs).

Copy link
Member

@mfherbst mfherbst left a comment

Choose a reason for hiding this comment

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

Very nice. I think we should've done this in the first place.

src/fast_system.jl Show resolved Hide resolved
test/printing.jl Show resolved Hide resolved
test/fast_system.jl Outdated Show resolved Hide resolved
@mfherbst mfherbst enabled auto-merge (squash) March 22, 2023 14:39
@mfherbst mfherbst merged commit 3479b6f into JuliaMolSim:master Mar 22, 2023
@Liozou
Copy link
Contributor Author

Liozou commented Mar 22, 2023

Great, thanks for the review!

@Liozou Liozou deleted the atomviewupdate branch March 22, 2023 14:42
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.

None yet

2 participants