From d41d80b1fcb3bf8be2ed6ba17c89c9bf1ce92aa4 Mon Sep 17 00:00:00 2001 From: Berenger Bramas <berenger.bramas@inria.fr> Date: Mon, 12 Nov 2012 15:40:17 +0100 Subject: [PATCH] update fmm api --- Addons/FmmApi/Src/ScalfmmApiCore.cpp | 27 ++++++++---------------- Addons/FmmApi/Src/ScalfmmApiRotation.cpp | 18 ++++++---------- Addons/FmmApi/Tests/testFmmApi.cpp | 14 ++++++------ 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/Addons/FmmApi/Src/ScalfmmApiCore.cpp b/Addons/FmmApi/Src/ScalfmmApiCore.cpp index 673c67ea3..18da57d73 100644 --- a/Addons/FmmApi/Src/ScalfmmApiCore.cpp +++ b/Addons/FmmApi/Src/ScalfmmApiCore.cpp @@ -8,14 +8,12 @@ // Owners: INRIA. // Copyright © 2011-2012, spread under the terms and conditions of a proprietary license. // =================================================================================== -#include "../../Src/Utils/FParameters.hpp" -#include "../../Src/Utils/FTic.hpp" - #include "../../Src/Containers/FOctree.hpp" #include "../../Src/Containers/FVector.hpp" #include "../../Src/Components/FSimpleLeaf.hpp" #include "../../Src/Components/FBasicParticle.hpp" +#include "../../Src/Components/FBasicCell.hpp" #include "../../Src/Utils/FPoint.hpp" @@ -308,19 +306,6 @@ int FmmCore_init(void **fmmCore) { return FMMAPI_NO_ERROR; } /*alloue et initialise le FmmCore*/ -// !!! Added !!! -int FmmCore_finishInit(void *fmmCore) { - 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)); - - if( corehandle->config.nbThreads != 0){ - omp_set_num_threads(corehandle->config.nbThreads); - } - - return FMMAPI_NO_ERROR; -} /*alloue et initialise le FmmCore*/ int FmmCore_free(void *fmmCore) { ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; @@ -561,14 +546,20 @@ int FmmCore_getKernelData(void*fmmCore, void **fmmKernel) { int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) { ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; - OctreeClass* octree = corehandle->octree; + + corehandle->octree = new OctreeClass(corehandle->config.treeHeight, FMath::Min(3,corehandle->config.treeHeight-1), + corehandle->config.boxWidth, FPoint(corehandle->config.boxCenter)); + + if( corehandle->config.nbThreads != 0){ + omp_set_num_threads(corehandle->config.nbThreads); + } CoreParticleClass part; for(int idxPart = 0 ; idxPart < (*nb) ; ++idxPart){ FReal* pos = &position[idxPart * 3]; part.setPosition(pos[0], pos[1], pos[2]); part.setIndex(idxPart); - octree->insert(part); + corehandle->octree->insert(part); } return FMMAPI_NO_ERROR; diff --git a/Addons/FmmApi/Src/ScalfmmApiRotation.cpp b/Addons/FmmApi/Src/ScalfmmApiRotation.cpp index 101921bcf..1c5284fdb 100644 --- a/Addons/FmmApi/Src/ScalfmmApiRotation.cpp +++ b/Addons/FmmApi/Src/ScalfmmApiRotation.cpp @@ -193,9 +193,8 @@ int FmmKernel_getLocalArraySize(void */*fmmCore*/, int *size){ /******* Opérateurs FMM : **/ int FmmKernel_P2M(void *fmmCore, void* boxId){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); @@ -229,9 +228,8 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){ } int FmmKernel_L2P(void *fmmCore, void* boxId){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); @@ -281,9 +279,8 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){ } int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); @@ -318,9 +315,8 @@ int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon){ } int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); @@ -355,9 +351,8 @@ int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon){ } int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); @@ -394,9 +389,8 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){ } int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ - ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)fmmCore; ScalFmmKernelHandle* kernelhandle; - FmmCore_getKernelData(corehandle, (void**)&kernelhandle); + FmmCore_getKernelData(fmmCore, (void**)&kernelhandle); int threadId; FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId); diff --git a/Addons/FmmApi/Tests/testFmmApi.cpp b/Addons/FmmApi/Tests/testFmmApi.cpp index 0aa63db71..bad86f756 100644 --- a/Addons/FmmApi/Tests/testFmmApi.cpp +++ b/Addons/FmmApi/Tests/testFmmApi.cpp @@ -14,9 +14,13 @@ #include "../../Src/Utils/FParameters.hpp" #include "../../Src/Utils/FTic.hpp" +#include "../../Src/Utils/FMemUtils.hpp" #include "../../Src/Files/FRandomLoader.hpp" +#include "../../Src/Components/FBasicParticle.hpp" + +#include "../Src/FmmApi.h" /** This program show an example of use of the fmm api */ @@ -35,7 +39,7 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// - FRandomLoader<KernelParticleClass> loader(NbPart, 1, FPoint(0.5,0.5,0.5), 1); + FRandomLoader<FBasicParticle> loader(NbPart, 1, FPoint(0.5,0.5,0.5), 1); void* FmmCoreHandle; FmmCore_init(&FmmCoreHandle); @@ -45,8 +49,6 @@ int main(int argc, char ** argv){ FmmCore_setParameter(FmmCoreHandle, FMMCORE_ROOT_BOX_WIDTH, &boxWidth); FmmCore_setParameter(FmmCoreHandle, FMMCORE_ROOT_BOX_CENTER, loader.getCenterOfBox().getDataValue()); - FmmCore_finishInit(FmmCoreHandle); - void* FmmKernelHandle; FmmKernel_init(FmmCoreHandle, &FmmKernelHandle); @@ -64,13 +66,13 @@ int main(int argc, char ** argv){ FReal* positions = new FReal[nbPart*3]; { - KernelParticleClass part; - part.setPhysicalValue(0.1); + FBasicParticle part; + const FReal physicalValue = 0.1; for(int idx = 0 ; idx < nbPart ; ++idx){ loader.fillParticle(part); - potentials[idx] = part.getPhysicalValue(); + potentials[idx] = physicalValue; positions[3*idx] = part.getPosition().getX(); positions[3*idx+1] = part.getPosition().getY(); positions[3*idx+2] = part.getPosition().getZ(); -- GitLab