local void gravsum(bodyptr p0, cellptr cptr, cellptr bptr) { vector pos0, acc0; real phi0; SETV(pos0, Pos(p0)); // copy position of body phi0 = 0.0; // init total potential CLRV(acc0); // and total acceleration if (usequad) // if using quad moments sumcell(interact, cptr, pos0, &phi0, acc0); // sum cell forces w quads else // not using quad moments sumnode(interact, cptr, pos0, &phi0, acc0); // sum cell forces wo quads sumnode(bptr, interact + actmax, pos0, &phi0, acc0); // sum forces from bodies Phi(p0) = phi0; // store total potential SETV(Acc(p0), acc0); // and total acceleration nfcalc++; // update counters nbbcalc += interact + actmax - bptr; nbccalc += cptr - interact; }
local void gravsum(bodyptr p0, cellptr cptr, cellptr bptr) { vector pos0, acc0; real phi0; SETV(pos0, Pos(p0)); /* copy position of body */ phi0 = 0.0; /* init total potential */ CLRV(acc0); /* and total acceleration */ if (usequad) /* if using quad moments */ sumcell(interact, cptr, pos0, &phi0, acc0); /* sum cell forces w quads */ else /* not using quad moments */ sumnode(interact, cptr, pos0, &phi0, acc0); /* sum cell forces wo quads */ sumnode(bptr, interact + actlen, pos0, &phi0, acc0); /* sum forces from bodies */ Phi(p0) = phi0; /* store total potential */ SETV(Acc(p0), acc0); /* and total acceleration */ nfcalc++; /* update counters */ nbbcalc += interact + actlen - bptr; nbccalc += cptr - interact; }