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.
The nature of RK4 integration requires a bit of a rethink into how the particle updates are parallelized. I've refactored both the Euler and RK4
updateVelocity
functions to place the parallelization inside the scope of the functions themselves. Assuming I've done this correctly, this should now be able to correctly implement RK4, as well as providing additional flexibility if/when you decide to try more integrators.I spent a few days trying to setup an environment for developing Java, but I couldn't figure out how to get the app to import from my local code. As such, this code is completely untested! I realize that this is a terrible practice, and I apologize for the fact that I'm essentially asking you to debug my code. Having said that, I think I understand at least the organization of your code well enough to provide a decent starting point. A few points to be aware of:
particlesBuffer
attribute of thePhysics
class which didn't seem to get used anywhere, so I used it to hold onto the temporary steps involved in RK4. If that was actually something important, you should be able to just create another array of particles as a public attribute.loadDistributor.distributeLoadEvenly
withinupdateVelocityRK4
. The first 4 calculate the k-values, and the 5th applies them.getContainers()
, it might make sense to call that before calculating each k-coefficient.