I've been fooling around with my granular particles repository these past days before do a real coding into Krita. I'm trying to optimize my simulation through a series of modifications in the code I wrote last week.
My first attempt to run this granular particles simulation was quite a big failure, since it was really slow and full of errors. I correct some small things this past weekend and during this week I implemented a neighborhood restriction to the collision detection between particles.
One of the reasons the code had a slow response was the fact that each particle was doing a collision detection with every other particle in the simulation. I initialized with 2010 particles, so we had a lot time wasted just doing useless calculations, since we only had to worry about each particle vicinity. So this time I implemented a grid so we could restrict the computation of collision only for neighbors particles. I have yet some other two improvements to test before generate some QImages: try the RK4 integrator instead of the Gear's predictor and corrector, and a more vectorizable grid construction which will be more easily implemented in a GPU.
I'm already writting a more detailed post with all the theory used behind the scenes. But if you already took a look at the code before, this update will be easy to understand. Again, the code is well commented and any questions you can contact me here in the comments or sending me a message to my Gitorious account.
See you all soon! :)