Fix bond visualization; data handling. #4502
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add updates for bond data in OpenGL visualizer.
Up to now, the OpenGL visualizer collected information about the bonds in a system only once, on initialization. Simulations that dynamically add or remove bonds while running were therefore not correctly visualized.
Note that still dynamic removal of particles or bonds may result in race conditions, if during the drawing process new data has been fetched from the core where particles are no longer available. To lower the chance of this to happen, the data collection now happens with just one communication of
system.parts.all()
as well as bond drawing catching (and ignoring) this exception. (Another point where that might happen is_draw_system_particles()
, if this proves to be an issue, I can give it another look.)While this increases the amount of data being communicated, it also reduces the number of communications. To check the performance impact, both the old and new version of the
_update_particles
method were tested on a simple LJ fluid (868 particles). When communicating the minimum number of attributes (pos
andtype
) the slowdown is about 4 %, when communicating all attributes we get about 4 % speedup. In practice, this does not seem to have a noticeable impact on visualization performance of common simulation setups.Also, parts of the visualizer, such as the
_draw_system_particles()
method, relied on the particle ids communicated by the core to be contiguous.Description of changes: