Commit 28464609 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Fix for chebInterface and hibox

parent 970a66a9
......@@ -447,6 +447,17 @@ typedef void (*Callback_P2PFull)(FSize nbParticles, const FSize* particleIndexes
typedef void (*Callback_P2PInner)(FSize nbParticles, const FSize* particleIndexes, void* userData);
/**
* @brief Function to be filled by user's method to reset a user's cell
* @param level level of the cell.
* @param morton_index morton index of the cell to be allocated.
* @param tree_position int[3] position inside the tree (number of boxes in
* each direction)
* @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);
/**
* @brief Structure containing callbacks to fill in order to define
......@@ -522,7 +533,7 @@ void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell cellDestro
* and local development, forces and potentials)
* @param Handle scalfmm_handle provided by scalfmm_init.
*/
void scalfmm_reset_tree(scalfmm_handle handle);
void scalfmm_reset_tree(scalfmm_handle handle, Callback_reset_cell cellReseter);
/**
* @brief This function shouldn't be there !! display information
......
......@@ -359,7 +359,7 @@ public:
//get back the potentials
void get_potentials( int nbPotentials, double * potentialsToFill){
octree->forEachLeaf([&](LeafClass* leaf){
ContainerClass * sources = leaf->getSrc();
ContainerClass * sources = leaf->getTargets();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
FSize nbPartThere = sources->getNbParticles();
for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){
......@@ -519,7 +519,7 @@ public:
}
//Simple call to FScalFMMEngine method with good template
void reset_tree(){
void reset_tree(Callback_reset_cell /*not used*/){
generic_reset_tree<FReal,ContainerClass,InterCell,LeafClass>(octree);
}
......
......@@ -202,7 +202,7 @@ public:
FAssertLF(0,"No tree instancied, exiting ...\n");
}
virtual void reset_tree(){
virtual void reset_tree(Callback_reset_cell cellReset){
}
template<class FReal,class ContainerClass, class CellClass, class LeafClass>
......@@ -242,6 +242,8 @@ public:
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
virtual void hibox_Rinflu_display(FSize nbPartIn, double *Rinflu){
}
};
......@@ -441,8 +443,12 @@ extern "C" void scalfmm_utils_interactionPosition(int interactionPosition, int*
}
extern "C" void scalfmm_reset_tree(scalfmm_handle Handle){
((ScalFmmCoreHandle * ) Handle)->engine->reset_tree();
extern "C" void scalfmm_reset_tree(scalfmm_handle Handle, Callback_reset_cell cellReseter){
((ScalFmmCoreHandle * ) Handle)->engine->reset_tree(cellReseter);
}
extern "C" void scalfmm_hibox_Rinflu_display(scalfmm_handle Handle, FSize nbPart, double * Rinflu){
((ScalFmmCoreHandle * ) Handle)->engine->hibox_Rinflu_display(nbPart, Rinflu);
}
#endif
......@@ -250,7 +250,7 @@ extern "C" void ChebKernel_L2P(void* leafCell, FSize nbParticles, const FSize* p
forcesToFill[indexes[idxPart]*3+0] += tempContainer->getForcesX()[idxPart];
forcesToFill[indexes[idxPart]*3+1] += tempContainer->getForcesY()[idxPart];
forcesToFill[indexes[idxPart]*3+2] += tempContainer->getForcesZ()[idxPart];
potentialsToFill[indexes[idxPart]] =+ tempContainer->getPotentials()[idxPart];
potentialsToFill[indexes[idxPart]] += tempContainer->getPotentials()[idxPart];
}
delete tempContainer;
......@@ -317,7 +317,7 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes,
forcesToFill[indexes[idxPart]*3+0] += tempContTarget->getForcesX()[idxPart];
forcesToFill[indexes[idxPart]*3+1] += tempContTarget->getForcesY()[idxPart];
forcesToFill[indexes[idxPart]*3+2] += tempContTarget->getForcesZ()[idxPart];
potentialsToFill[indexes[idxPart]] =+ tempContTarget->getPotentials()[idxPart];
potentialsToFill[indexes[idxPart]] += tempContTarget->getPotentials()[idxPart];
}
//Note that sources are also modified.
......@@ -329,7 +329,7 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes,
forcesToFill[indexesSource[idxSourcePart]*3+0] += tempContSources[idSource]->getForcesX()[idxSourcePart];
forcesToFill[indexesSource[idxSourcePart]*3+1] += tempContSources[idSource]->getForcesY()[idxSourcePart];
forcesToFill[indexesSource[idxSourcePart]*3+2] += tempContSources[idSource]->getForcesZ()[idxSourcePart];
potentialsToFill[indexesSource[idxSourcePart]] =+ tempContSources[idSource]->getPotentials()[idxSourcePart];
potentialsToFill[indexesSource[idxSourcePart]] += tempContSources[idSource]->getPotentials()[idxSourcePart];
}
}
......@@ -340,6 +340,10 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes,
delete tempContTarget;
}
void ChebCell_reset(int level, long long morton_index, int* tree_position, double* spatial_position, void * userCell){
ChebCellStruct * cellStruct = reinterpret_cast<ChebCellStruct *>(userCell);
FChebCell<double,7>* chebCell = cellStruct->cell;
chebCell->resetToInitialState();
}
#endif
......@@ -492,6 +492,28 @@ public:
}
void reset_tree(Callback_reset_cell cellReset){
double boxwidth = octree->getBoxWidth();
FPoint<FReal> BoxCenter = octree->getBoxCenter();
double boxCorner[3];
boxCorner[0] = BoxCenter.getX() - boxwidth/2.0;
boxCorner[1] = BoxCenter.getY() - boxwidth/2.0;
boxCorner[2] = BoxCenter.getZ() - boxwidth/2.0;
//apply user function reset on each user's cell
octree->forEachCellWithLevel([&](CoreCell * currCell,const int currLevel){
if(currCell->getContainer()){
FTreeCoordinate currCoord = currCell->getCoordinate();
int arrayCoord[3] = {currCoord.getX(),currCoord.getY(),currCoord.getZ()};
MortonIndex currMorton = currCoord.getMortonIndex(currLevel);
double position[3];
position[0] = boxCorner[0] + currCoord.getX()*boxwidth/double(1<<currLevel);
position[1] = boxCorner[1] + currCoord.getY()*boxwidth/double(1<<currLevel);
position[2] = boxCorner[2] + currCoord.getZ()*boxwidth/double(1<<currLevel);
cellReset(currLevel,currMorton,arrayCoord,position,currCell->getContainer());
}
});
}
void intern_dealloc_handle(Callback_free_cell userDeallocator){
free_cell(userDeallocator);
}
......
......@@ -56,6 +56,8 @@ void ChebKernel_L2P(void* leafCell, FSize nbParticles, const FSize* particleInde
void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes,
const FSize * sourceParticleIndexes[27], FSize sourceNbPart[27],void* userData);
void ChebCell_reset(int level, long long morton_index, int* tree_position, double* spatial_position, void * userCell);
typedef struct myUserDatas{
ChebKernelStruct * kernelStruct;
double * insertedPositions;
......
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