Commit b2be4187 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

API's working again, and reset_cell mechanism is split into apply_on_cell and apply_on_leaf.

parent 74f47c5a
......@@ -170,7 +170,7 @@ typedef void (*Callback_copy_cell)(void * userDatas, FSize size, void * memoryAl
* @param userData cell user data
* @param userData Kernel user data
*/
typedef void (*Callback_finalize_leaf)(int level, FSize nbParts, const FSize * idxParts, long long morton_index, double center[3],
typedef void (*Callback_apply_on_leaf)(int level, FSize nbParts, const FSize * idxParts, long long morton_index, double center[3],
void * cellDatas,void * leafDatas, void * userDatas);
/**
......@@ -608,7 +608,7 @@ typedef void (*Callback_P2PSym)(void * targetLeaf, FSize nbParticles, const FSiz
* @param spatial_position double[3] center of the cell
* @param usercell ptr to user's cell
*/
typedef void (*Callback_reset_cell)(int level, long long morton_index, int* tree_position, double* spatial_position, void * userCell, void * userData);
typedef void (*Callback_apply_on_cell)(int level, long long morton_index, int* tree_position, double* spatial_position, void * userCell, void * userData);
/**
* @brief Structure containing callbacks to fill in order to define
......@@ -667,7 +667,7 @@ void scalfmm_execute_fmm(scalfmm_handle Handle);
* called after insert_parts.
* @param
*/
void scalfmm_apply_on_leaf(scalfmm_handle Handle, Callback_finalize_leaf function);
void scalfmm_apply_on_leaf(scalfmm_handle Handle, Callback_apply_on_leaf function);
/////////////////////////////////////////////////////////////////////
......@@ -689,11 +689,10 @@ void scalfmm_apply_on_leaf(scalfmm_handle Handle, Callback_finalize_leaf functio
void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell cellDestroyer);
/**
* @brief this function reset all the data of the tree. (i e multipole
* and local development, forces and potentials)
* @brief This function apply the function param on each cell of the octree
* @param Handle scalfmm_handle provided by scalfmm_init.
*/
void scalfmm_reset_tree(scalfmm_handle handle, Callback_reset_cell cellReseter);
void scalfmm_apply_on_cell(scalfmm_handle handle, Callback_apply_on_cell function);
/////////////////////////////////////////////////////////////////////
/////////////// Monitoring functions /////////////////
......
......@@ -716,8 +716,9 @@ public:
}
//Simple call to FScalFMMEngine method with good template
void reset_tree(Callback_reset_cell /*not used*/){
FScalFMMEngine<FReal>::template generic_reset_tree<ContainerClass,InterCell,LeafClass>(octree);
void apply_on_cell(Callback_apply_on_cell /*not used*/){
//We used this one to clean the Cehb cell in the user defined cheb kernel situation.
FScalFMMEngine<FReal>::template generic_apply_on_cell<ContainerClass,InterCell,LeafClass>(octree);
}
......
......@@ -173,7 +173,7 @@ public:
virtual void set_potentials_npart( int nbParts, int* idxOfParticles, FReal * potentialsToRead, PartType type){
FAssertLF(0,"No tree instancied, exiting ...\n");
}
virtual void apply_on_each_leaf(Callback_finalize_leaf function){
virtual void apply_on_each_leaf(Callback_apply_on_leaf function){
FAssertLF(0,"No tree instancied, exiting ...\n");
}
......@@ -771,11 +771,11 @@ public:
}
}
virtual void reset_tree(Callback_reset_cell cellReset){
virtual void apply_on_cell(Callback_apply_on_cell function){
}
template<class ContainerClass, class CellClass, class LeafClass>
void generic_reset_tree(FOctree<FReal,CellClass,ContainerClass,LeafClass> * tree){
void generic_apply_on_cell(FOctree<FReal,CellClass,ContainerClass,LeafClass> * tree){
//Reset forces and potentials
tree->forEachLeaf([&](LeafClass * leaf){
ContainerClass * targets = leaf->getTargets();
......@@ -1057,8 +1057,8 @@ extern "C" void scalfmm_utils_interactionPosition(int interactionPosition, int*
}
extern "C" void scalfmm_reset_tree(scalfmm_handle Handle, Callback_reset_cell cellReseter){
((ScalFmmCoreHandle<double> * ) Handle)->engine->reset_tree(cellReseter);
extern "C" void scalfmm_apply_on_cell(scalfmm_handle Handle, Callback_apply_on_cell function){
((ScalFmmCoreHandle<double> * ) Handle)->engine->apply_on_cell(function);
}
extern "C" void scalfmm_print_everything(scalfmm_handle Handle){
......@@ -1069,7 +1069,7 @@ extern "C" void scalfmm_set_upper_limit(scalfmm_handle Handle, int upperLimit){
((ScalFmmCoreHandle<double> * ) Handle)->engine->set_upper_limit(upperLimit);
}
extern "C" void scalfmm_apply_on_leaf(scalfmm_handle Handle, Callback_finalize_leaf function){
extern "C" void scalfmm_apply_on_leaf(scalfmm_handle Handle, Callback_apply_on_leaf function){
((ScalFmmCoreHandle<double> * ) Handle)->engine->apply_on_each_leaf(function);
}
......
......@@ -386,7 +386,7 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes, const FSize
//Empty tree coordinate
int coord[3] = {0,0,0};
inKernelStruct->kernel[id_thread]->P2P(FTreeCoordinate(coord),tempContTarget,nullptr,tempContSources,sourcePosition,size);
inKernelStruct->kernel[id_thread]->P2P(FTreeCoordinate(coord),tempContTarget,tempContTarget,tempContSources,sourcePosition,size);
//get back forces & potentials
double * forcesToFill = reinterpret_cast<UserData *>(inKernel)->forcesComputed[id_thread];
......
......@@ -637,7 +637,7 @@ public:
});
}
void apply_on_each_leaf(Callback_finalize_leaf function){
void apply_on_each_leaf(Callback_apply_on_leaf function){
if(octreeDist){
FUserKernelEngine<FReal,LeafClass>::template generic_apply_on_each_leaf<ContainerClass,CoreCellDist>(octreeDist,kernel->getUserKernelDatas(),function);
}else{
......
......@@ -335,7 +335,7 @@ public:
this->octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint<FReal>(BoxCenter));
}
void reset_tree(Callback_reset_cell cellReset){
void apply_on_cell(Callback_apply_on_cell function){
double boxwidth = octree->getBoxWidth();
//apply user function reset on each user's cell
octree->forEachCellWithLevel([&](CoreCell * currCell,const int currLevel){
......@@ -347,7 +347,7 @@ public:
position[0] = boxCorner.getX() + currCoord.getX()*boxwidth/double(1<<currLevel);
position[1] = boxCorner.getY() + currCoord.getY()*boxwidth/double(1<<currLevel);
position[2] = boxCorner.getZ() + currCoord.getZ()*boxwidth/double(1<<currLevel);
cellReset(currLevel,currMorton,arrayCoord,position,currCell->getContainer(),kernel->getUserKernelDatas());
function(currLevel,currMorton,arrayCoord,position,currCell->getContainer(),kernel->getUserKernelDatas());
}
});
}
......@@ -444,14 +444,14 @@ public:
FScalFMMEngine<FReal>::template generic_set_positions_npart<ContainerClass,LeafClass,CoreCell>(octree,NbPositions,idxOfParticles,X,Y,Z,type);
}
virtual void apply_on_each_leaf(Callback_finalize_leaf function){
virtual void apply_on_each_leaf(Callback_apply_on_leaf function){
generic_apply_on_each_leaf<ContainerClass,CoreCell>(octree,kernel->getUserKernelDatas(),function);
}
template<class ContainerClass,class CellClass>
void generic_apply_on_each_leaf(FOctree<FReal,CellClass,ContainerClass,LeafClass>* octreeIn,
void * kernelUserData,
Callback_finalize_leaf function){
Callback_apply_on_leaf function){
if(octreeIn){
octreeIn->forEachCellLeaf([&](CoreCell * currCell, LeafClass * leaf){
int lvl = octreeIn->getHeight();
......
......@@ -99,13 +99,13 @@ void on_leaf(int level, FSize nbParts, const FSize * idxParts, long long morton_
* @param number of particle (no default value)
*/
int main(int argc, char ** av){
omp_set_num_threads(1);
//omp_set_num_threads(1);
printf("Start\n");
if(argc<2){
printf("Use : %s nb_part (optionnal : TreeHeight) \nexiting\n",av[0]);
exit(0);
}
int nbPart= atoi(av[1]);
int nbPart= atoi(av[1]);;
int treeHeight = 5 ;
if(argc>2){
int treeHeight = atoi(av[2]);
......@@ -125,12 +125,9 @@ int main(int argc, char ** av){
printf("Creating Particles:\n");
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];
particleXYZ[idxPart*3+2] = (random()/(double)(RAND_MAX))*boxWidth
- boxWidth/2 + boxCenter[2];
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];
particleXYZ[idxPart*3+2] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[2];
physicalValues[idxPart] = 1.0;
}
}
......@@ -360,8 +357,8 @@ int main(int argc, char ** av){
free(potentialsRef);
//Reset
scalfmm_reset_tree(handle,cheb_resetCell);
scalfmm_reset_tree(handle_ref,NULL);
scalfmm_apply_on_cell(handle,cheb_resetCell);
scalfmm_apply_on_cell(handle_ref,NULL);
printf("Internal resets done \n");
......
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