Commit d41d80b1 authored by BRAMAS Berenger's avatar BRAMAS Berenger

update fmm api

parent a2c96d8b
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
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