Commit 75fc7f4b authored by berenger-bramas's avatar berenger-bramas

Added some "print" when executing test files.

Also renamed some files.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@35 2616d619-271b-44dc-8df4-d4a8f33a7222
parent e81135cd
#ifndef FEXTENDFORCES_HPP
#define FEXTENDFORCES_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Utils/FGlobal.hpp"
#include "../Utils/F3DPosition.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendForces
* Please read the license
*
* This class is an extenssion.
* It proposes a 3d array as a forces vector.
*/
class FExtendForces {
protected:
F3DPosition forces; //< 3D vector stored in a position object
public:
/** Default constructor */
FExtendForces() {
}
/** Copy constructor */
FExtendForces(const FExtendForces& other) : forces(other.forces) {
}
/** Destructor */
virtual ~FExtendForces(){
}
/** Copy operator */
FExtendForces& operator=(const FExtendForces& other) {
this->forces = other.forces;
return *this;
}
/** Return the forces */
F3DPosition getForces() const {
return this->forces;
}
/** Set Forces */
void setForces(const F3DPosition& inForces) {
this->forces = inForces;
}
/** Set Forces with 3 FReals */
void setForces(const FReal inFx, const FReal inFy, const FReal inFz) {
this->forces.setX(inFx);
this->forces.setY(inFy);
this->forces.setZ(inFz);
}
};
#endif //FEXTENDFORCES_HPP
// [--LICENSE--]
#ifndef FEXTENDMORTONINDEX_HPP
#define FEXTENDMORTONINDEX_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Containers/FTreeCoordinate.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendMortonIndex
* Please read the license
* This class is an extenssion.
* It proposes a mortonIndex.
*/
class FExtendMortonIndex {
protected:
MortonIndex mortonIndex; //< Morton index (need by most elements)
public:
/** Default constructor */
FExtendMortonIndex() : mortonIndex(0) {
}
/** Copy constructor */
FExtendMortonIndex(const FExtendMortonIndex& other) : mortonIndex(other.mortonIndex) {
}
/** Destructor */
virtual ~FExtendMortonIndex(){
}
/** Copy operator */
FExtendMortonIndex& operator=(const FExtendMortonIndex& other) {
this->mortonIndex = other.mortonIndex;
return *this;
}
/** To get the morton index */
MortonIndex getMortonIndex() const {
return this->mortonIndex;
}
/** To set the morton index */
void setMortonIndex(const MortonIndex inMortonIndex) {
this->mortonIndex = inMortonIndex;
}
};
#endif //FEXTENDMORTONINDEX_HPP
// [--LICENSE--]
#ifndef FExtendPhysicalValue_HPP
#define FExtendPhysicalValue_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Utils/FGlobal.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendPhysicalValue
* Please read the license
* This class is an extenssion.
* It proposes a physicalValue (FReal).
*/
class FExtendPhysicalValue {
protected:
FReal physicalValue; //< A simple physicalValue
public:
/** Default constructor */
FExtendPhysicalValue() : physicalValue(0) {
}
/** Copy constructor */
FExtendPhysicalValue(const FExtendPhysicalValue& other) : physicalValue(other.physicalValue) {
}
/** Destructor */
virtual ~FExtendPhysicalValue(){
}
/** Copy Constructor */
FExtendPhysicalValue& operator=(const FExtendPhysicalValue& other) {
this->physicalValue = other.physicalValue;
return *this;
}
/** To get the physicalValue */
FReal getPhysicalValue() const {
return this->physicalValue;
}
/** To set the physicalValue */
void setPhysicalValue(const FReal inphysicalValue) {
this->physicalValue = inphysicalValue;
}
};
#endif //FExtendPhysicalValue_HPP
// [--LICENSE--]
#ifndef FEXTENDPOSITION_HPP
#define FEXTENDPOSITION_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Utils/FGlobal.hpp"
#include "../Utils/F3DPosition.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendPosition
* Please read the license
* This class is an extenssion.
* It proposes a mortonIndex.
*/
class FExtendPosition {
protected:
F3DPosition position; //< The position
public:
/** Default constructor */
FExtendPosition() {
}
/** Copy constructor */
FExtendPosition(const FExtendPosition& other) : position(other.position) {
}
/** Destructor */
virtual ~FExtendPosition(){
}
/** Copy operator */
FExtendPosition& operator=(const FExtendPosition& other) {
this->position = other.position;
return *this;
}
/** To get the position */
F3DPosition getPosition() const {
return this->position;
}
/** To set the position */
void setPosition(const F3DPosition& inPosition) {
this->position = inPosition;
}
/** To set the position from 3 FReals */
void setPosition(const FReal inX, const FReal inY, const FReal inZ) {
this->position.setX(inX);
this->position.setY(inY);
this->position.setZ(inZ);
}
};
#endif //FEXTENDPOSITION_HPP
// [--LICENSE--]
#ifndef FEXTENDPOTENTIAL_HPP
#define FEXTENDPOTENTIAL_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Utils/FGlobal.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendPotential
* Please read the license
* This class is an extenssion.
* It proposes a Potential (FReal).
*/
class FExtendPotential {
protected:
FReal potential; //< The potential extended
public:
/** Default constructor */
FExtendPotential() : potential(0) {
}
/** Copy constructor */
FExtendPotential(const FExtendPotential& other) : potential(other.potential) {
}
/** Destructor */
virtual ~FExtendPotential(){
}
/** Copy operator */
FExtendPotential& operator=(const FExtendPotential& other) {
this->potential = other.potential;
return *this;
}
/** To get the potential */
FReal getPotential() const {
return this->potential;
}
/** To set the potential */
void setPotential(const FReal inPotential) {
this->potential = inPotential;
}
};
#endif //FEXTENDPOTENTIAL_HPP
// [--LICENSE--]
#ifndef FFMATORLOADER_HPP
#define FFMATORLOADER_HPP
#ifndef FFMATOSLOADER_HPP
#define FFMATOSLOADER_HPP
// /!\ Please, you must read the license at the bottom of this page
#include <iostream>
......@@ -11,7 +11,7 @@
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FFMAToRLoader
* @class FFMAToSLoader
* Please read the license
*
* Load a file with a format like :
......@@ -19,7 +19,7 @@
* X Y Z // one particule by line
* ....
* <code>
* FFMAToRLoader<FBasicParticule> loader("../FMB++/Tests/particules.basic.txt"); <br>
* FFMAToSLoader<FBasicParticule> loader("../FMB++/Tests/particules.basic.txt"); <br>
* if(!loader.isValide()){ <br>
* std::cout << "Loader Error\n"; <br>
* return 1; <br>
......@@ -37,7 +37,7 @@
* Particule has to extend {FExtendPhysicalValue,FExtendPosition}
*/
template <class ParticuleClass>
class FFMAToRLoader : public FAbstractLoader<ParticuleClass> {
class FFMAToSLoader : public FAbstractLoader<ParticuleClass> {
protected:
std::ifstream file; //< The file to read
F3DPosition centerOfBox; //< The center of box read from file
......@@ -50,7 +50,7 @@ public:
* @param filename the name of the file to open
* you can test if file is successfuly open by calling isValide()
*/
FFMAToRLoader(const char* const filename): file(filename,std::ifstream::in){
FFMAToSLoader(const char* const filename): file(filename,std::ifstream::in){
// test if open
if(this->file.is_open()){
FReal x,y,z;
......@@ -67,7 +67,7 @@ public:
/**
* Default destructor, simply close the file
*/
virtual ~FFMAToRLoader(){
virtual ~FFMAToSLoader(){
file.close();
}
......@@ -120,6 +120,6 @@ public:
};
#endif //FFMATORLOADER_HPP
#endif //FFMATOSLOADER_HPP
// [--LICENSE--]
......@@ -34,36 +34,41 @@
*/
class FApp : public ApplicationImplementation{
public:
FApp(const int inArgc, char ** const inArgv )
: ApplicationImplementation(inArgc,inArgv) {
}
FApp(const int inArgc, char ** const inArgv )
: ApplicationImplementation(inArgc,inArgv) {
}
protected:
void initMaster(){
printf("I am %d on %d, I am master\n", processId(), processCount());
const std::string argStr = userParemeterAt<std::string>(0);
printf("[Master] arg str = %s\n", argStr.c_str()); // will print ./testApplication
const int argInt = userParemeterAt<int>(0,-1);
printf("[Master] arg int = %d\n", argInt); // will print -1
}
void initSlave(){
printf("I am %d on %d, I am slave\n", processId(), processCount());
}
void run(){
printf("I am %d, I start to work\n",processId());
for(long idx = 0 ; idx < 50000000 ; ++idx) {++idx;--idx;}
processBarrier();
printf("I am %d, I just finished\n",processId());
}
void initMaster(){
printf("I am %d on %d, I am master\n", processId(), processCount());
const std::string argStr = userParemeterAt<std::string>(0);
printf("[Master] arg str = %s\n", argStr.c_str()); // will print ./testApplication
const int argInt = userParemeterAt<int>(0,-1);
printf("[Master] arg int = %d\n", argInt); // will print -1
}
void initSlave(){
printf("I am %d on %d, I am slave\n", processId(), processCount());
}
void run(){
printf("I am %d, I start to work\n",processId());
for(long idx = 0 ; idx < 50000000 ; ++idx) {++idx;--idx;}
processBarrier();
printf("I am %d, I just finished\n",processId());
}
};
// Usual Main
int main(int argc, char ** argv){
FApp app(argc,argv);
return app.execute();
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable is useless to execute.\n";
std::cout << ">> It is only interesting to wath the code to understand\n";
std::cout << ">> how mpi MAY be included in the lib (no define!)\n";
//////////////////////////////////////////////////////////////
FApp app(argc,argv);
return app.execute();
}
......
......@@ -39,6 +39,11 @@ protected:
// Usual Main
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable is useless to execute.\n";
std::cout << ">> It is only interesting to wath the code to understand\n";
std::cout << ">> the FAssert system.\n";
//////////////////////////////////////////////////////////////
FApp app(argc,argv);
return app.execute();
}
......
......@@ -10,6 +10,11 @@
*/
int main(void){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable is useless to execute.\n";
std::cout << ">> It is only interesting to wath the code to understand\n";
std::cout << ">> to understand the FDebug system.\n";
//////////////////////////////////////////////////////////////
// Print data simply
FDEBUG( FDebug::Controller << "Hello Wordl\n");
......
......@@ -35,76 +35,80 @@
// Simply create particules and try the kernels
int main(int argc, char ** argv){
const int NbLevels = 10;//10;
const int SizeSubLevels = 3;//3
const long NbPart = 2000000;//2000000
FTestParticule* particules = new FTestParticule[NbPart];
FTic counter;
srand ( 1 ); // volontary set seed to constant
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules[idxPart].setPosition(FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
FOctree<FTestParticule, FTestCell, FSimpleLeaf, NbLevels, SizeSubLevels> tree(1.0,F3DPosition(0.5,0.5,0.5));
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Inserting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
tree.insert(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Working on particules ..." << std::endl;
counter.tic();
// FTestKernels FBasicKernels
FTestKernels<FTestParticule, FTestCell, NbLevels> kernels;
//FFMMAlgorithm FFMMAlgorithmThreaded FFMMAlgorithmArray FFMMAlgorithmTask
FFMMAlgorithmArray<FTestKernels, FTestParticule, FTestCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
ValidateFMMAlgo(&tree);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Deleting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules[idxPart].~FTestParticule();
}
delete [] particules;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
return 0;
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test the FMM algorithm.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = 10;//10;
const int SizeSubLevels = 3;//3
const long NbPart = 2000000;//2000000
FTestParticule* particules = new FTestParticule[NbPart];
FTic counter;
srand ( 1 ); // volontary set seed to constant
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules[idxPart].setPosition(FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX,FReal(rand())/RAND_MAX);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
FOctree<FTestParticule, FTestCell, FSimpleLeaf, NbLevels, SizeSubLevels> tree(1.0,F3DPosition(0.5,0.5,0.5));
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Inserting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
tree.insert(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Working on particules ..." << std::endl;
counter.tic();
// FTestKernels FBasicKernels
FTestKernels<FTestParticule, FTestCell, NbLevels> kernels;
//FFMMAlgorithm FFMMAlgorithmThreaded FFMMAlgorithmArray FFMMAlgorithmTask
FFMMAlgorithmArray<FTestKernels, FTestParticule, FTestCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
ValidateFMMAlgo(&tree);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
std::cout << "Deleting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
particules[idxPart].~FTestParticule();
}
delete [] particules;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
return 0;
}
......
......@@ -57,113 +57,117 @@ public:
// Simply create particules and try the kernels
int main(int argc, char ** argv){
const int NbLevels = 9;//10;
const int SizeSubLevels = 3;//3
FTic counter;
const char* const defaultFilename = "testLoaderFMA.fma"; //../../Data/ "testLoaderFMA.fma" "testFMAlgorithm.fma" Sphere.fma
const char* filename;
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test fmb algorithm.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = 9;//10;
const int SizeSubLevels = 3;//3
FTic counter;
const char* const defaultFilename = "testLoaderFMA.fma"; //../../Data/ "testLoaderFMA.fma" "testFMAlgorithm.fma" Sphere.fma
const char* filename;
if(argc == 1){
std::cout << "You have to give a .fma file in argument.\n";
std::cout << "The program will try a default file : " << defaultFilename << "\n";
filename = defaultFilename;
}
else{
filename = argv[1];
std::cout << "Opening : " << filename << "\n";
}
if(argc == 1){
std::cout << "You have to give a .fma file in argument.\n";
std::cout << "The program will try a default file : " << defaultFilename << "\n";
filename = defaultFilename;
}
else{
filename = argv[1];
std::cout << "Opening : " << filename << "\n";
}
FFMALoader<FmbParticule> loader(filename);
if(!loader.isValide()){
std::cout << "Loader Error, " << filename << " is missing\n";
return 1;
}
FFMALoader<FmbParticule> loader(filename);
if(!loader.isValide()){
std::cout << "Loader Error, " << filename << " is missing\n";
return 1;
}
// -----------------------------------------------------
// -----------------------------------------------------
FOctree<FmbParticule, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> tree(loader.getBoxWidth(),loader.getCenterOfBox());
FOctree<FmbParticule, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> tree(loader.getBoxWidth(),loader.getCenterOfBox());
// -----------------------------------------------------
// -----------------------------------------------------
std::cout << "Creating " << loader.getNumberOfParticules() << " particules ..." << std::endl;
counter.tic();
std::cout << "Creating " << loader.getNumberOfParticules() << " particules ..." << std::endl;
counter.tic();
FmbParticule* particules = new FmbParticule[loader.getNumberOfParticules()];
FmbParticule* particules = new FmbParticule[loader.getNumberOfParticules()];
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
loader.fillParticule(&particules[idxPart]);
}
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
loader.fillParticule(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
// -----------------------------------------------------
std::cout << "Inserting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
tree.insert(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
std::cout << "Inserting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
tree.insert(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
// -----------------------------------------------------
std::cout << "Working on particules ..." << std::endl;
counter.tic();
std::cout << "Working on particules ..." << std::endl;
counter.tic();
//FFmbKernelsPotentialForces FFmbKernelsForces FFmbKernelsPotential
FFmbKernelsPotentialForces<FmbParticule, FmbCell, NbLevels> kernels(loader.getBoxWidth());
//FFMMAlgorithm FFMMAlgorithmThreaded FFMMAlgorithmArray FFMMAlgorithmTask
FFMMAlgorithm<FFmbKernelsPotentialForces, FmbParticule, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
//FFmbKernelsPotentialForces FFmbKernelsForces FFmbKernelsPotential
FFmbKernelsPotentialForces<FmbParticule, FmbCell, NbLevels> kernels(loader.getBoxWidth());
//FFMMAlgorithm FFMMAlgorithmThreaded FFMMAlgorithmArray FFMMAlgorithmTask
FFMMAlgorithm<FFmbKernelsPotentialForces, FmbParticule, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
//std::cout << "Foces Sum x = " << kernels.getForcesSum().getX() << " y = " << kernels.getForcesSum().getY() << " z = " << kernels.getForcesSum().getZ() << std::endl;
//std::cout << "Potential = " << kernels.getPotential() << std::endl;
//std::cout << "Foces Sum x = " << kernels.getForcesSum().getX() << " y = " << kernels.getForcesSum().getY() << " z = " << kernels.getForcesSum().getZ() << std::endl;
//std::cout << "Potential = " << kernels.getPotential() << std::endl;
{ // get sum forces&potential
FReal potential = 0;
F3DPosition forces;
FOctree<FmbParticule, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels>::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
do{
FList<FmbParticule*>::ConstBasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.isValide() ){
potential += iter.value()->getPotential() * iter.value()->getPhysicalValue();
forces += iter.value()->getForces();
{ // get sum forces&potential
FReal potential = 0;
F3DPosition forces;