Heya, On 01:52 Sat 24 Mar , Evgeny wrote: > I have a question about your bouncing spheres example. You said, that > spheres don't actually see a grid, only neighboring spheres, but how > neighborhood choses actually, I caught myself thinking, when I went deep > enough into the source code of the library itself, but then realized that > obviously it should be set by some api, but can't found which.
very good question. So, in the example code you've probably seen that main() instantiates a SerialSimulator<Container> [1]. The SerialSimulator actually operates on a 3d, regular grid. The reason that the spheres only see neighboring spheres (and boundary elements) is because Container provides adapters that translate the neighborhood of grid cells into a neighborhood of particles (and boundaries). Container inherits from BaseContainer[2]. This class is generated via DECLARE_MULTI_CONTAINER_CELL() and does some behind the scenes magic. Here is a quick rundown of what happens during simulation: 1. SerialSimulator will call update on all instances of Container in the 3D grid. 2. Container::update() is actually BaseContainer::update(), because inheritance. It receives a neighborhood object with can be addressed via relative coordinates (e.g. Coord<3>(-1, 0, 0)) to retrieve neighboring Container objects. 3. BaseContainer::update() now iterates over all elements in its members "spheres" and "boundaries" and calls Sphere::update() and Boundary::update() respectively. But instead of passing the neighborhood object it got from the SerialSimulator, it will pass on a new neighborhood object[3], a MultiNeighborhoodAdapter[4]. This has two members, called "spheres" and "boundaries", which are generated in the expansion of the macro DECLARE_MULTI_CONTAINER_CELL(). 4. These members are actually of type NeighborhoodIteratorHelpers::Adapter[5]. This object does the translation from the neighborhood that is defined on the regular grid towards iterating over spheres (or boundaries). So yeah, definitely a lot going on under the hood. :-) Did this answer your question? Feel free to ask more. Cheers -Andi [1] https://github.com/STEllAR-GROUP/libgeodecomp/blob/master/src/examples/bouncingspheres/main.cpp#L384 [2] https://github.com/STEllAR-GROUP/libgeodecomp/blob/master/src/examples/bouncingspheres/main.cpp#L165 [3] https://github.com/STEllAR-GROUP/libgeodecomp/blob/master/src/libgeodecomp/storage/multicontainercell.h#L157 [4] https://github.com/STEllAR-GROUP/libgeodecomp/blob/master/src/libgeodecomp/storage/multicontainercell.h#L109 [5] https://github.com/STEllAR-GROUP/libgeodecomp/blob/master/src/libgeodecomp/storage/neighborhooditerator.h#L19 -- ========================================================== Andreas Schäfer HPC and Supercomputing for Computer Simulations LibGeoDecomp project lead, http://www.libgeodecomp.org PGP/GPG key via keyserver I'm an SRE @ Google, this is a private account though. All mails are my own and not Google's. ========================================================== (\___/) (+'.'+) (")_(") This is Bunny. Copy and paste Bunny into your signature to help him gain world domination!
signature.asc
Description: Digital signature
_______________________________________________ hpx-users mailing list [email protected] https://mail.cct.lsu.edu/mailman/listinfo/hpx-users
