/** * Recursively walk the tree to do hackwalk calculation */ public override HG walkSubTree(double dsq, HG hg) { if (this != hg.pskip) { hg = gravSub(hg); } return(hg); }
/** * Decide if the cell is too close to accept as a single term. * * @return true if the cell is too close. */ public bool subdivp(double dsq, HG hg) { MathVector dr = MathVector.makeMathVector(); dr.subtraction2(pos, hg.pos0); double drsq = dr.dotProduct(); // in the original olden version drsp is multiplied by 1.0 return(drsq < dsq); }
/** * Evaluate gravitational field on the body. * The original olden version calls a routine named "walkscan", * but we use the same name that is in the Barnes code. */ public void hackGravity(double rsize, Node root) { MathVector pos0 = pos.cloneMathVector(); HG hg = HG.makeHG(this, pos); hg = root.walkSubTree(rsize * rsize, hg); phi = hg.phi0; newAcc = hg.acc0; }
/** * Compute a single body-body or body-cell interaction */ public HG gravSub (HG hg) { MathVector dr = MathVector.makeMathVector (); dr.subtraction2 (pos, hg.pos0); double drsq = dr.dotProduct () + (EPS * EPS); double drabs = Math.Sqrt (drsq); double phii = mass / drabs; hg.phi0 -= phii; double mor3 = phii / drsq; dr.multScalar1 (mor3); hg.acc0.addition (dr); return hg; }
/** * Compute a single body-body or body-cell interaction */ public HG gravSub(HG hg) { MathVector dr = MathVector.makeMathVector(); dr.subtraction2(pos, hg.pos0); double drsq = dr.dotProduct() + (EPS * EPS); double drabs = Math.Sqrt(drsq); double phii = mass / drabs; hg.phi0 -= phii; double mor3 = phii / drsq; dr.multScalar1(mor3); hg.acc0.addition(dr); return(hg); }
/** * Recursively walk the tree to do hackwalk calculation */ public override HG walkSubTree(double dsq, HG hg) { if (subdivp(dsq, hg)) { for (int k = 0; k < Cell.NSUB; k++) { Node r = this.subp [k]; if (r != null) { hg = r.walkSubTree(dsq / 4.0, hg); } } } else { hg = gravSub(hg); } return(hg); }
public abstract HG walkSubTree(double dsq, HG hg);
/** * Recursively walk the tree to do hackwalk calculation */ public override HG walkSubTree (double dsq, HG hg) { if (subdivp (dsq, hg)) { for (int k = 0; k < Cell.NSUB; k++) { Node r = this.subp [k]; if (r != null) hg = r.walkSubTree (dsq / 4.0, hg); } } else hg = gravSub (hg); return hg; }
/** * Decide if the cell is too close to accept as a single term. * * @return true if the cell is too close. */ public bool subdivp (double dsq, HG hg) { MathVector dr = MathVector.makeMathVector (); dr.subtraction2 (pos, hg.pos0); double drsq = dr.dotProduct (); // in the original olden version drsp is multiplied by 1.0 return (drsq < dsq); }
/** * Recursively walk the tree to do hackwalk calculation */ public override HG walkSubTree (double dsq, HG hg) { if (this != hg.pskip) hg = gravSub (hg); return hg; }
public abstract HG walkSubTree (double dsq, HG hg);