Commit 94264c1e authored by BRAMAS Berenger's avatar BRAMAS Berenger

Work in progress to make FReal template - if you pull it will not work

parent 1afca526
......@@ -39,8 +39,8 @@
* templates can be ChebCell/ChebKernel or UnifCell/UnifKernel
*/
template<class InterCell,class InterKernel,
class ContainerClass = FP2PParticleContainerIndexed<>,
class LeafClass = FSimpleLeaf<FP2PParticleContainerIndexed<> >,
class ContainerClass = FP2PParticleContainerIndexed<FReal>,
class LeafClass = FSimpleLeaf<FReal, FP2PParticleContainerIndexed<FReal> >,
class MatrixKernelClass = FInterpMatrixKernelR>
class FInterEngine : public FScalFMMEngine{
private:
......@@ -76,9 +76,9 @@ public:
}
void build_tree(int TreeHeight, double BoxWidth , double * BoxCenter,User_Scalfmm_Cell_Descriptor notUsedHere){
octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint(BoxCenter));
octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint<FReal>(BoxCenter));
this->matrix = new MatrixKernelClass();
this->kernel = new InterKernel(TreeHeight,BoxWidth,FPoint(BoxCenter),matrix);
this->kernel = new InterKernel(TreeHeight,BoxWidth,FPoint<FReal>(BoxCenter),matrix);
}
......@@ -95,7 +95,7 @@ public:
//Inserting array of position
void tree_insert_particles_xyz(int NbPositions, double * XYZ){
for(int idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint(&XYZ[3*idPart]),idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),idPart);
}
nbPart += NbPositions;
}
......@@ -103,7 +103,7 @@ public:
//Inserting arrayS of position
void tree_insert_particles(int NbPositions, double * X, double * Y, double * Z){
for(int idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint(X[idPart],Y[idPart],Z[idPart]),idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),idPart);
}
nbPart += NbPositions;
}
......
......@@ -223,7 +223,7 @@ struct ScalFmmCoreHandle {
// Read/Write parameter
int treeHeight; // Number of level in the octree
FReal boxWidth; // Simulation box size (root level)
FPoint boxCenter; // Center position of the box simulation(FReal[3])
FPoint<FReal> boxCenter; // Center position of the box simulation(FReal[3])
};
ScalFmmCoreConfig config;
......
......@@ -16,20 +16,20 @@ extern "C" scalfmm_handle scalfmm_init(/*int TreeHeight,double BoxWidth,double*
case 1:
//TODO typedefs
typedef FP2PParticleContainerIndexed<> ContainerClass;
typedef FP2PParticleContainerIndexed<FReal> ContainerClass;
typedef FChebCell<7> ChebCell;
typedef FInterpMatrixKernelR MatrixKernelClass;
typedef FInterpMatrixKernelR<FReal> MatrixKernelClass;
typedef FChebSymKernel<ChebCell,ContainerClass,MatrixKernelClass,7> ChebKernel;
handle->engine = new FInterEngine<ChebCell,ChebKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
break;
// case 2:
// //TODO typedefs
// typedef FP2PParticleContainerIndexed<> ContainerClass;
// typedef FP2PParticleContainerIndexed<FReal> ContainerClass;
// typedef FUnifCell<7> UnifCell;
// typedef FInterpMatrixKernelR MatrixKernelClass;
// typedef FInterpMatrixKernelR<FReal> MatrixKernelClass;
// typedef FUnifKernel<UnifCell,ContainerClass,MatrixKernelClass,7> UnifKernel;
// handle->engine = new FInterEngine<UnifCell,UnifKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
......@@ -90,8 +90,8 @@ extern "C" void ChebCellStruct_free(ChebCellStruct * inCell){
typedef struct FChebKernel_struct{
//Be ready full duplication go there !!!
FChebSymKernel<FChebCell<7>,FP2PParticleContainerIndexed<>,FInterpMatrixKernelR,7> ** kernel;
FInterpMatrixKernelR * matrix;
FChebSymKernel<FChebCell<7>,FP2PParticleContainerIndexed<FReal>,FInterpMatrixKernelR,7> ** kernel;
FInterpMatrixKernelR<FReal> * matrix;
} ChebKernelStruct;
//Kernel functions
......@@ -99,14 +99,14 @@ extern "C" ChebKernelStruct * ChebKernelStruct_create(int inTreeHeight,
double inBoxWidth,
double* inBoxCenter){
//typedef to lighten the writing
typedef FChebSymKernel<FChebCell<7>, FP2PParticleContainerIndexed<>, FInterpMatrixKernelR,7> KernelClass;
typedef FChebSymKernel<FChebCell<7>, FP2PParticleContainerIndexed<FReal>, FInterpMatrixKernelR,7> KernelClass;
ChebKernelStruct * newKernel = new ChebKernelStruct();
newKernel->matrix= new FInterpMatrixKernelR();
int nb_threads = omp_get_max_threads();
newKernel->kernel = new KernelClass*[nb_threads];
newKernel->kernel[0]=new KernelClass(inTreeHeight,
inBoxWidth,
FPoint(inBoxCenter[0], inBoxCenter[1], inBoxCenter[2]),
FPoint<FReal>(inBoxCenter[0], inBoxCenter[1], inBoxCenter[2]),
newKernel->matrix);
for(int idThreads=1 ; idThreads<nb_threads ; ++idThreads){
......@@ -128,11 +128,11 @@ extern "C" void ChebKernelStruct_free(void *inKernel){
extern "C" void ChebKernel_P2M(void * leafCell, int nbParticles, const int *particleIndexes, void * inKernel){
//make temporary array of parts
FP2PParticleContainerIndexed<>* tempContainer = new FP2PParticleContainerIndexed<>();
FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>();
tempContainer->reserve(nbParticles);
FPoint pos;
FPoint<FReal> pos;
for(int i=0 ; i<nbParticles ; ++i){
pos = FPoint(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
pos = FPoint<FReal>(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+1],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+2]);
double Phi = reinterpret_cast<UserData *>(inKernel)->myPhyValues[particleIndexes[i]];
......@@ -217,11 +217,11 @@ extern "C" void ChebKernel_L2L(int level, void* parentCell, int childPosition, v
extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* particleIndexes, void* inKernel){
//Create temporary FSimpleLeaf
FP2PParticleContainerIndexed<>* tempContainer = new FP2PParticleContainerIndexed<>();
FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>();
tempContainer->reserve(nbParticles);
FPoint pos;
FPoint<FReal> pos;
for(int i=0 ; i<nbParticles ; ++i){
pos = FPoint(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
pos = FPoint<FReal>(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+1],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+2]);
double Phi = reinterpret_cast<UserData *>(inKernel)->myPhyValues[particleIndexes[i]];
......@@ -258,10 +258,10 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
const int * sourceParticleIndexes[27],int sourceNbPart[27],void* inKernel){
//Create temporary FSimpleLeaf for target
FP2PParticleContainerIndexed<>* tempContTarget = new FP2PParticleContainerIndexed<>();
FP2PParticleContainerIndexed<FReal>* tempContTarget = new FP2PParticleContainerIndexed<FReal>();
tempContTarget->reserve(nbParticles);
for(int i=0 ; i<nbParticles ; ++i){
FPoint pos = FPoint(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
FPoint<FReal> pos = FPoint<FReal>(reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3 ],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+1],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[particleIndexes[i]*3+2]);
double Phi = reinterpret_cast<UserData *>(inKernel)->myPhyValues[particleIndexes[i]];
......@@ -269,18 +269,18 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
}
//Create 27 FSimpleLeaf for 27 sources
FP2PParticleContainerIndexed<>* tempContSources[27];
FP2PParticleContainerIndexed<FReal>* tempContSources[27];
for(int idSource=0; idSource<27 ; ++idSource){
if(sourceNbPart[idSource] != 0){
//Create container
tempContSources[idSource] = new FP2PParticleContainerIndexed<>();
tempContSources[idSource] = new FP2PParticleContainerIndexed<FReal>();
//Allocate memory
tempContSources[idSource]->reserve(sourceNbPart[idSource]);
//Store a ptr to the indices of that source leaf
const int * indSource = sourceParticleIndexes[idSource];
//Then, for each part in this source
for(int i=0 ; i<sourceNbPart[idSource] ; ++i){
FPoint pos = FPoint(reinterpret_cast<UserData *>(inKernel)->insertedPositions[indSource[i]*3 ],
FPoint<FReal> pos = FPoint<FReal>(reinterpret_cast<UserData *>(inKernel)->insertedPositions[indSource[i]*3 ],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[indSource[i]*3+1],
reinterpret_cast<UserData *>(inKernel)->insertedPositions[indSource[i]*3+2]);
double Phi = reinterpret_cast<UserData *>(inKernel)->myPhyValues[indSource[i]];
......
......@@ -203,8 +203,8 @@ class FUserKernelEngine : public FScalFMMEngine{
private:
//Typedefs :
typedef FP2PParticleContainerIndexed<> ContainerClass;
typedef FSimpleLeaf<ContainerClass> LeafClass;
typedef FP2PParticleContainerIndexed<FReal> ContainerClass;
typedef FSimpleLeaf<FReal, ContainerClass> LeafClass;
typedef FOctree<CoreCell,ContainerClass,LeafClass> OctreeClass;
typedef CoreKernel<CoreCell,ContainerClass> CoreKernelClass;
......@@ -223,7 +223,7 @@ private:
public:
FUserKernelEngine(/*int TreeHeight, double BoxWidth , double * BoxCenter, */scalfmm_kernel_type KernelType) :
octree(nullptr), kernel(nullptr), arranger(nullptr){
// octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint(BoxCenter));
// octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint<FReal>(BoxCenter));
kernelType = KernelType;
//Kernel is not set now because the user must provide a
//Scalfmm_Kernel_descriptor
......@@ -251,12 +251,12 @@ public:
void build_tree(int TreeHeight,double BoxWidth,double* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor){
CoreCell::Init(user_cell_descriptor);
this->octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint(BoxCenter));
this->octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint<FReal>(BoxCenter));
}
void tree_insert_particles( int NbPositions, double * arrayX, double * arrayY, double * arrayZ){
for(int idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint(arrayX[idPart],arrayY[idPart],arrayZ[idPart]),idPart);
octree->insert(FPoint<FReal>(arrayX[idPart],arrayY[idPart],arrayZ[idPart]),idPart);
}
nbPart += NbPositions;
this->init_cell();
......@@ -264,7 +264,7 @@ public:
void tree_insert_particles_xyz( int NbPositions, double * XYZ){
for(int idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint(&XYZ[3*idPart]),idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),idPart);
}
nbPart += NbPositions;
this->init_cell();
......@@ -430,7 +430,7 @@ public:
void init_cell(){
double boxwidth = octree->getBoxWidth();
FPoint BoxCenter = octree->getBoxCenter();
FPoint<FReal> BoxCenter = octree->getBoxCenter();
double boxCorner[3];
boxCorner[0] = BoxCenter.getX() - boxwidth/2.0;
boxCorner[1] = BoxCenter.getY() - boxwidth/2.0;
......
......@@ -152,7 +152,7 @@ public:
// Here are all the type definition
typedef FBasicParticleContainer<1, int> CoreContainerClass;
typedef FSimpleLeaf<CoreContainerClass > LeafClass;
typedef FSimpleLeaf<FReal, CoreContainerClass > LeafClass;
typedef FOctree<CoreCell, CoreContainerClass , LeafClass > OctreeClass;
typedef CoreKernel<CoreCell, CoreContainerClass> CoreKernelClass;
typedef FFmmAlgorithmThread<OctreeClass, CoreCell, CoreContainerClass, CoreKernelClass, LeafClass > FmmClassThread;
......@@ -164,7 +164,7 @@ struct ScalFmmCoreHandle {
// Read/Write parameter
int treeHeight; // Number of level in the octree
FReal boxWidth; // Simulation box size (root level)
FPoint boxCenter; // Center position of the box simulation(FReal[3])
FPoint<FReal> boxCenter; // Center position of the box simulation(FReal[3])
};
ScalFmmCoreConfig config;
......@@ -179,7 +179,7 @@ extern "C" Scalfmm_Handle Scalfmm_init_handle(int treeHeight, double boxWidth, d
corehandle->config.treeHeight = treeHeight;
corehandle->config.boxWidth = boxWidth;
corehandle->config.boxCenter = FPoint(boxCenter[0],boxCenter[1],boxCenter[2]);
corehandle->config.boxCenter = FPoint<FReal>(boxCenter[0],boxCenter[1],boxCenter[2]);
corehandle->octree = new OctreeClass(corehandle->config.treeHeight, FMath::Min(3,corehandle->config.treeHeight-1),
corehandle->config.boxWidth, corehandle->config.boxCenter);
......@@ -229,7 +229,7 @@ extern "C" void Scalfmm_dealloc_handle(Scalfmm_Handle handle, Callback_free_cell
extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbParticles, int* particleIndexes, double* particleXYZ){
ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)handle;
for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
corehandle->octree->insert(FPoint(particleXYZ[idxPart*3],particleXYZ[idxPart*3+1],particleXYZ[idxPart*3+2]),
corehandle->octree->insert(FPoint<FReal>(particleXYZ[idxPart*3],particleXYZ[idxPart*3+1],particleXYZ[idxPart*3+2]),
particleIndexes[idxPart]);
}
}
......@@ -237,7 +237,7 @@ extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbP
// Push one particle in the tree
extern "C" void Scalfmm_one_particle(Scalfmm_Handle handle, int particleIndex, double x, double y, double z){
ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)handle;
corehandle->octree->insert(FPoint(x,y,z), particleIndex);
corehandle->octree->insert(FPoint<FReal>(x,y,z), particleIndex);
}
// Execute a kernel (by using the user functions callback).
......
......@@ -242,7 +242,7 @@ public:
return indexes.getSize();
}
void push(const FPoint& partPosition, const int partIndex){
void push(const FPoint<FReal>& partPosition, const int partIndex){
positions.push(partPosition.getX());
positions.push(partPosition.getY());
positions.push(partPosition.getZ());
......@@ -254,7 +254,7 @@ public:
typedef CoreVector CoreContainerClass;
typedef CoreCell<CoreContainerClass> CoreCellClass;
typedef FSimpleLeaf<CoreContainerClass > LeafClass;
typedef FSimpleLeaf<FReal, CoreContainerClass > LeafClass;
typedef FOctree<CoreCellClass, CoreContainerClass , LeafClass > OctreeClass;
typedef CoreKernel<CoreCellClass, CoreContainerClass> CoreKernelClass;
......@@ -533,7 +533,7 @@ int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) {
ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore;
corehandle->octree = new OctreeClass(corehandle->config.treeHeight, FMath::Min(3,corehandle->config.treeHeight-1),
corehandle->config.boxWidth, FPoint(corehandle->config.boxCenter));
corehandle->config.boxWidth, FPoint<FReal>(corehandle->config.boxCenter));
if( corehandle->config.nbThreads != 0){
omp_set_num_threads(corehandle->config.nbThreads);
......@@ -541,7 +541,7 @@ int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) {
for(int idxPart = 0 ; idxPart < (*nb) ; ++idxPart){
const FReal* pos = &position[idxPart * 3];
corehandle->octree->insert(FPoint(pos[0], pos[1], pos[2]),idxPart);
corehandle->octree->insert(FPoint<FReal>(pos[0], pos[1], pos[2]),idxPart);
}
return FMMAPI_NO_ERROR;
......@@ -581,7 +581,7 @@ int FmmCore_doComputation(void *fmmCore) {
ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore;
{ // Ceck if there is number of NbPart summed at level 1
FPoint corner = corehandle->octree->getBoxCenter();
FPoint<FReal> corner = corehandle->octree->getBoxCenter();
corner -= (corehandle->octree->getBoxWidth()/2);
FReal boxWidth = corehandle->octree->getBoxWidth()/( 1<< (corehandle->config.treeHeight-1) );
......@@ -599,7 +599,7 @@ int FmmCore_doComputation(void *fmmCore) {
octreeIterator.getCurrentCell()->createArrays(multipoleSize, localSize);
octreeIterator.getCurrentCell()->setLevel(idxLevel);
const FTreeCoordinate coord = octreeIterator.getCurrentCell()->getCoordinate();
FPoint position( coord.getX()*boxWidth + boxWidth/2.0 + corner.getX(),
FPoint<FReal> position( coord.getX()*boxWidth + boxWidth/2.0 + corner.getX(),
coord.getY()*boxWidth + boxWidth/2.0 + corner.getY(),
coord.getZ()*boxWidth + boxWidth/2.0 + corner.getZ());
octreeIterator.getCurrentCell()->setPosition(position.getDataValue());
......
......@@ -26,29 +26,29 @@
////////////////////// Opérateurs FMM Kernel : //////////////////////////
class KernelCell : public FBasicCell {
FComplex* multipole;
FComplex* local;
FComplex<FReal>* multipole;
FComplex<FReal>* local;
public:
KernelCell() : multipole(nullptr), local(nullptr){
}
void attachArrays(FComplex inMultipole[], FComplex inLocal[]){
void attachArrays(FComplex<FReal> inMultipole[], FComplex<FReal> inLocal[]){
multipole = inMultipole;
local = inLocal;
}
const FComplex* getMultipole() const{
const FComplex<FReal>* getMultipole() const{
return multipole;
}
const FComplex* getLocal() const{
const FComplex<FReal>* getLocal() const{
return local;
}
FComplex* getMultipole(){
FComplex<FReal>* getMultipole(){
return multipole;
}
FComplex* getLocal(){
FComplex<FReal>* getLocal(){
return local;
}
};
......@@ -57,8 +57,8 @@ public:
static const int P = 5;
typedef KernelCell KernelCellClass;
typedef FP2PParticleContainer<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FP2PParticleContainer<FReal> ContainerClass;
typedef FSimpleLeaf<FReal, ContainerClass > LeafClass;
typedef FRotationKernel< KernelCellClass, ContainerClass , P> KernelClass;
struct ScalFmmKernelHandle {
......@@ -82,7 +82,7 @@ int FmmKernel_init(void *fmmCore, void **fmmKernel){
FmmCore_getParameter(fmmCore, FMMCORE_THREADS_NUMBER, &kernelhandle->nbthread);
KernelClass original( NbLevels, boxWidth, FPoint(centerOfBox) );
KernelClass original( NbLevels, boxWidth, FPoint<FReal>(centerOfBox) );
kernelhandle->kernel = new KernelClass*[kernelhandle->nbthread];
for(int idxThread = 0 ; idxThread < kernelhandle->nbthread ; ++idxThread){
kernelhandle->kernel[idxThread] = new KernelClass(original);
......@@ -184,12 +184,12 @@ int FmmKernel_getParameter(void *fmmKernel, int name, void*value){
/****** Données FMM : *****/
int FmmKernel_getMultipoleArraySize(void */*fmmCore*/, int *size) {
*size = ((P+2)*(P+1))/2 * sizeof(FComplex);
*size = ((P+2)*(P+1))/2 * sizeof(FComplex<FReal>);
return FMMAPI_NO_ERROR;
} /* Renvoie dans size la taille (en octets) de l'expansion multipôle associée à la boîte boxId */
int FmmKernel_getLocalArraySize(void */*fmmCore*/, int *size){
*size = ((P+2)*(P+1))/2 * sizeof(FComplex);
*size = ((P+2)*(P+1))/2 * sizeof(FComplex<FReal>);
return FMMAPI_NO_ERROR;
} /* Renvoie dans size la taille (en octets) de l'expansion locale associée à la boîte boxId*/
......@@ -201,7 +201,7 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FComplex* multipole;
FComplex<FReal>* multipole;
FmmCore_getMultipoleArray(fmmCore, boxId, (void**)&multipole);
KernelCellClass cell;
......@@ -215,9 +215,9 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){
int number;
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&physicalValues, &number);
FP2PParticleContainer<> sources;
FP2PParticleContainer<FReal> sources;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
sources.push(FPoint(positions[idxPart*3],positions[idxPart*3+1],positions[idxPart*3+2]),physicalValues[idxPart]);
sources.push(FPoint<FReal>(positions[idxPart*3],positions[idxPart*3+1],positions[idxPart*3+2]),physicalValues[idxPart]);
}
kernelhandle->kernel[threadId]->P2M(&cell, &sources);
......@@ -233,7 +233,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FComplex* local;
FComplex<FReal>* local;
FmmCore_getLocalArray(fmmCore, boxId, (void**)&local);
KernelCellClass cell;
......@@ -250,9 +250,9 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){
FReal* fields = new FReal[number*kernelhandle->fieldDataSize];
FmmCore_getTargetField(fmmCore, boxId, fields);
FP2PParticleContainer<> targets;
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
targets.push(FPoint(&positions[idxPart*3]),physicalValues[idxPart],
targets.push(FPoint<FReal>(&positions[idxPart*3]),physicalValues[idxPart],
fields[idxPart*kernelhandle->fieldDataSize],
fields[idxPart*kernelhandle->fieldDataSize+1],
fields[idxPart*kernelhandle->fieldDataSize+2],
......@@ -286,7 +286,7 @@ int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon){
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FComplex* multipole;
FComplex<FReal>* multipole;
FmmCore_getMultipoleArray(fmmCore, boxIdFather, (void**)&multipole);
KernelCellClass cellFather;
......@@ -322,7 +322,7 @@ int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon){
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FComplex* local;
FComplex<FReal>* local;
FmmCore_getLocalArray(fmmCore, boxIdFather, (void**)&local);
KernelCellClass cellFather;
......@@ -358,7 +358,7 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FComplex* multipole;
FComplex<FReal>* multipole;
FmmCore_getMultipoleArray(fmmCore, boxIdSrc, (void**)&multipole);
KernelCellClass cellSrc;
cellSrc.attachArrays(multipole,nullptr);
......@@ -366,7 +366,7 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){
FmmCore_getCoord(fmmCore, boxIdSrc, coord);
cellSrc.setCoordinate(coord[0], coord[1], coord[2]);
FComplex* local;
FComplex<FReal>* local;
FmmCore_getLocalArray(fmmCore, boxIdDest, (void**)&local);
KernelCellClass cellDst;
cellDst.attachArrays(nullptr, local);
......@@ -408,9 +408,9 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){
FmmCore_getCoord(fmmCore, boxIdSrcDest, coordTargets);
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
FP2PParticleContainer<> targets;
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
targets.push(FPoint(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1],
......@@ -419,8 +419,8 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){
}
FP2PParticleContainer<>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<>*) * 27);
FP2PParticleContainer<FReal>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<FReal>*) * 27);
kernelhandle->kernel[threadId]->P2P(treecoord, &targets, &targets, ptrs, 0);
const FReal*const potentials = targets.getPotentials();
......@@ -460,9 +460,9 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA
FmmCore_getCoord(fmmCore, boxIdDest, coordTargets);
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
FP2PParticleContainer<> targets;
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
targets.push(FPoint(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1],
......@@ -475,13 +475,13 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA
int numberSources;
FmmCore_getSource(fmmCore, boxIdSrc, &positionsSrc, (void**)&potentialsSrc, &numberSources);
FP2PParticleContainer<> sources;
FP2PParticleContainer<FReal> sources;
for(int idxPart = 0 ; idxPart < numberSources ; ++idxPart){
sources.push(FPoint(positionsSrc[idxPart*3],positionsSrc[idxPart*3+1],positionsSrc[idxPart*3+2]),potentialsSrc[idxPart]);
sources.push(FPoint<FReal>(positionsSrc[idxPart*3],positionsSrc[idxPart*3+1],positionsSrc[idxPart*3+2]),potentialsSrc[idxPart]);
}
FP2PParticleContainer<>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<>*) * 27);
FP2PParticleContainer<FReal>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<FReal>*) * 27);
ptrs[0] = &sources;
kernelhandle->kernel[threadId]->P2PRemote(treecoord, &targets, &targets, ptrs, 1);
......
......@@ -37,7 +37,7 @@ int main(int argc, char ** argv){
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
FRandomLoader loader(NbPart, 1, FPoint(0.5,0.5,0.5), 1);
FRandomLoader<FReal> loader(NbPart, 1, FPoint<FReal>(0.5,0.5,0.5), 1);
void* FmmCoreHandle;
FmmCore_init(&FmmCoreHandle);
......@@ -64,7 +64,7 @@ int main(int argc, char ** argv){
FReal* positions = new FReal[nbPart*3];
{
FPoint part;
FPoint<FReal> part;
const FReal physicalValue = 0.1;
for(int idx = 0 ; idx < nbPart ; ++idx){
......@@ -157,8 +157,8 @@ int main(int argc, char ** argv){
std::cout << "Comparing results ..." << std::endl;
counter.tic();
FMath::FAccurater forces;
FMath::FAccurater potential;
FMath::FAccurater<FReal> forces;
FMath::FAccurater<FReal> potential;
for(int idx = 0 ; idx < nbPart ; ++idx){
if(idx < 10){
......
......@@ -94,23 +94,22 @@ int main(int argc, char* argv[])
// open particle file
////////////////////////////////////////////////////////////////////
//
FFmaGenericLoader loader(filename);
typedef double FReal;
FFmaGenericLoader<FReal> loader(filename);
//
////////////////////////////////////////////////////////////////////
// begin Chebyshev kernel
// accuracy
const unsigned int ORDER = 7;
// typedefs
typedef FP2PParticleContainerIndexed<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FChebCell<ORDER> CellClass;
typedef FOctree<CellClass,ContainerClass,LeafClass> OctreeClass;
typedef FP2PParticleContainerIndexed<FReal> ContainerClass;
typedef FSimpleLeaf<FReal, ContainerClass > LeafClass;
typedef FChebCell<FReal,ORDER> CellClass;