Commit 184d7ae4 authored by berenger-bramas's avatar berenger-bramas

Factorize the FMB cell & particle into one file.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@226 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 7668036d
#ifndef FFMBCOMPONENTS_HPP
#define FFMBCOMPONENTS_HPP
#include "../Extensions/FExtendForces.hpp"
#include "../Extensions/FExtendPotential.hpp"
#include "../Extensions/FExtendParticleType.hpp"
#include "../Extensions/FExtendCellType.hpp"
#include "../Components/FFmaParticle.hpp"
#include "../Components/FBasicCell.hpp"
#include "../Components/FSimpleLeaf.hpp"
#include "../Components/FBasicKernels.hpp"
#include "../Utils/FAbstractSendable.hpp"
#include "FExtendFmbCell.hpp"
class FmbParticle : public FExtendForces, public FFmaParticle, public FExtendPotential {
public:
};
class FmbCell : public FBasicCell, public FExtendFmbCell {
public:
};
class FmbTypedParticle : public FmbParticle, public FExtendParticleType {
public:
};
class FmbTypedCell : public FmbCell, public FExtendCellType {
public:
};
class FmbSendableCell : public FmbCell , public FAbstractSendable {
public:
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
static const int SerializedSizeUp = sizeof(FComplexe)*MultipoleSize + sizeof(FBasicCell);
void serializeUp(void* const buffer) const {
memcpy(buffer, (FBasicCell*)this, sizeof(FBasicCell));
memcpy((char*)(buffer) + sizeof(FBasicCell), multipole_exp, sizeof(FComplexe)*MultipoleSize );
}
void deserializeUp(const void* const buffer){
memcpy((FBasicCell*)this, buffer, sizeof(FBasicCell));
memcpy(multipole_exp, (char*)(buffer) + sizeof(FBasicCell), sizeof(FComplexe)*MultipoleSize );
}
static const int SerializedSizeDown = sizeof(FComplexe)*MultipoleSize + sizeof(FBasicCell);
void serializeDown(void* const buffer) const {
memcpy(buffer, (FBasicCell*)this, sizeof(FBasicCell));
memcpy((char*)(buffer) + sizeof(FBasicCell), local_exp, sizeof(FComplexe)*MultipoleSize );
}
void deserializeDown(const void* const buffer){
memcpy((FBasicCell*)this, buffer, sizeof(FBasicCell));
memcpy(local_exp, (char*)(buffer) + sizeof(FBasicCell), sizeof(FComplexe)*MultipoleSize );
}
};
#endif // FFMBCOMPONENTS_HPP
......@@ -11,23 +11,12 @@
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Components/FFmaParticle.hpp"
#include "../Src/Extensions/FExtendForces.hpp"
#include "../Src/Extensions/FExtendPotential.hpp"
#include "../Src/Components/FBasicCell.hpp"
#include "../Src/Fmb/FExtendFmbCell.hpp"
#include "../Src/Core/FFmmAlgorithm.hpp"
#include "../Src/Core/FFmmAlgorithmThread.hpp"
#include "../Src/Core/FFmmAlgorithmThreadUs.hpp"
#include "../Src/Components/FSimpleLeaf.hpp"
#include "../Src/Components/FBasicKernels.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Files/FFmaLoader.hpp"
......@@ -41,21 +30,6 @@
*/
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
*/
class FmbParticle : public FExtendForces, public FFmaParticle, public FExtendPotential {
public:
};
/** Custom cell
*
*/
class FmbCell : public FBasicCell, public FExtendFmbCell {
public:
};
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FmbParticle ParticleClass;
......
......@@ -9,20 +9,15 @@
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Components/FFmaParticle.hpp"
#include "../Src/Extensions/FExtendForces.hpp"
#include "../Src/Extensions/FExtendPotential.hpp"
#include "../Src/Components/FBasicCell.hpp"
#include "../Src/Fmb/FExtendFmbCell.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Core/FFmmAlgorithmThreadProc.hpp"
#include "../Src/Core/FFmmAlgorithmThread.hpp"
#include "../Src/Components/FSimpleLeaf.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Files/FMpiFmaLoader.hpp"
#include "../Src/Files/FMpiTreeBuilder.hpp"
#include "../Src/Files/FFmaBinLoader.hpp"
......@@ -53,70 +48,36 @@
*/
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
*/
class FmbParticle : public FFmaParticle, public FExtendForces, public FExtendPotential {
public:
};
/** Custom cell
*
*/
class FmbCell : public FBasicCell, public FExtendFmbCell , public FAbstractSendable {
public:
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
static const int SerializedSizeUp = sizeof(FComplexe)*MultipoleSize + sizeof(FBasicCell);
void serializeUp(void* const buffer) const {
memcpy(buffer, (FBasicCell*)this, sizeof(FBasicCell));
memcpy((char*)(buffer) + sizeof(FBasicCell), multipole_exp, sizeof(FComplexe)*MultipoleSize );
}
void deserializeUp(const void* const buffer){
memcpy((FBasicCell*)this, buffer, sizeof(FBasicCell));
memcpy(multipole_exp, (char*)(buffer) + sizeof(FBasicCell), sizeof(FComplexe)*MultipoleSize );
///////////////////////////////////////////////////////
// to test equality between good and potentialy bad solution
///////////////////////////////////////////////////////
/** To compare data */
bool isEqualPole(const FmbSendableCell& me, const FmbSendableCell& other, FReal*const cumul){
//return memcmp(multipole_exp, other.multipole_exp, sizeof(FComplexe)*MultipoleSize) == 0 &&
// memcmp(local_exp, other.local_exp, sizeof(FComplexe)*MultipoleSize) == 0;
*cumul = 0.0;
for(int idx = 0; idx < FExtendFmbCell::MultipoleSize; ++idx){
*cumul += FMath::Abs( me.getMultipole()[idx].getImag() - other.getMultipole()[idx].getImag() );
*cumul += FMath::Abs( me.getMultipole()[idx].getReal() - other.getMultipole()[idx].getReal() );
}
static const int SerializedSizeDown = sizeof(FComplexe)*MultipoleSize + sizeof(FBasicCell);
void serializeDown(void* const buffer) const {
memcpy(buffer, (FBasicCell*)this, sizeof(FBasicCell));
memcpy((char*)(buffer) + sizeof(FBasicCell), local_exp, sizeof(FComplexe)*MultipoleSize );
}
void deserializeDown(const void* const buffer){
memcpy((FBasicCell*)this, buffer, sizeof(FBasicCell));
memcpy(local_exp, (char*)(buffer) + sizeof(FBasicCell), sizeof(FComplexe)*MultipoleSize );
}
///////////////////////////////////////////////////////
// to test equality between good and potentialy bad solution
///////////////////////////////////////////////////////
/** To compare data */
bool isEqualPole(const FmbCell& other, FReal*const cumul){
//return memcmp(multipole_exp, other.multipole_exp, sizeof(FComplexe)*MultipoleSize) == 0 &&
// memcmp(local_exp, other.local_exp, sizeof(FComplexe)*MultipoleSize) == 0;
*cumul = 0.0;
for(int idx = 0; idx < MultipoleSize; ++idx){
*cumul += FMath::Abs( multipole_exp[idx].getImag() - other.multipole_exp[idx].getImag() );
*cumul += FMath::Abs( multipole_exp[idx].getReal() - other.multipole_exp[idx].getReal() );
}
return *cumul < 0.0001;//FMath::LookEqual(cumul,FReal(0.0));
}
return *cumul < 0.0001;//FMath::LookEqual(cumul,FReal(0.0));
/** To compare data */
bool isEqualLocal(const FmbSendableCell& me, const FmbSendableCell& other, FReal*const cumul){
//return memcmp(multipole_exp, other.multipole_exp, sizeof(FComplexe)*MultipoleSize) == 0 &&
// memcmp(local_exp, other.local_exp, sizeof(FComplexe)*MultipoleSize) == 0;
*cumul = 0.0;
for(int idx = 0; idx < FExtendFmbCell::MultipoleSize; ++idx){
*cumul += FMath::Abs( me.getLocal()[idx].getImag() - other.getLocal()[idx].getImag() );
*cumul += FMath::Abs( me.getLocal()[idx].getReal() - other.getLocal()[idx].getReal() );
}
/** To compare data */
bool isEqualLocal(const FmbCell& other, FReal*const cumul){
//return memcmp(multipole_exp, other.multipole_exp, sizeof(FComplexe)*MultipoleSize) == 0 &&
// memcmp(local_exp, other.local_exp, sizeof(FComplexe)*MultipoleSize) == 0;
*cumul = 0.0;
for(int idx = 0; idx < MultipoleSize; ++idx){
*cumul += FMath::Abs( local_exp[idx].getImag() - other.local_exp[idx].getImag() );
*cumul += FMath::Abs( local_exp[idx].getReal() - other.local_exp[idx].getReal() );
}
return *cumul < 0.0001;//FMath::LookEqual(cumul,FReal(0.0));
}
return *cumul < 0.0001;//FMath::LookEqual(cumul,FReal(0.0));
}
};
#ifdef VALIDATE_FMM
template<class OctreeClass, class ContainerClass>
......@@ -215,7 +176,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree,
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FmbParticle ParticleClass;
typedef FmbCell CellClass;
typedef FmbSendableCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
......
......@@ -11,13 +11,6 @@
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Components/FFmaParticle.hpp"
#include "../Src/Extensions/FExtendForces.hpp"
#include "../Src/Extensions/FExtendPotential.hpp"
#include "../Src/Components/FBasicCell.hpp"
#include "../Src/Fmb/FExtendFmbCell.hpp"
#include "../Src/Core/FFmmAlgorithm.hpp"
#include "../Src/Core/FFmmAlgorithmThread.hpp"
......@@ -26,6 +19,8 @@
#include "../Src/Fmb/FFmbKernelsBlockBlas.hpp"
#include "../Src/Fmb/FFmbKernelsBlas.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Files/FFmaScanfLoader.hpp"
......@@ -42,21 +37,6 @@
*/
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
*/
class FmbParticle : public FFmaParticle, public FExtendForces, public FExtendPotential {
public:
};
/** Custom cell
*
*/
class FmbCell : public FBasicCell, public FExtendFmbCell {
public:
};
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FmbParticle ParticleClass;
......
......@@ -6,26 +6,17 @@
#include <stdlib.h>
#include "../Src/Utils/FTic.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Components/FFmaParticle.hpp"
#include "../Src/Extensions/FExtendForces.hpp"
#include "../Src/Extensions/FExtendPotential.hpp"
#include "../Src/Extensions/FExtendParticleType.hpp"
#include "../Src/Extensions/FExtendCellType.hpp"
#include "../Src/Components/FTypedLeaf.hpp"
#include "../Src/Components/FBasicCell.hpp"
#include "../Src/Fmb/FExtendFmbCell.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Core/FFmmAlgorithmTsm.hpp"
#include "../Src/Components/FTypedLeaf.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Files/FFmaTsmLoader.hpp"
......@@ -39,25 +30,10 @@
*/
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
*/
class FmbParticle : public FFmaParticle, public FExtendParticleType, public FExtendForces, public FExtendPotential {
public:
};
/** Custom cell
*
*/
class FmbCell : public FBasicCell, public FExtendFmbCell, public FExtendCellType {
public:
};
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FmbParticle ParticleClass;
typedef FmbCell CellClass;
typedef FmbTypedParticle ParticleClass;
typedef FmbTypedCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FTypedLeaf<ParticleClass, ContainerClass > LeafClass;
......@@ -131,7 +107,7 @@ int main(int argc, char ** argv){
typename OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
do{
FVector<FmbParticle>::ConstBasicIterator iter(*octreeIterator.getCurrentListTargets());
FVector<ParticleClass>::ConstBasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.hasNotFinished() ){
potential += iter.data().getPotential() * iter.data().getPhysicalValue();
forces += iter.data().getForces();
......
......@@ -6,21 +6,14 @@
#include <stdlib.h>
#include "../Src/Utils/FTic.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Components/FFmaParticle.hpp"
#include "../Src/Extensions/FExtendForces.hpp"
#include "../Src/Extensions/FExtendPotential.hpp"
#include "../Src/Extensions/FExtendParticleType.hpp"
#include "../Src/Extensions/FExtendCellType.hpp"
#include "../Src/Components/FBasicCell.hpp"
#include "../Src/Fmb/FExtendFmbCell.hpp"
#include "../Src/Fmb/FFmbComponents.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
#include "../Src/Core/FFmmAlgorithm.hpp"
#include "../Src/Core/FFmmAlgorithmTsm.hpp"
......@@ -30,7 +23,6 @@
#include "../Src/Components/FSimpleLeaf.hpp"
#include "../Src/Components/FTypedLeaf.hpp"
#include "../Src/Fmb/FFmbKernels.hpp"
// With openmp : g++ testFmbTsmNoTsm.cpp ../Src/Utils/FDebug.cpp ../Src/Utils/FTrace.cpp -lgomp -fopenmp -O2 -o testFmbTsmNoTsm.exe
......@@ -43,28 +35,6 @@
*/
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
*/
class FmbParticle : public FFmaParticle, public FExtendForces, public FExtendPotential {
public:
};
class FmbParticleTyped : public FmbParticle, public FExtendParticleType {
public:
};
/** Custom cell
*
*/
class FmbCell : public FBasicCell, public FExtendFmbCell {
public:
};
class FmbCellTyped : public FmbCell, public FExtendCellType {
public:
};
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FmbParticle ParticleClass;
......@@ -77,8 +47,8 @@ int main(int argc, char ** argv){
typedef FFmmAlgorithmThread<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
typedef FmbParticleTyped ParticleClassTyped;
typedef FmbCellTyped CellClassTyped;
typedef FmbTypedParticle ParticleClassTyped;
typedef FmbTypedCell CellClassTyped;
typedef FVector<ParticleClassTyped> ContainerClassTyped;
typedef FTypedLeaf<ParticleClassTyped, ContainerClassTyped > LeafClassTyped;
......
......@@ -48,10 +48,10 @@ int main(int argc, char ** argv){
std::cout << ">> This executable has to be used to test the FMM algorithm.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
......@@ -60,7 +60,7 @@ int main(int argc, char ** argv){
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
OctreeClass tree(NbLevels, SizeSubLevels,1.0,F3DPosition(0.5,0.5,0.5));
OctreeClass tree(NbLevels, SizeSubLevels, 1.0, F3DPosition(0.5,0.5,0.5));
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
......
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