4 using double4 = Point4D;
5 using double2 = Point2D;
6 using int2 = std::pair<int, int>;
26 const int nnodes = 2 * (int)
object.size() - 1;
27 const int nbodies = (int)
object.size();
28#pragma omp for schedule(dynamic,5)
29 for (
int k = nbodies; k < nnodes; ++k)
49 int srt = indexSort[(nnodes - 1) - k];
50 int2 chdPair = child[srt];
52 for (i = 0; i < 2; i++) {
53 int chd = i * chdPair.second + (1 - i) * chdPair.first;
55 ch = (chd >= nbodies) ? (chd - nbodies) : ((nnodes - 1) - indexSortT[chd]);
57 if ((chd >= nbodies) || (mass[nnodes - 1 - ch] >= 0))
68 for (i = 0; i < 2; i++)
70 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
74 const int sortedBody = mortonCodesIdx[ch];
76 double4 xyAB = gabForLeaves[sortedBody];
78 ::fmin(xyAB[0], xyAB[2]), ::fmin(xyAB[1], xyAB[3]),
79 ::fmax(xyAB[0], xyAB[2]), ::fmax(xyAB[1], xyAB[3])
86 lu[i] = lowerupper[chd];
91 lowerupper[srt] = double4{
92 ::fmin(lu[0][0], lu[1][0]), ::fmin(lu[0][1], lu[1][1]),
93 ::fmax(lu[0][2], lu[1][2]), ::fmax(lu[0][3], lu[1][3])
96 cen = center[srt] = double2{ 0.5 * (lowerupper[srt][0] + lowerupper[srt][2]),
97 0.5 * (lowerupper[srt][1] + lowerupper[srt][3]) };
99 const double2 zero = { 0.0, 0.0 };
100 double2 momh0 = zero;
101 double2 momh1 = zero;
102 double2 momh2 = zero;
103 double2 momh3 = zero;
104 double2 momh4 = zero;
106 for (i = 0; i < 2; i++)
108 const int chd = i * chdPair.second + (1 - i) * chdPair.first;
112 const int sortedBody = mortonCodesIdx[ch];
116 mom0 = double2{ gamma[sortedBody], 0.0 };
118mom1 = mom2 = mom3 = mom4 = double2{ 0.0, 0.0 };
119 double2 pos =
object[sortedBody];
132 const int srtT = indexSortT[chd];
133 ch = (nnodes - 1) - srtT;
137 mom0 = double2{ moms[nch + 0][0], (double)0 };
138 mom1 = moms[nch + 1];
139 mom2 = moms[nch + 2];
140 mom3 = moms[nch + 3];
141 mom4 = moms[nch + 4];
142 dr = center[chd] - cen;
155 momh1 += multz(mom0, z);
156 momh2 += 2 * multz(mom1, z);
157 momh3 += 3 * multz(mom2, z);
158 momh4 += 4 * multz(mom3, z);
162 momh2 += multz(mom0, z);
163 momh3 += 3 * multz(mom1, z);
164 momh4 += 6 * multz(mom2, z);
168 momh3 += multz(mom0, z);
169 momh4 += 4 * multz(mom1, z);
173 momh4 += multz(mom0, z);
178 moms[kch + 0] = momh0;
179 moms[kch + 1] = momh1;
180 moms[kch + 2] = momh2;
181 moms[kch + 3] = momh3;
182 moms[kch + 4] = momh4;
190 mass[nnodes - 1 - k] = cm;