Commit d707bd1a authored by berenger-bramas's avatar berenger-bramas

Add a loader generic method to load particles in the tree as:

loader.fillTree(tree);

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@361 2616d619-271b-44dc-8df4-d4a8f33a7222
parent e31aa0fb
......@@ -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;
......
......@@ -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);
}
}
};
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
//////////////////////////////////////////////////////////////////////////////////
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment