Commit 356dd59f authored by COULAUD Olivier's avatar COULAUD Olivier

Accept binary or ascii loader ../Examples/RotationFMM.cpp

parent 89436018
......@@ -23,7 +23,7 @@
#include <cstdio>
#include <cstdlib>
#include "../../Src/Files/FFmaScanfLoader.hpp"
#include "Files/FFmaGenericLoader.hpp"
//#include "../../Src/Files/FFmaBinLoader.hpp"
......@@ -58,6 +58,8 @@
//! \param -t The number of threads
//!
//! \param -f name Name of the particles file. The file have to be in our FMA format
//! \param -bin if the file is in binary mode
//!
//
......@@ -68,6 +70,7 @@ void usage() {
<< " -depth the depth of the octree "<< std::endl
<< " -subdepth specifies the size of the sub octree " << std::endl
<< " -f name name specifies the name of the particle distribution" << std::endl
<< " -bin if the file is in binary mode" << std::endl
<< " -t n specifies the number of threads used in the computations" << std::endl;
}
......@@ -88,23 +91,28 @@ int main(int argc, char* argv[])
#else
std::cout << "\n>> Sequential version.\n" << std::endl;
#endif
//
//
std::cout << "Parameters "<< std::endl
<< " Octree Depth "<< TreeHeight <<std::endl
<< " SubOctree depth " << SubTreeHeight <<std::endl
<< " Input file name: " <<filename <<std::endl
<< " Thread number: " << NbThreads <<std::endl
<<std::endl;
//
// init timer
FTic time;
//
// init timer
FTic time;
// open particle file
FFmaScanfLoader loader(filename);
if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
////////////////////////////////////////////////////////////////////
FFmaGenericLoader *loader = nullptr ;
if(FParameters::existParameter(argc, argv, "-bin")){
loader = new FFmaGenericLoader(filename,true);
}
else {
loader = new FFmaGenericLoader(filename);
}
if(!loader->isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
// begin Chebyshev kernel
......@@ -122,21 +130,21 @@ int main(int argc, char* argv[])
typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
// init oct-tree
OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
OctreeClass tree(TreeHeight, SubTreeHeight, loader->getBoxWidth(), loader->getCenterOfBox());
{ // -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles()
<< " particles ..." << std::endl;
std::cout << "Creating & Inserting " << loader->getNumberOfParticles()
<< " particles ..." << std::endl;
std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl;
time.tic();
//
FPoint position;
FReal physicalValue = 0.0;
//
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
for(int idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){
// Read particles from file
loader.fillParticle(&position,&physicalValue);
loader->fillParticle(&position,&physicalValue);
// put particles in octree
tree.insert(position, idxPart, physicalValue);
......@@ -152,7 +160,7 @@ int main(int argc, char* argv[])
time.tic();
//
KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
KernelClass kernels(TreeHeight, loader->getBoxWidth(), loader->getCenterOfBox());
//
FmmClass algorithm(&tree, &kernels);
//
......@@ -167,7 +175,7 @@ int main(int argc, char* argv[])
//
//
{ // -----------------------------------------------------
long int N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ;
long int N1=0, N2= loader->getNumberOfParticles()/2, N3= loader->getNumberOfParticles() -1; ;
FReal energy =0.0 ;
//
// Loop over all leaves
......
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