octree - Barnes Hut worst case memory scenario -
i want run barnes hut n-body simulation (wikipedia article). know how memory single node of octree occupy, can't figure out worst case memory usage scenario given number of particles. in short, i'm wondering how many nodes possibly exist in octree given number of particles. need know know how memory allocate octree.
edit:
oh, , i'm writing in c if wants give me code instead of , explanation.
i have this, way worse worst case scenario. it's guaranteed @ least allocate enough memory. i'm hoping can give me little more memory efficient.
int kbh_worstcase(int particles) { // returns number of nodes required store number of particles in worst case scenario int worst; unsigned int n; worst=1; n=1; while(n<particles) { n=n<<3; worst+=n; } return worst; }
i'm not sure if such suitable criterion exists. octree takes account particles distribution change during simulation. effective depth of tree cannot rely on number of particles.
one spurious solution define bound on tree depth (or on number of nodes). in such case group more particles in single cell (the leaves of octree) , fall body-body interaction. if want more control on tree structure, maybe better have ability allocate new nodes when necessary.
Comments
Post a Comment