Commit dfc8b42d authored by berenger-bramas's avatar berenger-bramas

FMB progress

Upward OK

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@13 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 713d7a08
......@@ -15,6 +15,7 @@ Doc/html/
tmp/
*.tmp
*.temp
*.temp.*
*.fma
*.FMA
*~
......
......@@ -88,9 +88,10 @@ public:
double tempWidth = this->boxWidth;
// pre compute box width for each level
for(int indexLevel = 0; indexLevel < this->height; ++indexLevel ){
this->boxWidthAtLevel[indexLevel] = tempWidth;
this->boxWidthAtLevel[indexLevel] = tempWidth;
tempWidth /= 2.0;
}
}
/** Desctructor */
......@@ -105,7 +106,7 @@ public:
* @param inParticule the particule to insert (must inherite from FAbstractParticule)
*/
void insert(ParticuleClass* const inParticule){
const MortonIndex particuleIndex = getLeafMortonFromPosition(inParticule->getPosition());
const MortonIndex particuleIndex = getLeafMortonFromPosition(inParticule->getPosition());
root.insert( particuleIndex, inParticule, height, this->boxWidthAtLevel);
}
......
This diff is collapsed.
......@@ -109,6 +109,7 @@ public:
double x,y,z,data;
this->file >> x >> y >> z >> data;
inParticule->setPosition(F3DPosition(x,y,z));
inParticule->setValue(data);
}
};
......
......@@ -76,6 +76,14 @@ public:
void incImag(const double inIncImag){
this->imag += inIncImag;
}
void decReal(const double inIncReal){
this->real -= inIncReal;
}
void decImag(const double inIncImag){
this->imag -= inIncImag;
}
};
......
......@@ -9,6 +9,7 @@
#define FDEBUG( X )
#else
#define FDEBUG( X ) X
#define FDEBUG_TRACE( X ) X
#include <iostream>
#include <fstream>
......
......@@ -14,13 +14,15 @@
#include "../Sources/Utils/F3DPosition.hpp"
#include "../Sources/Utils/FComplexe.hpp"
#include "../Sources/Core/FBasicParticule.hpp"
#include "../Sources/Core/FFmaParticule.hpp"
#include "../Sources/Core/FBasicCell.hpp"
#include "../Sources/Core/FFMMAlgorithm.hpp"
#include "../Sources/Core/FFmbKernels.hpp"
// Compile by : g++ testFMMAlgorithm.cpp ../Sources/Utils/FAssertable.cpp ../Sources/Utils/FDebug.cpp -O2 -o testFMMAlgorithm.exe
#include "../Sources/Files/FFMALoader.hpp"
// Compile by : g++ testFmbAlgorithm.cpp ../Sources/Utils/FAssertable.cpp ../Sources/Utils/FDebug.cpp -O2 -o testFmbAlgorithm.exe
/** This program show an example of use of
* the fmm basic algo
......@@ -30,24 +32,14 @@
/** Custom particule class */
class FmbParticule : public FBasicParticule{
protected:
double value;
class FmbParticule : public FFmaParticule {
public:
FmbParticule(const double inX, const double inY, const double inZ) : FBasicParticule(inX,inY,inZ) {
setValue(0);
FmbParticule(const double inX, const double inY, const double inZ, const double inValue)
: FFmaParticule(inX,inY,inZ,inValue) {
}
FmbParticule(const F3DPosition& inPos) : FBasicParticule(inPos) {
setValue(0);
FmbParticule(const F3DPosition& inPos) : FFmaParticule(inPos) {
}
FmbParticule(){
setValue( 0 );
}
double getValue() const {
return this->value;
}
void setValue(const double inValue){
this->value = inValue;
}
};
......@@ -56,12 +48,22 @@ class FmbCell : public FBasicCell {
static const int FMB_Info_P = 2;
static const int MultipoleSize = int(((FMB_Info_P)+1) * ((FMB_Info_P)+2) * 0.5);
FComplexe multipole_exp[MultipoleSize];
FComplexe local_exp[MultipoleSize];
public:
FmbCell() {
for(int idxPole = 0 ; idxPole < MultipoleSize ; ++idxPole){
this->multipole_exp[idxPole].setImag(0);
this->multipole_exp[idxPole].setReal(0);
this->local_exp[idxPole].setImag(0);
this->local_exp[idxPole].setReal(0);
}
}
FComplexe* getMultipole() {
return this->multipole_exp;
}
FComplexe* getLocal() {
return this->local_exp;
}
};
/*
......@@ -78,32 +80,37 @@ Done (1.94356s).
// Simply create particules and try the kernels
int main(int , char ** ){
const int NbLevels = 10;//10;
const int NbLevels = 9;//10;
const int NbSubLevels = 3;//3
const long NbPart = 2;//2E6;
const int BoxWidth = 2;//1
FmbParticule* particules = new FmbParticule[NbPart];
FTic counter;
const char* const filename = "testFMAlgorithm.fma";
FFMALoader<FmbParticule> loader(filename);
if(!loader.isValide()){
std::cout << "Loader Error, " << filename << "is missing\n";
return 1;
}
// -----------------------------------------------------
srand ( 1 ); // volontary set seed to constant
FOctree<FmbParticule, FmbCell, NbLevels, NbSubLevels> tree(loader.getBoxWidth(),loader.getCenterOfBox());
// -----------------------------------------------------
std::cout << "Creating " << NbPart << " particules ..." << std::endl;
std::cout << "Creating " << loader.getNumberOfParticules() << " particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
new (&particules[idxPart]) FmbParticule(double(rand())/RAND_MAX,double(rand())/RAND_MAX,double(rand())/RAND_MAX);
FmbParticule* particules = new FmbParticule[loader.getNumberOfParticules()];
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
loader.fillParticule(&particules[idxPart]);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
FOctree<FmbParticule, FmbCell, NbLevels, NbSubLevels> tree(BoxWidth,F3DPosition(0.0,0.0,0.0));
// -----------------------------------------------------
std::cout << "Inserting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
tree.insert(&particules[idxPart]);
}
counter.tac();
......@@ -113,7 +120,7 @@ int main(int , char ** ){
std::cout << "Working on particules ..." << std::endl;
counter.tic();
FFmbKernels<FmbParticule, FmbCell> kernels(NbLevels,BoxWidth);
FFmbKernels<FmbParticule, FmbCell> kernels(NbLevels,loader.getBoxWidth());
FFMMAlgorithm<FmbParticule, FmbCell, NbLevels, NbSubLevels> algo(&tree,&kernels);
algo.execute();
......@@ -123,7 +130,7 @@ int main(int , char ** ){
// -----------------------------------------------------
std::cout << "Deleting particules ..." << std::endl;
counter.tic();
for(long idxPart = 0 ; idxPart < NbPart ; ++idxPart){
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticules() ; ++idxPart){
particules[idxPart].~FmbParticule();
}
delete [] particules;
......
......@@ -14,7 +14,7 @@
#include "../Sources/Utils/FAssertable.hpp"
#include "../Sources/Utils/F3DPosition.hpp"
#include "../Sources/Core/FBasicParticule.hpp"
#include "../Sources/Core/FFmaParticule.hpp"
#include "../Sources/Core/FBasicCell.hpp"
#include "../Sources/Files/FFMALoader.hpp"
......@@ -33,26 +33,26 @@
int main(int , char ** ){
// we store all particules to be able to dealloc
FList<FBasicParticule*> particules;
FList<FFmaParticule*> particules;
// Use testLoaderCreate.exe to create this file
const char* const filename = "testLoaderFMA.fma";
FTic counter;
// open basic particules loader
FFMALoader<FBasicParticule> loader(filename);
FFMALoader<FFmaParticule> loader(filename);
if(!loader.isValide()){
std::cout << "Loader Error, " << filename << "is missing\n";
return 1;
}
// otree
FOctree<FBasicParticule, FBasicCell, 10, 3> tree(loader.getBoxWidth(),loader.getCenterOfBox());
FOctree<FFmaParticule, FBasicCell, 10, 3> tree(loader.getBoxWidth(),loader.getCenterOfBox());
// -----------------------------------------------------
std::cout << "Inserting " << loader.getNumberOfParticules() << " particules ..." << std::endl;
counter.tic();
for(int idx = 0 ; idx < loader.getNumberOfParticules() ; ++idx){
FBasicParticule* const part = new FBasicParticule();
FFmaParticule* const part = new FFmaParticule();
particules.pushFront(part);
loader.fillParticule(part);
tree.insert(part);
......
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