Commit 15ffd99b authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Forgot to commit this one

parent ea5984ac
......@@ -24,52 +24,52 @@
#include "FAbstractLoader.hpp"
#include "../Utils/FPoint.hpp"
#include "../Utils/FMpi.hpp"
#include "../Utils/FLog.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FMpiFmaLoader
* Please read the license
*
* Load a file with a format like :
* NB_particles Box_width Box_X Box_Y Box_Z // init
* X Y Z // one particle by line
* ....
* @code
* FMpiFmaLoader<FBasicParticle> loader("../ADir/Tests/particles.basic.txt"); <br>
* if(!loader.isOpen()){ <br>
* std::cout << "Loader Error\n"; <br>
* return 1; <br>
* } <br>
* <br>
* FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br>
* <br>
* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br>
* FBasicParticle* const part = new FBasicParticle(); <br>
* loader.fillParticle(part); <br>
* tree.insert(part); <br>
* } <br>
* @endcode
*
* Particle has to extend {FExtendPhysicalValue,FExtendPosition}
*/
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FMpiFmaLoader
* Please read the license
*
* Load a file with a format like :
* NB_particles Box_width Box_X Box_Y Box_Z // init
* X Y Z // one particle by line
* ....
* @code
* FMpiFmaLoader<FBasicParticle> loader("../ADir/Tests/particles.basic.txt"); <br>
* if(!loader.isOpen()){ <br>
* std::cout << "Loader Error\n"; <br>
* return 1; <br>
* } <br>
* <br>
* FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br>
* <br>
* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br>
* FBasicParticle* const part = new FBasicParticle(); <br>
* loader.fillParticle(part); <br>
* tree.insert(part); <br>
* } <br>
* @endcode
*
* Particle has to extend {FExtendPhysicalValue,FExtendPosition}
*/
class FMpiFmaLoader : public FAbstractLoader {
protected:
FPoint centerOfBox; //< The center of box read from file
FReal boxWidth; //< the box width read from file
FSize totalNbParticles; //< the number of particles read from file
FSize nbParticles; //< the number of particles read from file
FSize nbParticles; //< the number of particles read from file for this proc
bool isOpenFlag; //< to knwo if the file is open now
FReal* particles; //< the particles loaded from the binary file
MPI_Offset idxParticles; //< to iterate on the particles array
int start;
public:
/**
* The constructor need the file name
* The constructor need txhe file name
* @param filename the name of the file to open
* you can test if file is successfuly open by calling hasNotFinished()
*/
FMpiFmaLoader(const char* const filename, const FMpi::FComm& comm, const bool useMpiIO = false)
: boxWidth(0), totalNbParticles(0), nbParticles(0), isOpenFlag(false), particles(0), idxParticles(0) {
: boxWidth(0), totalNbParticles(0), nbParticles(0), isOpenFlag(false), particles(0), idxParticles(0), start(0) {
if( useMpiIO ){
char nonConstFilename[512];
strcpy(nonConstFilename,filename);
......@@ -106,6 +106,7 @@ public:
const FSize startPart = comm.getLeft(this->totalNbParticles);
const FSize endPart = comm.getRight(this->totalNbParticles);
nbParticles = (endPart - startPart);
this->start = int(startPart);
const FSize bufsize = nbParticles * 4;
// local number to read
particles = new FReal[bufsize];
......@@ -160,6 +161,7 @@ public:
const FSize startPart = comm.getLeft(this->totalNbParticles);
const FSize endPart = comm.getRight(this->totalNbParticles);
nbParticles = (endPart - startPart);
this->start = int(startPart);
const FSize bufsize = nbParticles * 4;
// local number to read
particles = new FReal[bufsize];
......@@ -194,13 +196,21 @@ public:
}
/**
* To get the number of particles from this loader
* @param the number of particles the loader can fill
* To get the number of particles to be used by this proc from this loader
* @param the number of particles for this proc the loader can fill
*/
FSize getNumberOfParticles() const{
return this->nbParticles;
}
/**
* To get the number of particles to be used by this proc from this loader
* @param the number of particles for this proc the loader can fill
*/
FSize getTotalNumberOfParticles() const{
return this->totalNbParticles;
}
/**
* The center of the box from the simulation file opened by the loader
* @return box center
......@@ -217,6 +227,15 @@ public:
return this->boxWidth;
}
/**
* The starting index of calling processus
* @return start
*/
int getStart() const{
return int(this->start);
}
/**
* Fill a particle
* @warning to work with the loader, particles has to expose a setPosition method
......
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