Commit 0184d873 authored by berenger-bramas's avatar berenger-bramas

Use FParemeter whenever it is possible.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@362 2616d619-271b-44dc-8df4-d4a8f33a7222
parent d707bd1a
......@@ -16,6 +16,7 @@
#include <time.h>
#include "../Src/Utils/FTic.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
......@@ -33,7 +34,7 @@
* In this file we show how to use octree
*/
int main(int , char ** ){
int main(int argc, char ** argv){
typedef FVector<FBasicParticle> ContainerClass;
typedef FSimpleLeaf<FBasicParticle, ContainerClass > LeafClass;
typedef FOctree<FBasicParticle, FBasicCell, ContainerClass , LeafClass > OctreeClass;
......@@ -42,7 +43,7 @@ int main(int , char ** ){
std::cout << ">> It is only interesting to wath the code to understand\n";
std::cout << ">> how to use the Octree\n";
//////////////////////////////////////////////////////////////
const long NbPart = 2000000;
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
FTic counter;
FRandomLoader<FBasicParticle> loader(NbPart, 1, F3DPosition(0.5,0.5,0.5), 1);
......
......@@ -16,6 +16,8 @@
#include <time.h>
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Components/FSimpleLeaf.hpp"
......@@ -33,7 +35,7 @@
* This is a good example to understand FOctree::Iterator.
*/
int main(int , char ** ){
int main(int argc, char ** argv){
typedef FVector<FBasicParticle> ContainerClass;
typedef FSimpleLeaf<FBasicParticle, ContainerClass > LeafClass;
typedef FOctree<FBasicParticle, FBasicCell, ContainerClass , LeafClass > OctreeClass;
......@@ -43,73 +45,73 @@ int main(int , char ** ){
std::cout << ">> how to use octree iterator.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = 9;
const int NbSubLevels = 3;
const long NbPart = 2E6;
const FReal FRandMax = FReal(RAND_MAX);
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int NbSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counterTime;
FTic counterTime;
srand ( 1 ); // volontary set seed to constant
// -----------------------------------------------------
srand ( 1 ); // volontary set seed to constant
// -----------------------------------------------------
OctreeClass tree(NbLevels, NbSubLevels, 1.0, F3DPosition(0.5,0.5,0.5));
OctreeClass tree(NbLevels, NbSubLevels, 1.0,F3DPosition(0.5,0.5,0.5));
// -----------------------------------------------------
std::cout << "Creating and inserting " << NbPart << " particles ..." << std::endl;
counterTime.tic();
{
FBasicParticle particle;
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particle.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
tree.insert(particle);
}
}
counterTime.tac();
std::cout << "Done " << "(" << counterTime.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Creating and inserting " << NbPart << " particles ..." << std::endl;
// -----------------------------------------------------
{
std::cout << "Itering on particles ..." << std::endl;
counterTime.tic();
{
FBasicParticle particle;
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particle.setPosition(FReal(rand())/FRandMax,FReal(rand())/FRandMax,FReal(rand())/FRandMax);
tree.insert(particle);
}
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = NbLevels - 1 ; idxLevel >= 1 ; --idxLevel ){
int counter = 0;
do{
++counter;
//counter += octreeIterator.getCurrentList()->getSize();
} while(octreeIterator.moveRight());
octreeIterator.moveUp();
octreeIterator.gotoLeft();
std::cout << "Cells at this level " << counter << " ...\n";
}
counterTime.tac();
std::cout << "Done " << "(" << counterTime.elapsed() << "s)." << std::endl;
}
// -----------------------------------------------------
{
std::cout << "Itering on particles fast ..." << std::endl;
counterTime.tic();
// -----------------------------------------------------
{
std::cout << "Itering on particles ..." << std::endl;
counterTime.tic();
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = NbLevels - 1 ; idxLevel >= 1 ; --idxLevel ){
int counter = 0;
do{
++counter;
//counter += octreeIterator.getCurrentList()->getSize();
} while(octreeIterator.moveRight());
octreeIterator.moveUp();
octreeIterator.gotoLeft();
std::cout << "Cells at this level " << counter << " ...\n";
}
counterTime.tac();
std::cout << "Done " << "(" << counterTime.elapsed() << "s)." << std::endl;
}
// -----------------------------------------------------
{
std::cout << "Itering on particles fast ..." << std::endl;
counterTime.tic();
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
OctreeClass::Iterator avoidGoLeft(octreeIterator);
for(int idx = 0 ; idx < NbLevels - 1; ++idx ){
do{
} while(octreeIterator.moveRight());
avoidGoLeft.moveUp();
octreeIterator = avoidGoLeft;
}
counterTime.tac();
std::cout << "Done " << "(" << counterTime.elapsed() << "s)." << std::endl;
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
OctreeClass::Iterator avoidGoLeft(octreeIterator);
for(int idx = 0 ; idx < NbLevels - 1; ++idx ){
do{
} while(octreeIterator.moveRight());
avoidGoLeft.moveUp();
octreeIterator = avoidGoLeft;
}
// -----------------------------------------------------
counterTime.tac();
std::cout << "Done " << "(" << counterTime.elapsed() << "s)." << std::endl;
}
// -----------------------------------------------------
return 0;
return 0;
}
......
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