public void updateForce(Body _body) { if (isExternal(this)) { if (body != _body) { _body.addForce(body); } } else if (quad.getLength() / (body.calcDistance(_body)) < 2) { _body.addForce(body); } else { if (NorthWest != null) { NorthWest.updateForce(_body); } if (NorthEast != null) { NorthEast.updateForce(_body); } if (SouthWest != null) { SouthWest.updateForce(_body); } if (SouthEast != null) { SouthEast.updateForce(_body); } } }
public void addForce(int start, int end) { for (int i = start; i < end; i++) { if (bodies[i].isIn(quad)) { lock (tree) { tree.insert(bodies[i]); } } } for (int i = start; i < end; i++) { bodies[i].resetForce(); if (bodies[i].isIn(quad)) { lock (tree) { tree.updateForce(bodies[i]); } bodies[i].Update(1e11); } } }
public void addForce(int N) { BHTree tree = new BHTree(quad); Parallel.For(0, N, i => { if (bodies[i].isIn(quad)) { tree.insert(bodies[i]); } }); Parallel.For(0, N, i => { bodies[i].resetForce(); if (bodies[i].isIn(quad)) { tree.updateForce(bodies[i]); bodies[i].Update(1e11); } }); }
public void addForce(int N) { BHTree tree = new BHTree(quad); for (int i = 0; i < N; i++) { if (bodies[i].isIn(quad)) { tree.insert(bodies[i]); } } for (int i = 0; i < N; i++) { bodies[i].resetForce(); if (bodies[i].isIn(quad)) { tree.updateForce(bodies[i]); bodies[i].Update(1e11); } } }