4 using double4 = Point4D;
5 using double2 = Point2D;
6 using int2 = std::pair<int, int>;
27 const int nnodes = 2 * (int)
object.size() - 1;
28 const int nbodies = (int)
object.size();
29#pragma omp for schedule(dynamic,5)
30 for (
int k = nbodies; k < nnodes; ++k)
50 int srt = indexSort[(nnodes - 1) - k];
51 int2 chdPair = child[srt];
53 for (i = 0; i < 2; i++) {
54 int chd = i * chdPair.second + (1 - i) * chdPair.first;
56 ch = (chd >= nbodies) ? (chd - nbodies) : ((nnodes - 1) - indexSortT[chd]);
58 if ((chd >= nbodies) || (mass[nnodes - 1 - ch] >= 0))
69 for (i = 0; i < 2; i++)
71 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
75 const int sortedBody = mortonCodesIdx[ch];
77 double4 xyAB = gabForLeaves[sortedBody];
79 ::fmin(xyAB[0], xyAB[2]), ::fmin(xyAB[1], xyAB[3]),
80 ::fmax(xyAB[0], xyAB[2]), ::fmax(xyAB[1], xyAB[3])
87 lu[i] = lowerupper[chd];
92 lowerupper[srt] = double4{
93 ::fmin(lu[0][0], lu[1][0]), ::fmin(lu[0][1], lu[1][1]),
94 ::fmax(lu[0][2], lu[1][2]), ::fmax(lu[0][3], lu[1][3])
97 cen = center[srt] = double2{ 0.5 * (lowerupper[srt][0] + lowerupper[srt][2]),
98 0.5 * (lowerupper[srt][1] + lowerupper[srt][3]) };
100 const double2 zero = { 0.0, 0.0 };
101 double2 momh0 = zero;
102 double2 momh1 = zero;
103 double2 momh2 = zero;
104 double2 momh3 = zero;
105 double2 momh4 = zero;
106 double2 momh5 = zero;
108 for (i = 0; i < 2; i++)
110 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
114 const int sortedBody = mortonCodesIdx[ch];
118 mom0 = double2{ gamma[sortedBody], 0.0 };
120mom1 = mom2 = mom3 = mom4 = mom5 = double2{ 0.0, 0.0 };
121 double2 pos =
object[sortedBody];
134 const int srtT = indexSortT[chd];
135 ch = (nnodes - 1) - srtT;
139 mom0 = double2{ moms[nch + 0][0], (double)0 };
140 mom1 = moms[nch + 1];
141 mom2 = moms[nch + 2];
142 mom3 = moms[nch + 3];
143 mom4 = moms[nch + 4];
144 mom5 = moms[nch + 5];
145 dr = center[chd] - cen;
159 momh1 += multz(mom0, z);
160 momh2 += 2 * multz(mom1, z);
161 momh3 += 3 * multz(mom2, z);
162 momh4 += 4 * multz(mom3, z);
163 momh5 += 5 * multz(mom4, z);
167 momh2 += multz(mom0, z);
168 momh3 += 3 * multz(mom1, z);
169 momh4 += 6 * multz(mom2, z);
170 momh5 += 10 * multz(mom3, z);
174 momh3 += multz(mom0, z);
175 momh4 += 4 * multz(mom1, z);
176 momh5 += 10 * multz(mom2, z);
180 momh4 += multz(mom0, z);
181 momh5 += 5 * multz(mom1, z);
185 momh5 += multz(mom0, z);
190 moms[kch + 0] = momh0;
191 moms[kch + 1] = momh1;
192 moms[kch + 2] = momh2;
193 moms[kch + 3] = momh3;
194 moms[kch + 4] = momh4;
195 moms[kch + 5] = momh5;
203 mass[nnodes - 1 - k] = cm;