public static Cell makeCell () { Cell c = new Cell (); c.initNode (); c.subp = new Node[NSUB]; for (int i = 0; i < Cell.NSUB; ++i) c.subp [i] = null; return c; }
/** * Initialize the tree structure for hack force calculation. * * @param nsteps the current time step */ private void makeTree (int nstep) { Body q0 = this.bodyTabRev [0]; q0.expandBox (this, nstep); Body q1 = this.bodyTabRev [1]; q1.expandBox (this, nstep); MathVector xqicinit = intcoord (q1.pos); this.root = q0.loadTree (q1, xqicinit, Node.IMAX >> 1, this); for (int i = 2; i < this.bodyTabRev.Count; ++i) { Body q = this.bodyTabRev [i]; if (q.mass != 0.0) { q.expandBox (this, nstep); MathVector xqic = intcoord (q.pos); root = root.loadTree (q, xqic, Node.IMAX >> 1, this); } } root.hackcofm (); }
/** * Advance the N-body system one time-step. * * @param nstep the current time step */ public void stepSystem (int nstep) { // free the tree root = null; makeTree (nstep); // compute the gravity for all the particles for (int i = 0; i < this.bodyTabRev.Count; ++i) this.bodyTabRev [i].hackGravity (rsize, root); vp (bodyTabRev, nstep); }