Commit 421e1146 authored by COULAUD Olivier's avatar COULAUD Olivier

Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/scalfmm/scalfmm

# By piacibel
# Via piacibel
* 'master' of git+ssh://scm.gforge.inria.fr//gitroot/scalfmm/scalfmm:
  Add mechanism to reset the tree in the API
parents 1b0d8c7c d151217e
......@@ -517,5 +517,12 @@ void scalfmm_execute_fmm(scalfmm_handle Handle);
*/
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)
* @param Handle scalfmm_handle provided by scalfmm_init.
*/
void reset_tree(scalfmm_handle handle);
#endif
......@@ -518,6 +518,11 @@ public:
});
}
//Simple call to FScalFMMEngine method with good template
void reset_tree(){
generic_reset_tree<FReal,ContainerClass,InterCell,LeafClass>(octree);
}
void update_tree(){
if(arranger){
arranger->rearrange();
......
......@@ -30,6 +30,7 @@
//For tree
#include "Components/FSimpleLeaf.hpp"
#include "Kernels/P2P/FP2PParticleContainerIndexed.hpp"
#include "Containers/FOctree.hpp"
//For interpolation
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
......@@ -201,6 +202,32 @@ public:
FAssertLF(0,"No tree instancied, exiting ...\n");
}
virtual void reset_tree(){
}
template<class FReal,class ContainerClass, class CellClass, class LeafClass>
void generic_reset_tree(FOctree<FReal,CellClass,ContainerClass,LeafClass> * tree){
//Reset forces and potentials
tree->forEachLeaf([&](LeafClass * leaf){
ContainerClass * targets = leaf->getTargets();
FSize nbPartTarget = targets->getNbParticles();
//Set potential to 0
FReal * potentialsTarget = targets->getPotentialsArray();
memset(potentialsTarget,0,sizeof(FReal)*nbPartTarget);
//Set forces to 0
FReal * forcesX = targets->getForcesXArray();
FReal * forcesY = targets->getForcesYArray();
FReal * forcesZ = targets->getForcesZArray();
memset(forcesX,0,sizeof(FReal)*nbPartTarget);
memset(forcesY,0,sizeof(FReal)*nbPartTarget);
memset(forcesZ,0,sizeof(FReal)*nbPartTarget);
});
//Reset multipole and local development
tree->forEachCell([&](CellClass * cell){
cell->resetToInitialState();
});
}
//User define Kernel Part
virtual void user_kernel_config( Scalfmm_Kernel_Descriptor userKernel, void * userDatas){
......@@ -215,6 +242,8 @@ public:
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
};
......@@ -412,6 +441,8 @@ extern "C" void scalfmm_utils_interactionPosition(int interactionPosition, int*
}
extern "C" void reset_tree(scalfmm_handle Handle){
((ScalFmmCoreHandle * ) Handle)->engine->reset_tree();
}
#endif
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