forlano Messages: 1185 Registered: March 2006 Location: Italy
Senior Contributor
mr_ped wrote on Mon, 02 May 2016 02:32
There's probably million possible ways, and to get some near-optimal advice you would have to show here the whole process and details.
Thanks both for reply!
Few more details. The particles are all the same and can be a huge number for example 1000 (and more if one has a super computer!). In principle the particle interacts with all others (particle i exerts a force on j and viceversa). As result of this interactions the particle can freely move around the domain.
However the interaction range of such force is just a fraction of the whole dimension of the simulation domain (you may think a square DxD). To save a lot of computation time then come up the concept of cell. Each has dimension d=D/n, where d a bit gretear than the force range.
In this way you can scan the domain by cell, pick a particle inside it and look for other particles that stay in the same cell and in its neighbour cells (https://en.wikipedia.org/wiki/Cell_lists)
Each cell must have a container of the particle they belong to. During the upgrade process I must pick a particle from one cell (find and delete it) and move in another one (append).
I never used std::set. Perhaps it can be a good alternative to linked list.