Commit 90e8f721 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Use FSize when it is related to particles

parent e8f3b15a
......@@ -48,7 +48,7 @@ void Scalfmm_dealloc_handle(Scalfmm_Handle handle, Callback_free_cell cellDestro
//< The indexes are the one used on the particles operator
//< The position of the particles should be composed of one triple per particle:
//< xyzxyzxyz...
void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbParticles, int* particleIndexes, double* particleXYZ);
void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, FSize nbParticles, int* particleIndexes, double* particleXYZ);
//< To insert one particle only
void Scalfmm_one_particle(Scalfmm_Handle handle, int particleIndexe, double x, double y, double z);
......@@ -62,13 +62,13 @@ void Scalfmm_init_cell(Scalfmm_Handle handle, Callback_init_cell cellInitializer
///////////////////////////////////////////////////////////////////////////
//< These function are the callbacks of the FMM operators
typedef void (*Callback_P2M)(void* leafCell, int nbParticles, const int* particleIndexes, void* userData);
typedef void (*Callback_P2M)(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData);
typedef void (*Callback_M2M)(int level, void* parentCell, int childPosition, void* childCell, void* userData);
typedef void (*Callback_M2L)(int level, void* targetCell, int sourceCellPosition, void* sourceCell, void* userData);
typedef void (*Callback_L2L)(int level, void* parentCell, int childPosition, void* childCell, void* userData);
typedef void (*Callback_L2P)(void* leafCell, int nbParticles, int* particleIndexes, void* userData);
typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData);
typedef void (*Callback_P2PInner)(int nbParticles, int* particleIndexes, void* userData);
typedef void (*Callback_L2P)(void* leafCell, FSize nbParticles, int* particleIndexes, void* userData);
typedef void (*Callback_P2P)(FSize nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData);
typedef void (*Callback_P2PInner)(FSize nbParticles, int* particleIndexes, void* userData);
//< This structure should be filled (or filled with null) to call the FMM
struct Scalfmm_Kernel_Descriptor {
......
......@@ -362,7 +362,7 @@ void scalfmm_algorithm_config(scalfmm_handle Handle,scalfmm_algorithm config);
* @param particleIndexes indexes of particles currently computed
* @param userData datas specific to the user's kernel
*/
typedef void (*Callback_P2M)(void* leafCell, int nbParticles, const int* particleIndexes, void* userData);
typedef void (*Callback_P2M)(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData);
/**
* @brief Function to be filled by user's M2M
......@@ -411,7 +411,7 @@ typedef void (*Callback_L2L)(int level, void* parentCell, int childPosition, voi
* @param particleIndexes indexes of particles currently computed
* @param userData datas specific to the user's kernel
*/
typedef void (*Callback_L2P)(void* leafCell, int nbParticles,const int* particleIndexes, void* userData);
typedef void (*Callback_L2P)(void* leafCell, FSize nbParticles,const int* particleIndexes, void* userData);
/**
* @brief Function to be filled by user's P2P
......@@ -421,7 +421,7 @@ typedef void (*Callback_L2P)(void* leafCell, int nbParticles,const int* particle
* @param sourceParticleIndexes indexes of cource particles currently computed
* @param userData datas specific to the user's kernel
*/
typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData);
typedef void (*Callback_P2P)(FSize nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData);
/**
* @brief Function to be filled by user's P2P
......@@ -432,7 +432,7 @@ typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nb
* @param sourceNbPart array containing the number of part in each neighbors
* @param userData datas specific to the user's kernel
*/
typedef void (*Callback_P2PFull)(int nbParticles, const int* particleIndexes,
typedef void (*Callback_P2PFull)(FSize nbParticles, const int* particleIndexes,
const int * sourceParticleIndexes[27],int sourceNbPart[27], void* userData);
......@@ -442,7 +442,7 @@ typedef void (*Callback_P2PFull)(int nbParticles, const int* particleIndexes,
* @param particleIndexes indexes of particles currently computed
* @param userData datas specific to the user's kernel
*/
typedef void (*Callback_P2PInner)(int nbParticles, const int* particleIndexes, void* userData);
typedef void (*Callback_P2PInner)(FSize nbParticles, const int* particleIndexes, void* userData);
......
This diff is collapsed.
......@@ -126,7 +126,7 @@ extern "C" void ChebKernelStruct_free(void *inKernel){
}
extern "C" void ChebKernel_P2M(void * leafCell, int nbParticles, const int *particleIndexes, void * inKernel){
extern "C" void ChebKernel_P2M(void * leafCell, FSize nbParticles, const int *particleIndexes, void * inKernel){
//make temporary array of parts
FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>();
tempContainer->reserve(nbParticles);
......@@ -215,7 +215,7 @@ extern "C" void ChebKernel_L2L(int level, void* parentCell, int childPosition, v
childChebCell->getLocal(0));
}
extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* particleIndexes, void* inKernel){
extern "C" void ChebKernel_L2P(void* leafCell, FSize nbParticles, const int* particleIndexes, void* inKernel){
//Create temporary FSimpleLeaf
FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>();
tempContainer->reserve(nbParticles);
......@@ -242,8 +242,8 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
//Then retrieve the results
double * forcesToFill = reinterpret_cast<UserData *>(inKernel)->forcesComputed[id_thread];
const FVector<int>& indexes = tempContainer->getIndexes();
for(int idxPart = 0 ; idxPart<nbParticles ; ++idxPart){
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(FSize idxPart = 0 ; idxPart<nbParticles ; ++idxPart){
forcesToFill[indexes[idxPart]*3+0] += tempContainer->getForcesX()[idxPart];
forcesToFill[indexes[idxPart]*3+1] += tempContainer->getForcesY()[idxPart];
forcesToFill[indexes[idxPart]*3+2] += tempContainer->getForcesZ()[idxPart];
......@@ -254,7 +254,7 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
}
void ChebKernel_P2P(int nbParticles, const int* particleIndexes,
void ChebKernel_P2P(FSize nbParticles, const int* particleIndexes,
const int * sourceParticleIndexes[27],int sourceNbPart[27],void* inKernel){
//Create temporary FSimpleLeaf for target
......@@ -306,8 +306,8 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
//get back forces
double * forcesToFill = reinterpret_cast<UserData *>(inKernel)->forcesComputed[id_thread];
const FVector<int>& indexes = tempContTarget->getIndexes();
for(int idxPart = 0 ; idxPart<nbParticles ; ++idxPart){
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(FSize idxPart = 0 ; idxPart<nbParticles ; ++idxPart){
forcesToFill[indexes[idxPart]*3+0] += tempContTarget->getForcesX()[idxPart];
forcesToFill[indexes[idxPart]*3+1] += tempContTarget->getForcesY()[idxPart];
forcesToFill[indexes[idxPart]*3+2] += tempContTarget->getForcesZ()[idxPart];
......@@ -316,7 +316,7 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti
//Note that sources are also modified.
//get back sources forces
for(int idSource = 0 ; idSource < 27 ; ++idSource){
const FVector<int>& indexes = tempContSources[idSource]->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
const int nbPartInSource = sourceNbPart[idSource];
for(int idxSourcePart = 0; idxSourcePart < nbPartInSource ; ++idxSourcePart){
forcesToFill[indexes[idxSourcePart]*3+0] += tempContSources[idSource]->getForcesX()[idxSourcePart];
......
......@@ -276,9 +276,9 @@ public:
void get_positions_xyz(int NbPositions, double * positionsToFill){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
positionsToFill[indexes[idxPart]*3+0] = sources->getPositions()[0][idxPart];
positionsToFill[indexes[idxPart]*3+1] = sources->getPositions()[1][idxPart];
positionsToFill[indexes[idxPart]*3+2] = sources->getPositions()[2][idxPart];
......@@ -289,9 +289,9 @@ public:
void get_positions_xyz_npart(int NbPositions, int * idxOfParticles, double * positionsToFill){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
int iterPart = 0;
bool notFoundYet = true;
while(iterPart < NbPositions && notFoundYet){
......@@ -312,9 +312,9 @@ public:
void get_positions( int NbPositions, double * X, double * Y , double * Z){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
X[indexes[idxPart]] = sources->getPositions()[0][idxPart];
Y[indexes[idxPart]] = sources->getPositions()[1][idxPart];
Z[indexes[idxPart]] = sources->getPositions()[2][idxPart];
......@@ -325,9 +325,9 @@ public:
void get_positions_npart(int NbPositions, int * idxOfParticles,double * X, double * Y , double * Z){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
int iterPart = 0;
bool notFoundYet = true;
while(iterPart < NbPositions && notFoundYet){
......@@ -352,9 +352,9 @@ public:
void add_to_positions_xyz(int NbPositions,double * updatedXYZ){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
sources->getWPositions()[0][idxPart] += updatedXYZ[indexes[idxPart]*3+0];
sources->getWPositions()[1][idxPart] += updatedXYZ[indexes[idxPart]*3+1];
sources->getWPositions()[2][idxPart] += updatedXYZ[indexes[idxPart]*3+2];
......@@ -365,9 +365,9 @@ public:
void add_to_positions(int NbPositions,double * X, double * Y , double * Z){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
sources->getWPositions()[0][idxPart] += X[indexes[idxPart]];
sources->getWPositions()[1][idxPart] += Y[indexes[idxPart]];
sources->getWPositions()[2][idxPart] += Z[indexes[idxPart]];
......@@ -379,9 +379,9 @@ public:
void set_positions_xyz(int NbPositions, double * updatedXYZ){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
sources->getWPositions()[0][idxPart] = updatedXYZ[indexes[idxPart]*3+0];
sources->getWPositions()[1][idxPart] = updatedXYZ[indexes[idxPart]*3+1];
sources->getWPositions()[2][idxPart] = updatedXYZ[indexes[idxPart]*3+2];
......@@ -392,9 +392,9 @@ public:
void set_positions(int NbPositions, double * X, double * Y, double * Z){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
const FVector<int>& indexes = sources->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
int nbPartThere = sources->getNbParticles();
for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
sources->getWPositions()[0][idxPart] = X[indexes[idxPart]];
sources->getWPositions()[1][idxPart] = Y[indexes[idxPart]];
sources->getWPositions()[2][idxPart] = Z[indexes[idxPart]];
......
......@@ -226,9 +226,9 @@ extern "C" void Scalfmm_dealloc_handle(Scalfmm_Handle handle, Callback_free_cell
}
// Insert a full array of particles. Posisions are xyz.xyz.xyz...
extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbParticles, int* particleIndexes, double* particleXYZ){
extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, FSize nbParticles, int* particleIndexes, double* particleXYZ){
ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)handle;
for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
corehandle->octree->insert(FPoint<FReal>(particleXYZ[idxPart*3],particleXYZ[idxPart*3+1],particleXYZ[idxPart*3+2]),
particleIndexes[idxPart]);
}
......
......@@ -88,13 +88,13 @@ struct MyData {
// Our P2M
void my_Callback_P2M(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){
void my_Callback_P2M(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2M += 1;
struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData;
VerbosePrint("Cell morton %lld is doing P2M with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -152,13 +152,13 @@ void my_Callback_L2L(int level, void* cellData, int childPosition, void* childDa
// JUST-PUT-HERE: Your L2L
}
void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, int* particleIndexes, void* userData){
void my_Callback_L2P(void* cellData, FSize nbParticlesInLeaf, int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countL2P += 1;
struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData;
VerbosePrint("Cell morton %lld is doing L2P with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -167,12 +167,12 @@ void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, int* particleIndexes
}
}
void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbParticlesInSrc, const int* particleIndexesSrc, void* userData){
void my_Callback_P2P(FSize nbParticlesInLeaf, const int* particleIndexes, FSize nbParticlesInSrc, const int* particleIndexesSrc, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2P += 1;
VerbosePrint("Doing P2P between two leaves of %d particles and %d particles :\n", nbParticlesInLeaf, nbParticlesInSrc);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t Target >> particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -189,12 +189,12 @@ void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbPa
// interacting with the target particles
}
void my_Callback_P2PInner(int nbParticlesInLeaf, int* particleIndexes, void* userData){
void my_Callback_P2PInner(FSize nbParticlesInLeaf, int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2PInner += 1;
VerbosePrint("Doing P2P inside a leaf of %d particles :\n", nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -217,12 +217,12 @@ int main(int argc, char ** argv){
boxCenter[0] = boxCenter[1] = boxCenter[2] = 0.0;
// Create random particles
int nbParticles = 10;
FSize nbParticles = 10;
int particleIndexes[nbParticles];
double particleXYZ[nbParticles*3];
{
printf("Creating Particles:\n");
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
particleIndexes[idxPart] = idxPart;
particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0];
......
......@@ -34,7 +34,7 @@ void cheb_free_cell(void * inCell){
* @brief Wrapper to FMM operators (refer to CScalfmmApi.h to get the
* detailed descriptions)
*/
void cheb_p2m(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){
void cheb_p2m(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){
ChebKernel_P2M(cellData,nbParticlesInLeaf,particleIndexes,userData);
}
void cheb_m2m(int level, void* parentCell, int childPosition, void* childCell, void* userData){
......@@ -46,10 +46,10 @@ void cheb_m2l_full(int level, void* targetCell, void* sourceCell[343], void* use
void cheb_l2l(int level, void* parentCell, int childPosition, void* childCell, void* userData){
ChebKernel_L2L( level, parentCell, childPosition, childCell, userData);
}
void cheb_l2p(void* leafCell, int nbParticles, const int* particleIndexes, void* userData){
void cheb_l2p(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData){
ChebKernel_L2P( leafCell, nbParticles, particleIndexes, userData);
}
void cheb_p2pFull(int nbParticles, const int* particleIndexes,
void cheb_p2pFull(FSize nbParticles, const int* particleIndexes,
const int * sourceParticleIndexes[27], int sourceNbPart[27],void* userData) {
ChebKernel_P2P(nbParticles, particleIndexes, sourceParticleIndexes, sourceNbPart, userData);
}
......@@ -131,7 +131,7 @@ int main(int argc, char ** av){
{
printf("Creating Particles:\n");
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbPart ; ++idxPart){
particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0];
particleXYZ[idxPart*3+1] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[1];
......@@ -146,7 +146,7 @@ int main(int argc, char ** av){
//format in order to verify numercal results
/* FILE * fd = fopen("input.fma","w"); */
/* fprintf(fd,"8\t 4\n %d\n %f\t %f\t %f\t %f\n",nbPart,boxWidth/2.0, boxCenter[0],boxCenter[1],boxCenter[2]); */
/* int idxPart; */
/* FSize idxPart; */
/* for(idxPart=0 ; idxPart<nbPart ; ++idxPart){ */
/* fprintf(fd,"%e\t %e\t %e\t %e \n", */
/* particleXYZ[idxPart*3], */
......@@ -238,7 +238,7 @@ int main(int argc, char ** av){
//Reduction on forces array
{
int idxPart;
FSize idxPart;
for(idThreads=1 ; idThreads<nb_threads ; ++idThreads){
for(idxPart=0 ; idxPart<nbPart*3 ; ++idxPart){
//Everything is stored in first array
......@@ -265,7 +265,7 @@ int main(int argc, char ** av){
memset(forcesRef,0,sizeof(double)*3*nbPart);
scalfmm_get_forces_xyz(handle_ref,nbPart,forcesRef);
{//Comparison part
int idxPart;
FSize idxPart;
int nbPartOkay = 0;
for(idxPart=0 ; idxPart<nbPart ; ++idxPart ){
double diffX,diffY,diffZ;
......
......@@ -37,7 +37,7 @@ int main(int argc, char ** av){
scalfmm_algorithm_config(handle,periodic);
//Creation of an array of particles
int nb_of_parts = 2;
int idxPart;
FSize idxPart;
double * positionsXYZ = malloc(sizeof(double)*3*nb_of_parts);
memset(positionsXYZ,0,sizeof(double)*3*nb_of_parts);
......
......@@ -88,13 +88,13 @@ struct MyData {
// Our P2M
void my_Callback_P2M(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){
void my_Callback_P2M(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2M += 1;
struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData;
VerbosePrint("Cell morton %lld is doing P2M with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -152,13 +152,13 @@ void my_Callback_L2L(int level, void* cellData, int childPosition, void* childDa
// JUST-PUT-HERE: Your L2L
}
void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){
void my_Callback_L2P(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countL2P += 1;
struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData;
VerbosePrint("Cell morton %lld is doing L2P with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -167,12 +167,12 @@ void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, const int* particleI
}
}
void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbParticlesInSrc, const int* particleIndexesSrc, void* userData){
void my_Callback_P2P(FSize nbParticlesInLeaf, const int* particleIndexes, FSize nbParticlesInSrc, const int* particleIndexesSrc, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2P += 1;
VerbosePrint("Doing P2P between two leaves of %d particles and %d particles :\n", nbParticlesInLeaf, nbParticlesInSrc);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t Target >> particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -189,12 +189,12 @@ void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbPa
// interacting with the target particles
}
void my_Callback_P2PInner(int nbParticlesInLeaf, const int* particleIndexes, void* userData){
void my_Callback_P2PInner(FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){
struct MyData* my_data = (struct MyData*)userData;
my_data->countP2PInner += 1;
VerbosePrint("Doing P2P inside a leaf of %d particles :\n", nbParticlesInLeaf);
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3];
VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart],
......@@ -217,12 +217,12 @@ int main(int argc, char ** argv){
boxCenter[0] = boxCenter[1] = boxCenter[2] = 0.0;
// Create random particles
int nbParticles = 10;
FSize nbParticles = 10;
int particleIndexes[nbParticles];
double particleXYZ[nbParticles*3];
{
printf("Creating Particles:\n");
int idxPart;
FSize idxPart;
for(idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
particleIndexes[idxPart] = idxPart;
particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0];
......
......@@ -539,7 +539,7 @@ int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) {
omp_set_num_threads(corehandle->config.nbThreads);
}
for(int idxPart = 0 ; idxPart < (*nb) ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < (*nb) ; ++idxPart){
const FReal* pos = &position[idxPart * 3];
corehandle->octree->insert(FPoint<FReal>(pos[0], pos[1], pos[2]),idxPart);
}
......
......@@ -216,7 +216,7 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&physicalValues, &number);
FP2PParticleContainer<FReal> sources;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){
sources.push(FPoint<FReal>(positions[idxPart*3],positions[idxPart*3+1],positions[idxPart*3+2]),physicalValues[idxPart]);
}
......@@ -251,7 +251,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){
FmmCore_getTargetField(fmmCore, boxId, fields);
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){
targets.push(FPoint<FReal>(&positions[idxPart*3]),physicalValues[idxPart],
fields[idxPart*kernelhandle->fieldDataSize],
fields[idxPart*kernelhandle->fieldDataSize+1],
......@@ -266,7 +266,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){
fields[idxPart*kernelhandle->fieldDataSize] += potentials[idxPart];
fields[idxPart*kernelhandle->fieldDataSize+1] += forcesX[idxPart];
fields[idxPart*kernelhandle->fieldDataSize+2] += forcesY[idxPart];
......@@ -409,7 +409,7 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
......@@ -428,7 +428,7 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart];
......@@ -461,7 +461,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
FP2PParticleContainer<FReal> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
......@@ -476,7 +476,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA
FmmCore_getSource(fmmCore, boxIdSrc, &positionsSrc, (void**)&potentialsSrc, &numberSources);
FP2PParticleContainer<FReal> sources;
for(int idxPart = 0 ; idxPart < numberSources ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < numberSources ; ++idxPart){
sources.push(FPoint<FReal>(positionsSrc[idxPart*3],positionsSrc[idxPart*3+1],positionsSrc[idxPart*3+2]),potentialsSrc[idxPart]);
}
......@@ -490,7 +490,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart];
......
......@@ -59,7 +59,7 @@ int main(int argc, char ** argv){
std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl;
counter.tic();
int nbPart = (int)loader.getNumberOfParticles();
FSize r.getNumberOfParticles();
FReal* potentials = new FReal[nbPart];
FReal* positions = new FReal[nbPart*3];
......
......@@ -129,7 +129,7 @@ int main(int argc, char* argv[])
FPoint<FReal> position;
FReal physicalValue = 0.0;
//
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
//
// Read particle per particle from file
loader.fillParticle(&position,&physicalValue);
......@@ -172,7 +172,7 @@ int main(int argc, char* argv[])
//
//
{ // -----------------------------------------------------
long int N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ;
FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ;
FReal energy =0.0 ;
//
// Loop over all leaves
......@@ -190,13 +190,13 @@ int main(int argc, char* argv[])
const FReal*const forcesX = leaf->getTargets()->getForcesX();
const FReal*const forcesY = leaf->getTargets()->getForcesY();
const FReal*const forcesZ = leaf->getTargets()->getForcesZ();
const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues();
const FVector<int>& indexes = leaf->getTargets()->getIndexes();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const int indexPartOrig = indexes[idxPart];
for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const FSize indexPartOrig = indexes[idxPart];
if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) {
std::cout << "Index "<< indexPartOrig <<" potential " << potentials[idxPart]