Commit e038cbdb authored by COULAUD Olivier's avatar COULAUD Olivier

Use either ascii or binary loader

parent 8c752919
......@@ -24,8 +24,6 @@
#include <cstdlib>
#include "Files/FFmaGenericLoader.hpp"
//#include "../../Src/Files/FFmaBinLoader.hpp"
#include "../../Src/Kernels/Chebyshev/FChebCell.hpp"
#include "../../Src/Kernels/Interpolation/FInterpMatrixKernel.hpp"
......@@ -105,14 +103,13 @@ int main(int argc, char* argv[])
// open particle file
////////////////////////////////////////////////////////////////////
FFmaGenericLoader *loader = nullptr ;
bool binaryMode = false;
if(FParameters::existParameter(argc, argv, "-bin")){
loader = new FFmaGenericLoader(filename,true);
}
else {
loader = new FFmaGenericLoader(filename);
binaryMode = true;
}
if(!loader->isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
FFmaGenericLoader loader(filename,binaryMode);
if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
// begin Chebyshev kernel
......@@ -130,11 +127,11 @@ 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()
std::cout << "Creating & Inserting " << loader.getNumberOfParticles()
<< " particles ..." << std::endl;
std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl;
time.tic();
......@@ -142,9 +139,9 @@ int main(int argc, char* argv[])
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);
......@@ -160,7 +157,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);
//
......@@ -175,7 +172,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
......
......@@ -97,14 +97,13 @@ int main(int argc, char* argv[])
FTic time;
// open particle file
FFmaGenericLoader *loader = nullptr ;
bool binaryMode = false;
if(FParameters::existParameter(argc, argv, "-bin")){
loader = new FFmaGenericLoader(filename,true);
binaryMode = true;
}
else {
loader = new FFmaGenericLoader(filename);
}
if(!loader->isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
FFmaGenericLoader loader(filename,binaryMode);
if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ;
////////////////////////////////////////////////////////////////////
......@@ -124,11 +123,11 @@ 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()
std::cout << "Creating & Inserting " << loader.getNumberOfParticles()
<< " particles ..." << std::endl;
std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl;
time.tic();
......@@ -136,9 +135,9 @@ int main(int argc, char* argv[])
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);
......@@ -156,7 +155,7 @@ int main(int argc, char* argv[])
//
// Here we use a pointer due to the limited size of the stack
//
KernelClass *kernels = new KernelClass(TreeHeight, loader->getBoxWidth(), loader->getCenterOfBox());
KernelClass *kernels = new KernelClass(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
//
FmmClass algorithm(&tree, kernels);
//
......@@ -171,7 +170,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
......
......@@ -27,7 +27,7 @@
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Files/FFmaLoader.hpp"
#include "../../Src/Files/FFmaGenericLoader.hpp"
/// \file statisticsOnOctree.cpp
......@@ -54,6 +54,7 @@
//! \param -subdepth Specifies the size of the sub octree
//!
//! \param -infile name Name of the particles file. The file have to be in our FMA format
//! \param -bin if the input file in binary mode
//! \param -outfile name Generic name for output file (without extension)
//!
//! <b> Statistics options:</b>
......@@ -68,6 +69,7 @@ void usage() {
<< " -depth the depth of the octree "<< std::endl
<< " -subdepth specifies the size of the sub octree " << std::endl
<< " -infile name specifies the name of the particle distribution" << std::endl
<< " -bin if the input file in binary mode"<< std::endl
<< " -outfile name specifies the file for the diagnostics" << std::endl
<< " -histP build the histogram of the particle number per leaf"<<std::endl;
}
......@@ -98,7 +100,11 @@ int main(int argc, char ** argv){
//
std::cout << "Opening : " << filename << "\n";
FFmaLoader loader(filename);
bool binaryMode = false;
if(FParameters::existParameter(argc, argv, "-bin")){
binaryMode = true;
}
FFmaGenericLoader loader(filename,binaryMode);
if(!loader.isOpen()){
std::cout << "Loader Error, " << filename << " is missing\n";
return 1;
......
This diff is collapsed.
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