51 #ifndef vtkm_worklet_cosmotools_cosmotools_centerfinder_h
52 #define vtkm_worklet_cosmotools_cosmotools_centerfinder_h
72 template <
typename T,
typename StorageType>
87 BinParticlesHalo(partId, binId, uniqueBins, partPerBin, particleOffset, binX, binY, binZ);
89 DebugPrint(
"uniqueBins", uniqueBins);
90 DebugPrint(
"partPerBin", partPerBin);
95 MBPCenterFindingByKey(binId, partId, partPotential);
100 DeviceAlgorithm::ReduceByKey(binId, partPotential, tempId, minPotential,
vtkm::Minimum());
104 DeviceAlgorithm::ReduceByKey(binId, partPotential, tempId, maxPotential,
vtkm::Maximum());
106 DebugPrint(
"minPotential", minPotential);
107 DebugPrint(
"maxPotential", maxPotential);
117 DeviceAlgorithm::Copy(minPotential, bestEstPotential);
118 DeviceAlgorithm::Copy(maxPotential, worstEstPotential);
123 computePotentialBin);
125 computePotentialBinDispatcher.Invoke(uniqueIndex,
133 DebugPrint(
"bestEstPotential", bestEstPotential);
134 DebugPrint(
"worstEstPotential", worstEstPotential);
135 std::cout <<
"Number of bestEstPotential " << bestEstPotential.
GetNumberOfValues() << std::endl;
136 std::cout <<
"Number of worstEstPotential " << worstEstPotential.
GetNumberOfValues() << std::endl;
141 DeviceAlgorithm::Copy(bestEstPotential, tempBest);
142 DeviceAlgorithm::SortByKey(tempBest, worstEstPotential);
155 setCandidateParticles);
156 setCandidateParticlesDispatcher.Invoke(bestEstPotential,
163 DeviceAlgorithm::CopyIf(partId, candidate, mparticles);
169 computePotentialOnCandidatesDispatcher(computePotentialOnCandidates);
171 computePotentialOnCandidatesDispatcher.Invoke(mparticles,
178 DeviceAlgorithm::SortByKey(mpotential, mparticles);
180 DebugPrint(
"mparticles", mparticles);
181 DebugPrint(
"mpotential", mpotential);
196 template <
typename T,
typename StorageType>
225 numBinsX = std::min(maxBins, numBinsX);
226 numBinsY = std::min(maxBins, numBinsY);
227 numBinsZ = std::min(maxBins, numBinsZ);
230 numBinsX = std::max(minBins, numBinsX);
231 numBinsY = std::max(minBins, numBinsY);
232 numBinsZ = std::max(minBins, numBinsZ);
235 std::cout << std::endl
236 <<
"** BinParticlesHalo (" << numBinsX <<
", " << numBinsY <<
", " << numBinsZ <<
") ("
237 << minX <<
", " << minY <<
", " << minZ <<
") (" << maxX <<
", " << maxY <<
", " << maxZ
252 computeBinsDispatcher.Invoke(xLoc,
258 DeviceAlgorithm::Copy(indexArray, partId);
261 DebugPrint(
"xLoc", xLoc);
262 DebugPrint(
"yLoc", yLoc);
263 DebugPrint(
"zLoc", zLoc);
264 DebugPrint(
"partId", partId);
265 DebugPrint(
"binId", binId);
269 DeviceAlgorithm::SortByKey(binId, partId);
273 DeviceAlgorithm::ReduceByKey(binId, constArray, uniqueBins, partPerBin,
vtkm::Add());
275 DebugPrint(
"sorted binId", binId);
276 DebugPrint(
"sorted partId", partId);
277 DebugPrint(
"uniqueBins", uniqueBins);
278 DebugPrint(
"partPerBin", partPerBin);
286 computeBinIndicesDispatcher.Invoke(uniqueBins,
291 DeviceAlgorithm::ScanExclusive(partPerBin, particleOffset);
302 template <
typename T,
typename StorageType>
317 leftNeighbor.
Allocate(NUM_NEIGHBORS * nParticles);
318 rightNeighbor.
Allocate(NUM_NEIGHBORS * nParticles);
323 computeNeighborBins);
324 computeNeighborBinsDispatcher.Invoke(countArray, keyId, leftNeighbor);
329 computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
332 DeviceAlgorithm::LowerBounds(keyId, leftNeighbor, leftNeighbor);
333 DeviceAlgorithm::UpperBounds(keyId, rightNeighbor, rightNeighbor);
335 DebugPrint(
"leftNeighbor", leftNeighbor);
336 DebugPrint(
"rightNeighbor", rightNeighbor);
342 numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, particleMass);
344 computePotentialNeighborsDispatcher(computePotentialNeighbors);
346 computePotentialNeighborsDispatcher.Invoke(indexArray,
357 DeviceAlgorithm::ScanInclusiveByKey(keyId, potential, minPotential,
vtkm::Minimum());
358 DeviceAlgorithm::ScanInclusiveByKey(keyReverse, minPotReverse, minPotReverse,
vtkm::Minimum());
360 DebugPrint(
"potential", potential);
361 DebugPrint(
"minPotential", minPotential);
368 equalsMinimumPotential);
370 equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, centerId);
380 template <
typename T,
typename StorageType>
393 computePotentialHalo);
395 computePotentialHaloDispatcher.Invoke(particleIndex,
402 DeviceAlgorithm::ScanInclusive(potential, minPotential,
vtkm::Minimum());
403 DeviceAlgorithm::ScanInclusive(minPotReverse, minPotReverse,
vtkm::Minimum());
409 equalsMinimumPotential);
411 equalsMinimumPotentialDispatcher.Invoke(particleIndex, potential, minPotential, centerId);
415 DeviceAlgorithm::ScanInclusive(centerId, centerId,
vtkm::Maximum());
416 DeviceAlgorithm::ScanInclusive(centerIdReverse, centerIdReverse,
vtkm::Maximum());