From 7bd01fecd775b5e3e59acd22e771b725c3ab2673 Mon Sep 17 00:00:00 2001 From: Pierre Esterie Date: Mon, 1 Apr 2019 11:06:43 +0200 Subject: [PATCH] Cleaning GroupTaskAlgo and adding generic function to GroupTree, needed for test driver compatibility. --- Tests/GroupTree/testBlockedAlgorithmDyn.cpp | 2 +- Tests/GroupTree/testBlockedRotationCompare.cpp | 2 +- include/GroupTree/Core/FGroupOfParticles.hpp | 9 +++++++++ include/GroupTree/Core/FGroupTaskAlgorithm.hpp | 2 +- include/GroupTree/Core/FGroupTree.hpp | 12 ++++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Tests/GroupTree/testBlockedAlgorithmDyn.cpp b/Tests/GroupTree/testBlockedAlgorithmDyn.cpp index 30f54299..29780d87 100644 --- a/Tests/GroupTree/testBlockedAlgorithmDyn.cpp +++ b/Tests/GroupTree/testBlockedAlgorithmDyn.cpp @@ -138,7 +138,7 @@ int main(int argc, char* argv[]){ #else typedef FTestKernels< GroupCellClass, GroupContainerClass > GroupKernelClass; //typedef FGroupSeqAlgorithm GroupAlgorithm; - typedef FGroupTaskAlgorithm GroupAlgorithm; + typedef FGroupTaskAlgorithm GroupAlgorithm; #endif typedef FTestCell CellClass; diff --git a/Tests/GroupTree/testBlockedRotationCompare.cpp b/Tests/GroupTree/testBlockedRotationCompare.cpp index 0e4d1296..0f7cac2c 100644 --- a/Tests/GroupTree/testBlockedRotationCompare.cpp +++ b/Tests/GroupTree/testBlockedRotationCompare.cpp @@ -645,7 +645,7 @@ struct RunContainer{ { typedef FRotationKernel GroupKernelClass; //typedef FGroupSeqAlgorithm GroupAlgorithm; - typedef FGroupTaskAlgorithm GroupAlgorithm; + typedef FGroupTaskAlgorithm GroupAlgorithm; std::cout << "Using FGroupTaskAlgorithm" << std::endl; GroupKernelClass groupkernel(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); GroupAlgorithm groupalgo(&groupedTree,&groupkernel); diff --git a/include/GroupTree/Core/FGroupOfParticles.hpp b/include/GroupTree/Core/FGroupOfParticles.hpp index bf1a86d4..c452c3a1 100644 --- a/include/GroupTree/Core/FGroupOfParticles.hpp +++ b/include/GroupTree/Core/FGroupOfParticles.hpp @@ -358,6 +358,15 @@ public: blockHeader->attributeLeadingDim); } + template + void forEachLeaf(F&& function){ + using F_ = std::remove_reference_t; + for(int idxLeafPtr = 0 ; idxLeafPtr < blockHeader->numberOfLeavesInBlock ; ++idxLeafPtr){ + auto leaf = getLeaf(idxLeafPtr); + function(&leaf); + } + } + /** Extract methods */ diff --git a/include/GroupTree/Core/FGroupTaskAlgorithm.hpp b/include/GroupTree/Core/FGroupTaskAlgorithm.hpp index f922422d..555e0e1c 100644 --- a/include/GroupTree/Core/FGroupTaskAlgorithm.hpp +++ b/include/GroupTree/Core/FGroupTaskAlgorithm.hpp @@ -17,7 +17,7 @@ #include -template +template class FGroupTaskAlgorithm : public FAbstractAlgorithm { protected: template diff --git a/include/GroupTree/Core/FGroupTree.hpp b/include/GroupTree/Core/FGroupTree.hpp index 7b47be19..9eb0f6c9 100644 --- a/include/GroupTree/Core/FGroupTree.hpp +++ b/include/GroupTree/Core/FGroupTree.hpp @@ -962,6 +962,18 @@ public: block->forEachLeaf(function); } } + + /** + * @brief forEachLeaf iterate on the leaf and apply the generic function + * @param function + */ + template + void forEachLeaf(F&& function){ + for (ParticleGroupClass* block: _particleBlocks){ + block->forEachLeaf(function); + } + } + /** * @brief forEachMyLeaf iterate on the leaf and apply the function * @param function -- 2.22.0