diff --git a/Src/Containers/FOctree.hpp b/Src/Containers/FOctree.hpp index c9c97b22357e5e673ad604cbd368774aa26c68ea..b6ed50f97d1f4a518fc9075917dade730028a114 100644 --- a/Src/Containers/FOctree.hpp +++ b/Src/Containers/FOctree.hpp @@ -116,18 +116,6 @@ public: } } - /** Use a loader to be filled - * @param the loader to fill the current tree - */ - template <class LoaderClass> - void fillWithLoader(LoaderClass& loader){ - ParticleClass particleToFill; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particleToFill); - insert(particleToFill); - } - } - /** Desctructor */ virtual ~FOctree() { delete [] boxWidthAtLevel; diff --git a/Src/Files/FAbstractLoader.hpp b/Src/Files/FAbstractLoader.hpp index 6b86497897410bede5cac01486531f1d4a27963e..b7204ebd04fecde27d44c4a4103a1360fb0912d6 100644 --- a/Src/Files/FAbstractLoader.hpp +++ b/Src/Files/FAbstractLoader.hpp @@ -33,39 +33,51 @@ class F3DPosition; template <class ParticleClass> class FAbstractLoader { public: - /** Default destructor */ - virtual ~FAbstractLoader(){ - } + /** Default destructor */ + virtual ~FAbstractLoader(){ + } - /** + /** * Get the number of particles for this simulation * @return number of particles that the loader can fill */ - virtual FSize getNumberOfParticles() const = 0; + virtual FSize getNumberOfParticles() const = 0; - /** + /** * Get the center of the simulation box * @return box center needed by the octree */ - virtual F3DPosition getCenterOfBox() const = 0; + virtual F3DPosition getCenterOfBox() const = 0; - /** + /** * Get the simulation box width * @return box width needed by the octree */ - virtual FReal getBoxWidth() const = 0; + virtual FReal getBoxWidth() const = 0; - /** + /** * To know if the loader is valide (file opened, etc.) * @return true if file is open */ - virtual bool isOpen() const = 0; + virtual bool isOpen() const = 0; - /** + /** * Fill the next particle * @param inParticle the particle to fill */ - virtual void fillParticle(ParticleClass& inParticle) = 0; + virtual void fillParticle(ParticleClass& inParticle) = 0; + + /** Fill a tree with all the particle of the current loader + * @param tree the tree to fill + */ + template <class OctreeClass> + void fillTree(OctreeClass& tree){ + ParticleClass particleToFill; + for(int idxPart = 0 ; idxPart < getNumberOfParticles() ; ++idxPart){ + fillParticle(particleToFill); + tree.insert(particleToFill); + } + } }; diff --git a/Tests/testFmbAlgorithm.cpp b/Tests/testFmbAlgorithm.cpp index c681a57c9f2f46902701fc00cc5e6bcc588dcfc3..c37b48fc74baf1b48f802318dbcaa979deaffe98 100644 --- a/Tests/testFmbAlgorithm.cpp +++ b/Tests/testFmbAlgorithm.cpp @@ -76,13 +76,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - { - ParticleClass particleToFill; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particleToFill); - tree.insert(particleToFill); - } - } + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testFmbBlasAlgorithm.cpp b/Tests/testFmbBlasAlgorithm.cpp index 793b16f72408f9f91a31937d945883ba0f75611c..15c1c10968217fc340e2754ae07079d222090835 100644 --- a/Tests/testFmbBlasAlgorithm.cpp +++ b/Tests/testFmbBlasAlgorithm.cpp @@ -77,13 +77,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - { - ParticleClass particleToFill; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particleToFill); - tree.insert(particleToFill); - } - } + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testFmbTsmAlgorithm.cpp b/Tests/testFmbTsmAlgorithm.cpp index 4cba5ca4a9ccac98079aa84416c83ef175f1731c..b57f9e1969970a45ac0cc1c1170a0bafbc89eaa0 100644 --- a/Tests/testFmbTsmAlgorithm.cpp +++ b/Tests/testFmbTsmAlgorithm.cpp @@ -75,13 +75,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - { - ParticleClass particleToFill; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particleToFill); - tree.insert(particleToFill); - } - } + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testFmmAlgorithm.cpp b/Tests/testFmmAlgorithm.cpp index 84ea8dea5f2d0df0f3ee7cb8b6f4fe3c0dbd7e23..87e9dab91b121900f2110541f4c030709c2978ba 100644 --- a/Tests/testFmmAlgorithm.cpp +++ b/Tests/testFmmAlgorithm.cpp @@ -75,7 +75,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - tree.fillWithLoader(loader); + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testFmmAlgorithmProc.cpp b/Tests/testFmmAlgorithmProc.cpp index 90472cd0f0b9fcb9d514dd2b33d1965dc3cc13b4..34ba9fa178bb7d1a42495d50c24ea16c6b4ebfcc 100644 --- a/Tests/testFmmAlgorithmProc.cpp +++ b/Tests/testFmmAlgorithmProc.cpp @@ -362,7 +362,7 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// } else{ - realTree.fillWithLoader(loader); + loader.fillTree(realTree); } ////////////////////////////////////////////////////////////////////////////////// @@ -372,7 +372,7 @@ int main(int argc, char ** argv){ OctreeClass treeValide(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); { FFmaBinLoader<ParticleClass> loaderSeq(filename); - treeValide.fillWithLoader(loaderSeq); + loaderSeq.fillTree(treeValide); } ////////////////////////////////////////////////////////////////////////////////// diff --git a/Tests/testFmmAlgorithmTsm.cpp b/Tests/testFmmAlgorithmTsm.cpp index ab4baccb73491ece4577718ba9bb1c778a405acc..16016cac68bbaa3a664c48e9fee02b79b505a617 100644 --- a/Tests/testFmmAlgorithmTsm.cpp +++ b/Tests/testFmmAlgorithmTsm.cpp @@ -82,7 +82,7 @@ int main(int argc, char ** argv){ std::cout << "Creating " << NbPart << " particles ..." << std::endl; counter.tic(); - tree.fillWithLoader(loader); + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testLoaderFMA.cpp b/Tests/testLoaderFMA.cpp index d02f7b5782465f5b76549a1813d1867aa7da4b2d..6fd2c1d08cbfdeaff4186b0974934c32cda25b88 100644 --- a/Tests/testLoaderFMA.cpp +++ b/Tests/testLoaderFMA.cpp @@ -74,11 +74,8 @@ int main(int argc, char ** argv ){ std::cout << "Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl; counter.tic(); - FFmaParticle part; - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ - loader.fillParticle(part); - tree.insert(part); - } + loader.fillTree(tree); + counter.tac(); std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl; diff --git a/Tests/testLoaderFMATsm.cpp b/Tests/testLoaderFMATsm.cpp index 599ee4186f75ab08271b1c1752f6d3862a1d1e55..8178e74bb480f857d267e77ba0fb37290235e9c0 100644 --- a/Tests/testLoaderFMATsm.cpp +++ b/Tests/testLoaderFMATsm.cpp @@ -74,11 +74,8 @@ int main(int argc, char ** argv ){ std::cout << "Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl; counter.tic(); - ParticleTsm part; - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ - loader.fillParticle(part); - tree.insert(part); - } + loader.fillTree(tree); + counter.tac(); std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl; diff --git a/Tests/testOctree.cpp b/Tests/testOctree.cpp index 139c093e60cf00e85bae8144c045faf407e12b83..ff56973235c1c378a1053093cff80bacce68e5e2 100644 --- a/Tests/testOctree.cpp +++ b/Tests/testOctree.cpp @@ -52,7 +52,7 @@ int main(int , char ** ){ std::cout << "Creating and inserting " << NbPart << " particles ..." << std::endl; counter.tic(); - tree.fillWithLoader(loader); + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl; diff --git a/Tests/testStatsTree.cpp b/Tests/testStatsTree.cpp index bb199b8b3038ad6269493baa231554830dfea1ce..82a4d0a9342454cc0292037d60aa5caee4357480 100644 --- a/Tests/testStatsTree.cpp +++ b/Tests/testStatsTree.cpp @@ -79,11 +79,7 @@ int main(int argc, char ** argv){ counter.tic(); - FFmaParticle particle; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particle); - tree.insert(particle); - } + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; diff --git a/Tests/testTreeIO.cpp b/Tests/testTreeIO.cpp index 5303f5c79fb5c9266cc65d54ed779018c6dfcba8..d313d3eefd895e24a01433c1227e2cc578dff729 100644 --- a/Tests/testTreeIO.cpp +++ b/Tests/testTreeIO.cpp @@ -63,13 +63,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - { - ParticleClass particleToFill; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(particleToFill); - tree.insert(particleToFill); - } - } + loader.fillTree(tree); counter.tac(); std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;