/** * Enlarge cubical "box", salvaging existing tree structure. * * @param tree the root of the tree. * @param nsteps the current time step */ public void expandBox(BTree tree, int nsteps) { MathVector rmid = MathVector.makeMathVector(); int k; bool inbox = icTest(tree); while (!inbox) { double rsize = tree.rsize; rmid.addScalar(tree.rmin, 0.5 * rsize); for (k = 0; k < MathVector.NDIM; k++) { if (pos.value(k) < rmid.value(k)) { double rmin = tree.rmin.value(k); tree.rmin.setValue(k, rmin - rsize); } } tree.rsize = 2.0 * rsize; if (tree.root != null) { MathVector ic = tree.intcoord(rmid); k = Node.oldSubindex(ic, Node.IMAX >> 1); Cell newt = Cell.makeCell(); newt.subp[k] = tree.root; tree.root = newt; inbox = icTest(tree); } } }
/** * Determine which subcell to select. * Combination of intcoord and oldSubindex. * * @param t the root of the tree */ public int subindex(BTree tree, int l) { MathVector xp = MathVector.makeMathVector(); double imxv = (double)Node.IMAX; double xsc = (pos.value(0) - tree.rmin.value(0)) / tree.rsize; xp.setValue(0, Math.Floor(imxv * xsc)); xsc = (pos.value(1) - tree.rmin.value(1)) / tree.rsize; xp.setValue(1, Math.Floor(imxv * xsc)); xsc = (pos.value(2) - tree.rmin.value(2)) / tree.rsize; xp.setValue(2, Math.Floor(imxv * xsc)); int i = 0; for (int k = 0; k < MathVector.NDIM; k++) { if (((int)xp.value(k) & l) != 0) //This used val & 1 != 0 so if there is a problem look here { i += Cell.NSUB >> (k + 1); } } return(i); }
public static int oldSubindex (MathVector ic, int l) { int i = 0; for (int k = 0; k < MathVector.NDIM; k++) { if (((int)ic.value (k) & l) != 0) i += Cell.NSUB >> (k + 1); } return i; }
public static int oldSubindex(MathVector ic, int l) { int i = 0; for (int k = 0; k < MathVector.NDIM; k++) { if (((int)ic.value(k) & l) != 0) { i += Cell.NSUB >> (k + 1); } } return(i); }
/** * Compute integerized coordinates. * * @return the coordinates or null if rp is out of bounds */ public MathVector intcoord(MathVector vp) { MathVector xp = MathVector.makeMathVector(); double imxv = (double)Node.IMAX; double xsc = (vp.value(0) - rmin.value(0)) / rsize; if (0.0 <= xsc && xsc < 1.0) { xp.setValue(0, Math.Floor(imxv * xsc)); } else { return(null); } xsc = (vp.value(1) - rmin.value(1)) / rsize; if (0.0 <= xsc && xsc < 1.0) { xp.setValue(1, Math.Floor(imxv * xsc)); } else { return(null); } xsc = (vp.value(2) - rmin.value(2)) / rsize; if (0.0 <= xsc && xsc < 1.0) { xp.setValue(2, Math.Floor(imxv * xsc)); } else { return(null); } return(xp); }
/** * Compute integerized coordinates. * * @return the coordinates or null if rp is out of bounds */ public MathVector intcoord (MathVector vp) { MathVector xp = MathVector.makeMathVector (); double imxv = (double)Node.IMAX; double xsc = (vp.value (0) - rmin.value (0)) / rsize; if (0.0 <= xsc && xsc < 1.0) xp.setValue (0, Math.Floor (imxv * xsc)); else return null; xsc = (vp.value (1) - rmin.value (1)) / rsize; if (0.0 <= xsc && xsc < 1.0) xp.setValue (1, Math.Floor (imxv * xsc)); else return null; xsc = (vp.value (2) - rmin.value (2)) / rsize; if (0.0 <= xsc && xsc < 1.0) xp.setValue (2, Math.Floor (imxv * xsc)); else return null; return xp; }