4 using double4 = Point4D;
5 using double2 = Point2D;
6 using int2 = std::pair<int, int>;
25 const int nnodes = 2 * (int)
object.size() - 1;
26 const int nbodies = (int)
object.size();
27#pragma omp for schedule(dynamic,5)
28 for (
int k = nbodies; k < nnodes; ++k)
48 int srt = indexSort[(nnodes - 1) - k];
49 int2 chdPair = child[srt];
51 for (i = 0; i < 2; i++) {
52 int chd = i * chdPair.second + (1 - i) * chdPair.first;
54 ch = (chd >= nbodies) ? (chd - nbodies) : ((nnodes - 1) - indexSortT[chd]);
56 if ((chd >= nbodies) || (mass[nnodes - 1 - ch] >= 0))
67 for (i = 0; i < 2; i++)
69 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
73 const int sortedBody = mortonCodesIdx[ch];
75 double4 xyAB = gabForLeaves[sortedBody];
77 ::fmin(xyAB[0], xyAB[2]), ::fmin(xyAB[1], xyAB[3]),
78 ::fmax(xyAB[0], xyAB[2]), ::fmax(xyAB[1], xyAB[3])
85 lu[i] = lowerupper[chd];
90 lowerupper[srt] = double4{
91 ::fmin(lu[0][0], lu[1][0]), ::fmin(lu[0][1], lu[1][1]),
92 ::fmax(lu[0][2], lu[1][2]), ::fmax(lu[0][3], lu[1][3])
95 cen = center[srt] = double2{ 0.5 * (lowerupper[srt][0] + lowerupper[srt][2]),
96 0.5 * (lowerupper[srt][1] + lowerupper[srt][3]) };
98 const double2 zero = { 0.0, 0.0 };
100 double2 momh1 = zero;
101 double2 momh2 = zero;
102 double2 momh3 = zero;
104 for (i = 0; i < 2; i++)
106 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
110 const int sortedBody = mortonCodesIdx[ch];
114 mom0 = double2{ gamma[sortedBody], 0.0 };
116mom1 = mom2 = mom3 = double2{ 0.0, 0.0 };
117 double2 pos =
object[sortedBody];
130 const int srtT = indexSortT[chd];
131 ch = (nnodes - 1) - srtT;
135 mom0 = double2{ moms[nch + 0][0], (double)0 };
136 mom1 = moms[nch + 1];
137 mom2 = moms[nch + 2];
138 mom3 = moms[nch + 3];
139 dr = center[chd] - cen;
151 momh1 += multz(mom0, z);
152 momh2 += 2 * multz(mom1, z);
153 momh3 += 3 * multz(mom2, z);
157 momh2 += multz(mom0, z);
158 momh3 += 3 * multz(mom1, z);
162 momh3 += multz(mom0, z);
167 moms[kch + 0] = momh0;
168 moms[kch + 1] = momh1;
169 moms[kch + 2] = momh2;
170 moms[kch + 3] = momh3;
178 mass[nnodes - 1 - k] = cm;