Commit a8f5ad2f authored by BRAMAS Berenger's avatar BRAMAS Berenger

update the FMM api to make it compile from the latest changes in ScalFmm

parent e51178f7
......@@ -5,6 +5,7 @@ if(insource)
endif(insource)
project(Addons_fmmapi_scalfmm CXX)
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
# Active language
# -----------------------
......@@ -29,7 +30,11 @@ if(SCALFMM_ADDON_FMMAPI)
target_link_libraries( scalfmmapi scalfmm)
# Adding the entire project dir as an include dir
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/Src )
INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}/Src
${CMAKE_SOURCE_DIR}/Src
${SCALFMM_INCLUDES}
)
# Install lib
install( TARGETS scalfmmapi ARCHIVE DESTINATION lib )
......@@ -80,6 +85,7 @@ if(SCALFMM_ADDON_FMMAPI)
scalfmmapi
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
${SCALFMM_LIBRARIES}
)
endif()
endforeach(exec)
......
......@@ -107,6 +107,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId);
int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon);
int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon);
int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest);
int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest);
int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest); /* pas mutuel, i.e. on fait seulement dans 1 sens. */
......
......@@ -12,7 +12,6 @@
#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"
......@@ -23,27 +22,14 @@
#include "../../Src/Components/FBasicKernels.hpp"
#include "../../Src/Components/FBasicParticleContainer.hpp"
#ifdef ScalFMM_USE_MPI
#include "../../Src/Utils/FMpi.hpp"
#endif
#include "FmmApi.h"
template <class ParticleClass>
class CoreParticle : public ParticleClass {
int index;
public:
CoreParticle() : index(0) {
}
void setIndex(const int inIndex){
index = inIndex;
}
int getIndex() const {
return index;
}
};
template <class ContainerClass>
class CoreCell : public FBasicCell {
char* multipole;
......@@ -53,7 +39,7 @@ class CoreCell : public FBasicCell {
mutable ContainerClass* container;
public:
CoreCell() : multipole(0), local(0), level(0), container(0) {
CoreCell() : multipole(nullptr), local(nullptr), level(0), container(nullptr) {
}
void createArrays(const int multipoleSize, const int localSize){
multipole = new char[multipoleSize];
......@@ -112,8 +98,8 @@ public:
template< class ParticleClass, class CellClass, class ContainerClass>
class CoreKernel : public FAbstractKernels<ParticleClass,CellClass,ContainerClass> {
template< class CellClass, class ContainerClass>
class CoreKernel : public FAbstractKernels<CellClass,ContainerClass> {
void* fmmCore;
public:
......@@ -169,7 +155,7 @@ public:
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/,
ContainerClass* const neighbors[27], const int ){
CellClass* cell = (CellClass*)targets->getParentCell();
FmmKernel_P2P(fmmCore, cell, cell);
FmmKernel_P2P_inner(fmmCore, cell);
for(int idx = 0 ; idx < 27 ; ++idx){
if( neighbors[idx] ){
......@@ -188,7 +174,6 @@ public:
};
template <class ObjectClass>
class CoreVector {
mutable void* parentCell;
void* fields;
......@@ -198,8 +183,8 @@ class CoreVector {
FVector<FReal> positions;
FVector<int> indexes;
public:
CoreVector() : parentCell(0), fields(0), sizeOfField(0),
potentials(0), sizeOfPential(0){
CoreVector() : parentCell(nullptr), fields(nullptr), sizeOfField(0),
potentials(nullptr), sizeOfPential(0){
}
~CoreVector(){
......@@ -257,24 +242,24 @@ public:
return indexes.getSize();
}
void push(const ObjectClass& particle){
positions.push(particle.getPosition().getX());
positions.push(particle.getPosition().getY());
positions.push(particle.getPosition().getZ());
indexes.push(particle.getIndex());
void push(const FPoint& partPosition, const int partIndex){
positions.push(partPosition.getX());
positions.push(partPosition.getY());
positions.push(partPosition.getZ());
indexes.push(partIndex);
}
};
typedef CoreParticle<FBasicParticle> CoreParticleClass;
typedef CoreVector<CoreParticleClass> CoreContainerClass;
typedef CoreVector CoreContainerClass;
typedef CoreCell<CoreContainerClass> CoreCellClass;
typedef FSimpleLeaf<CoreParticleClass, CoreContainerClass > LeafClass;
typedef FOctree<CoreParticleClass, CoreCellClass, CoreContainerClass , LeafClass > OctreeClass;
typedef CoreKernel<CoreParticleClass, CoreCellClass, CoreContainerClass> CoreKernelClass;
typedef FSimpleLeaf<CoreContainerClass > LeafClass;
typedef FOctree<CoreCellClass, CoreContainerClass , LeafClass > OctreeClass;
typedef CoreKernel<CoreCellClass, CoreContainerClass> CoreKernelClass;
typedef FFmmAlgorithm<OctreeClass, CoreParticleClass, CoreCellClass, CoreContainerClass, CoreKernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithmThread<OctreeClass, CoreParticleClass, CoreCellClass, CoreContainerClass, CoreKernelClass, LeafClass > FmmClassThread;
typedef FFmmAlgorithm<OctreeClass, CoreCellClass, CoreContainerClass, CoreKernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithmThread<OctreeClass, CoreCellClass, CoreContainerClass, CoreKernelClass, LeafClass > FmmClassThread;
struct ScalFmmCoreHandle {
......@@ -554,12 +539,9 @@ int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) {
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);
corehandle->octree->insert(part);
const FReal* pos = &position[idxPart * 3];
corehandle->octree->insert(FPoint(pos[0], pos[1], pos[2]),idxPart);
}
return FMMAPI_NO_ERROR;
......@@ -606,7 +588,7 @@ int FmmCore_doComputation(void *fmmCore) {
typename OctreeClass::Iterator octreeIterator(corehandle->octree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = corehandle->config.treeHeight - 1 ; idxLevel > 1 ; --idxLevel ){
for(int idxLevel = corehandle->config.treeHeight - 1 ; idxLevel >= 1 ; --idxLevel ){
int multipoleSize;
int localSize;
......
This diff is collapsed.
......@@ -18,8 +18,6 @@
#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
......@@ -39,7 +37,7 @@ int main(int argc, char ** argv){
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
FRandomLoader<FBasicParticle> loader(NbPart, 1, FPoint(0.5,0.5,0.5), 1);
FRandomLoader loader(NbPart, 1, FPoint(0.5,0.5,0.5), 1);
void* FmmCoreHandle;
FmmCore_init(&FmmCoreHandle);
......@@ -66,16 +64,16 @@ int main(int argc, char ** argv){
FReal* positions = new FReal[nbPart*3];
{
FBasicParticle part;
FPoint part;
const FReal physicalValue = 0.1;
for(int idx = 0 ; idx < nbPart ; ++idx){
loader.fillParticle(part);
loader.fillParticle(&part);
potentials[idx] = physicalValue;
positions[3*idx] = part.getPosition().getX();
positions[3*idx+1] = part.getPosition().getY();
positions[3*idx+2] = part.getPosition().getZ();
positions[3*idx] = part.getX();
positions[3*idx+1] = part.getY();
positions[3*idx+2] = part.getZ();
}
FmmCore_setPositions(FmmCoreHandle, &nbPart, positions);
......@@ -135,15 +133,16 @@ int main(int argc, char ** argv){
dy *= inv_square_distance;
dz *= inv_square_distance;
fieldsdirect[4*idxTarget] += dx;
fieldsdirect[4*idxTarget+1] += dy;
fieldsdirect[4*idxTarget+2] += dz;
fieldsdirect[4*idxTarget+3] += inv_distance * potentials[idxSource];
fieldsdirect[4*idxTarget+1] += dx;
fieldsdirect[4*idxTarget+2] += dy;
fieldsdirect[4*idxTarget+3] += dz;
fieldsdirect[4*idxTarget+0] += inv_distance * potentials[idxSource];
fieldsdirect[4*idxSource+1] += -dx;
fieldsdirect[4*idxSource+2] += -dy;
fieldsdirect[4*idxSource+3] += -dz;
fieldsdirect[4*idxSource+0] += inv_distance * potentials[idxTarget];
fieldsdirect[4*idxSource] += -dx;
fieldsdirect[4*idxSource+1] += -dy;
fieldsdirect[4*idxSource+2] += -dz;
fieldsdirect[4*idxSource+3] += inv_distance * potentials[idxTarget];
}
}
......
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