51 #ifndef vtkm_worklet_cosmotools_cosmotools_halofinder_h
52 #define vtkm_worklet_cosmotools_cosmotools_halofinder_h
71 template <
typename T,
typename StorageType>
77 using CompositeLocationType =
79 CompositeLocationType location;
89 leftNeighbor.
Allocate(NUM_NEIGHBORS * nParticles);
90 rightNeighbor.
Allocate(NUM_NEIGHBORS * nParticles);
96 BinParticlesAll(partId, binId, leftNeighbor, rightNeighbor);
102 markActiveNeighbors);
103 markActiveNeighborsDispatcher.Invoke(
116 DeviceAlgorithm::Copy(indexArray, haloIdCurrent);
117 DeviceAlgorithm::Copy(indexArray, haloIdLast);
126 GraftParticles<T> graftParticles(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, linkLen);
129 graftParticlesDispatcher.Invoke(indexArray,
139 DebugPrint(
"haloIdCurrent", haloIdCurrent);
143 DeviceAlgorithm::Copy(trueArray, rootedStar);
149 isStarDispatcher.Invoke(indexArray,
155 bool allStars = DeviceAlgorithm::Reduce(rootedStar,
true,
vtkm::LogicalAnd());
165 pointerJumpDispatcher.Invoke(indexArray, haloIdCurrent);
166 DeviceAlgorithm::Copy(haloIdCurrent, haloIdLast);
172 DeviceAlgorithm::Copy(indexArray, partId);
174 DebugPrint(
"FINAL haloId", haloIdCurrent);
175 DebugPrint(
"FINAL partId", partId);
179 DeviceAlgorithm::Copy(haloIdCurrent, resultHaloId);
180 MBPCenterFindingByHalo(partId, resultHaloId, resultMBP, resultPot);
188 template <
typename T,
typename StorageType>
216 numBinsX = std::min(maxBins, numBinsX);
217 numBinsY = std::min(maxBins, numBinsY);
218 numBinsZ = std::min(maxBins, numBinsZ);
220 numBinsX = std::max(minBins, numBinsX);
221 numBinsY = std::max(minBins, numBinsY);
222 numBinsZ = std::max(minBins, numBinsZ);
235 computeBinsDispatcher.Invoke(xLoc,
241 DeviceAlgorithm::Copy(indexArray, partId);
244 std::cout << std::endl
245 <<
"** BinParticlesAll (" << numBinsX <<
", " << numBinsY <<
", " << numBinsZ <<
")"
247 DebugPrint(
"xLoc", xLoc);
248 DebugPrint(
"yLoc", yLoc);
249 DebugPrint(
"zLoc", zLoc);
250 DebugPrint(
"partId", partId);
251 DebugPrint(
"binId", binId);
252 std::cout << std::endl;
256 DeviceAlgorithm::SortByKey(binId, partId);
258 DebugPrint(
"partId", partId);
259 DebugPrint(
"binId", binId);
266 computeNeighborBins);
267 computeNeighborBinsDispatcher.Invoke(countArray, binId, leftNeighbor);
272 computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
275 DeviceAlgorithm::LowerBounds(binId, leftNeighbor, leftNeighbor);
276 DeviceAlgorithm::UpperBounds(binId, rightNeighbor, rightNeighbor);
286 template <
typename T,
typename StorageType>
293 DeviceAlgorithm::SortByKey(haloId, partId);
295 DebugPrint(
"Sorted haloId", haloId);
296 DebugPrint(
"Sorted partId", partId);
312 DeviceAlgorithm::ReduceByKey(haloId, constArray, uniqueHaloIds, particlesPerHalo,
vtkm::Add());
314 DebugPrint(
"uniqueHaloId", uniqueHaloIds);
315 DebugPrint(
"partPerHalo", particlesPerHalo);
316 std::cout << std::endl;
324 DeviceAlgorithm::ScanExclusive(particlesPerHalo, tempI);
328 DeviceAlgorithm::ScanInclusive(particlesPerHalo, tempI);
333 vtkm::cont::make_ArrayHandleTransform<IdArrayType>(maxParticle,
336 DeviceAlgorithm::Copy(scaleBias, maxParticle);
338 DebugPrint(
"minParticle", minParticle);
339 DebugPrint(
"maxParticle", maxParticle);
347 computePotentialDispatcher.Invoke(indexArray,
357 DeviceAlgorithm::ReduceByKey(haloId, potential, uniqueHaloIds, tempT,
vtkm::Minimum());
360 DebugPrint(
"potential", potential);
361 DebugPrint(
"minPotential", minPotential);
367 equalsMinimumPotential);
369 equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, mbpId);
374 DeviceAlgorithm::ReduceByKey(haloId, mbpId, uniqueHaloIds, minIndx,
vtkm::Maximum());
379 DeviceAlgorithm::Copy(partId, savePartId);
381 DeviceAlgorithm::SortByKey(partId, haloId);
382 DeviceAlgorithm::Copy(savePartId, partId);
383 DeviceAlgorithm::SortByKey(partId, mbpId);
384 DeviceAlgorithm::Copy(savePartId, partId);
385 DeviceAlgorithm::SortByKey(partId, minPotential);
388 std::cout << std::endl;
389 DebugPrint(
"partId", partId);
390 DebugPrint(
"xLoc", xLoc);
391 DebugPrint(
"yLoc", yLoc);
392 DebugPrint(
"haloId", haloId);
393 DebugPrint(
"mbpId", mbpId);
394 DebugPrint(
"minPotential", minPotential);