Commit 72822426 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

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

# By bramas (9) and others
# Via aetcheve
* 'master' of git+ssh://scm.gforge.inria.fr//gitroot/scalfmm/scalfmm:
  fix some warnings
  Add a exec file to print the stats of the adaptive execution
  simple update of the adaptative test
  Remove old custom openmp barrier
  Manage the case when a node has all the same and so pivot equal max
  update the FMM api to make it compile from the latest changes in ScalFmm
  Add an fuse to protect from disabled fft
  Implemented adaptive routines for AdaptChebSym FMM kernel, Switched base kernel from dense to classic (fft accelerated) Unif FMM kernel in AdaptUnif FMM kernel.
  Debug the mpi quick sort in case the pivot is the max value
  changes and fix in utestMpiTreeBuilder
  Add an assert in the rotation matrix operator
  Add a division method
  Fix for the error occuring in M2M, still bugged
parents 59df215d 58613d08
......@@ -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;
......
......@@ -8,6 +8,9 @@
// Owners: INRIA.
// Copyright © 2011-2012, spread under the terms and conditions of a proprietary license.
// ===================================================================================
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Components/FSimpleLeaf.hpp"
......@@ -15,8 +18,8 @@
#include "../../Src/Utils/FPoint.hpp"
#include "../../Src/Kernels/Rotation/FRotationCell.hpp"
#include "../../Src/Kernels/Rotation/FRotationParticle.hpp"
#include "../../Src/Kernels/Rotation/FRotationKernel.hpp"
#include "../../Src/Kernels/P2P/FP2PParticleContainer.hpp"
#include "FmmApi.h"
......@@ -26,7 +29,7 @@ class KernelCell : public FBasicCell {
FComplexe* multipole;
FComplexe* local;
public:
KernelCell() : multipole(0), local(0){
KernelCell() : multipole(nullptr), local(nullptr){
}
void attachArrays(FComplexe inMultipole[], FComplexe inLocal[]){
multipole = inMultipole;
......@@ -53,10 +56,10 @@ public:
static const int P = 5;
typedef FRotationParticle KernelParticleClass;
typedef FVector<KernelParticleClass> KernelContainerClass;
typedef KernelCell KernelCellClass;
typedef FRotationKernel<KernelParticleClass, KernelCellClass, KernelContainerClass, P > KernelClass;
typedef FP2PParticleContainer<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FRotationKernel< KernelCellClass, ContainerClass , P> KernelClass;
struct ScalFmmKernelHandle {
KernelClass** kernel;
......@@ -202,27 +205,24 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){
FmmCore_getMultipoleArray(fmmCore, boxId, (void**)&multipole);
KernelCellClass cell;
cell.attachArrays(multipole, 0);
cell.attachArrays(multipole, nullptr);
int coord[3];
FmmCore_getCoord(fmmCore, boxId, coord);
cell.setCoordinate(coord[0], coord[1], coord[2]);
FReal* positions;
FReal* potentials;
FReal* physicalValues;
int number;
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&potentials, &number);
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&physicalValues, &number);
KernelContainerClass sources;
KernelParticleClass part;
FP2PParticleContainer<> sources;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
part.setPosition(FPoint(&positions[idxPart*3]));
part.setPhysicalValue(potentials[idxPart]);
sources.push(part);
sources.push(FPoint(positions[idxPart*3],positions[idxPart*3+1],positions[idxPart*3+2]),physicalValues[idxPart]);
}
kernelhandle->kernel[threadId]->P2M(&cell, &sources);
FmmCore_releaseSource(fmmCore, boxId, potentials, positions);
FmmCore_releaseSource(fmmCore, boxId, physicalValues, positions);
return FMMAPI_NO_ERROR;
}
......@@ -237,38 +237,40 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){
FmmCore_getLocalArray(fmmCore, boxId, (void**)&local);
KernelCellClass cell;
cell.attachArrays(0,local);
cell.attachArrays(nullptr,local);
int coord[3];
FmmCore_getCoord(fmmCore, boxId, coord);
cell.setCoordinate(coord[0], coord[1], coord[2]);
FReal* potentials;
FReal* physicalValues;
FReal* positions;
int number;
//FmmCore_getTargetPoints(fmmCore, boxId, &positions, &number);
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&potentials, &number);
FmmCore_getSource(fmmCore, boxId, &positions, (void**)&physicalValues, &number);
FReal* fields = new FReal[number*kernelhandle->fieldDataSize];
FmmCore_getTargetField(fmmCore, boxId, fields);
KernelContainerClass targets;
KernelParticleClass part;
FP2PParticleContainer<> targets;
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
part.setPosition(FPoint(&positions[idxPart*3]));
part.setForces(fields[idxPart*kernelhandle->fieldDataSize],fields[idxPart*kernelhandle->fieldDataSize+1],
fields[idxPart*kernelhandle->fieldDataSize+2]);
part.setPotential(fields[idxPart*kernelhandle->fieldDataSize+3]);
part.setPhysicalValue(potentials[idxPart]);
targets.push(part);
targets.push(FPoint(&positions[idxPart*3]),physicalValues[idxPart],
fields[idxPart*kernelhandle->fieldDataSize],
fields[idxPart*kernelhandle->fieldDataSize+1],
fields[idxPart*kernelhandle->fieldDataSize+2],
fields[idxPart*kernelhandle->fieldDataSize+3]);
}
kernelhandle->kernel[threadId]->L2P(&cell, &targets);
const FReal*const potentials = targets.getPotentials();
const FReal*const forcesX = targets.getForcesX();
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < number ; ++idxPart){
fields[idxPart*kernelhandle->fieldDataSize] = targets[idxPart].getForces().getX();
fields[idxPart*kernelhandle->fieldDataSize+1] = targets[idxPart].getForces().getY();
fields[idxPart*kernelhandle->fieldDataSize+2] = targets[idxPart].getForces().getZ();
fields[idxPart*kernelhandle->fieldDataSize+3] = targets[idxPart].getPotential();
fields[idxPart*kernelhandle->fieldDataSize] += potentials[idxPart];
fields[idxPart*kernelhandle->fieldDataSize+1] += forcesX[idxPart];
fields[idxPart*kernelhandle->fieldDataSize+2] += forcesY[idxPart];
fields[idxPart*kernelhandle->fieldDataSize+3] += forcesZ[idxPart];
}
FmmCore_releaseTargetPoints(fmmCore, boxId, positions);
......@@ -288,7 +290,7 @@ int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon){
FmmCore_getMultipoleArray(fmmCore, boxIdFather, (void**)&multipole);
KernelCellClass cellFather;
cellFather.attachArrays(multipole, 0);
cellFather.attachArrays(multipole, nullptr);
int coordFather[3];
FmmCore_getCoord(fmmCore, boxIdFather, coordFather);
cellFather.setCoordinate(coordFather[0], coordFather[1], coordFather[2]);
......@@ -296,7 +298,7 @@ int FmmKernel_M2M(void *fmmCore, void *boxIdFather, void *boxIdSon){
FmmCore_getMultipoleArray(fmmCore, boxIdSon, (void**)&multipole);
KernelCellClass cellSon;
cellSon.attachArrays(multipole, 0);
cellSon.attachArrays(multipole, nullptr);
int coordChild[3];
FmmCore_getCoord(fmmCore, boxIdSon, coordChild);
cellSon.setCoordinate(coordChild[0], coordChild[1], coordChild[2]);
......@@ -324,7 +326,7 @@ int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon){
FmmCore_getLocalArray(fmmCore, boxIdFather, (void**)&local);
KernelCellClass cellFather;
cellFather.attachArrays(0, local);
cellFather.attachArrays(nullptr, local);
int coordFather[3];
FmmCore_getCoord(fmmCore, boxIdFather, coordFather);
cellFather.setCoordinate(coordFather[0], coordFather[1], coordFather[2]);
......@@ -332,7 +334,7 @@ int FmmKernel_L2L(void *fmmCore, void *boxIdFather, void *boxIdSon){
FmmCore_getLocalArray(fmmCore, boxIdSon, (void**)&local);
KernelCellClass cellSon;
cellSon.attachArrays(0, local);
cellSon.attachArrays(nullptr, local);
int coordChild[3];
FmmCore_getCoord(fmmCore, boxIdSon, coordChild);
cellSon.setCoordinate(coordChild[0], coordChild[1], coordChild[2]);
......@@ -359,7 +361,7 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){
FComplexe* multipole;
FmmCore_getMultipoleArray(fmmCore, boxIdSrc, (void**)&multipole);
KernelCellClass cellSrc;
cellSrc.attachArrays(multipole,0);
cellSrc.attachArrays(multipole,nullptr);
int coord[3];
FmmCore_getCoord(fmmCore, boxIdSrc, coord);
cellSrc.setCoordinate(coord[0], coord[1], coord[2]);
......@@ -367,7 +369,7 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){
FComplexe* local;
FmmCore_getLocalArray(fmmCore, boxIdDest, (void**)&local);
KernelCellClass cellDst;
cellDst.attachArrays(0, local);
cellDst.attachArrays(nullptr, local);
FmmCore_getCoord(fmmCore, boxIdDest, coord);
cellDst.setCoordinate(coord[0], coord[1], coord[2]);
......@@ -388,7 +390,59 @@ int FmmKernel_M2L(void *fmmCore, void *boxIdSrc, void *boxIdDest){
return FMMAPI_NO_ERROR;
}
int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){
int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){
ScalFmmKernelHandle* kernelhandle;
FmmCore_getKernelData(fmmCore, (void**)&kernelhandle);
int threadId;
FmmCore_getParameter(fmmCore, FMMCORE_THREAD_ID, &threadId);
FReal* positionsTargets;
FReal* potentialsTargets;
int numberTargets;
FmmCore_getSource(fmmCore, boxIdSrcDest, &positionsTargets, (void**)&potentialsTargets, &numberTargets);
FReal* fieldsTargets = new FReal[numberTargets*kernelhandle->fieldDataSize];
FmmCore_getTargetField(fmmCore, boxIdSrcDest, fieldsTargets);
int coordTargets[3];
FmmCore_getCoord(fmmCore, boxIdSrcDest, coordTargets);
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
FP2PParticleContainer<> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
targets.push(FPoint(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+3]);
}
FP2PParticleContainer<>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<>*) * 27);
kernelhandle->kernel[threadId]->P2P(treecoord, &targets, &targets, ptrs, 0);
const FReal*const potentials = targets.getPotentials();
const FReal*const forcesX = targets.getForcesX();
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+3] = forcesZ[idxPart];
}
FmmCore_releaseTargetPoints(fmmCore, boxIdSrcDest, positionsTargets);
FmmCore_setTargetField(fmmCore, boxIdSrcDest, fieldsTargets);
delete[] fieldsTargets;
return FMMAPI_NO_ERROR;
}
int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMAPI_NO_ERROR;
ScalFmmKernelHandle* kernelhandle;
FmmCore_getKernelData(fmmCore, (void**)&kernelhandle);
int threadId;
......@@ -397,7 +451,6 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){
FReal* positionsTargets;
FReal* potentialsTargets;
int numberTargets;
//FmmCore_getTargetPoints(fmmCore, boxIdDest, &positionsTargets, &numberTargets);
FmmCore_getSource(fmmCore, boxIdDest, &positionsTargets, (void**)&potentialsTargets, &numberTargets);
FReal* fieldsTargets = new FReal[numberTargets*kernelhandle->fieldDataSize];
......@@ -405,17 +458,16 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){
int coordTargets[3];
FmmCore_getCoord(fmmCore, boxIdDest, coordTargets);
FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]);
KernelContainerClass targets;
KernelParticleClass part;
FP2PParticleContainer<> targets;
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
part.setPosition(FPoint(&positionsTargets[idxPart*3]));
part.setForces(fieldsTargets[idxPart*kernelhandle->fieldDataSize],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2]);
part.setPotential(fieldsTargets[idxPart*kernelhandle->fieldDataSize+3]);
part.setPhysicalValue(potentialsTargets[idxPart]);
targets.push(part);
targets.push(FPoint(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]),
potentialsTargets[idxPart],
fieldsTargets[idxPart*kernelhandle->fieldDataSize],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2],
fieldsTargets[idxPart*kernelhandle->fieldDataSize+3]);
}
FReal* positionsSrc;
......@@ -423,36 +475,26 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){
int numberSources;
FmmCore_getSource(fmmCore, boxIdSrc, &positionsSrc, (void**)&potentialsSrc, &numberSources);
KernelContainerClass sources;
FP2PParticleContainer<> sources;
for(int idxPart = 0 ; idxPart < numberSources ; ++idxPart){
part.setPosition(FPoint(&positionsSrc[idxPart*3]));
part.setPhysicalValue(potentialsSrc[idxPart]);
sources.push(part);
sources.push(FPoint(positionsSrc[idxPart*3],positionsSrc[idxPart*3+1],positionsSrc[idxPart*3+2]),potentialsSrc[idxPart]);
}
//KernelContainerClass* neigh[27];
//memset(neigh, 0, sizeof(KernelContainerClass*)*27);
//neigh[0] = &sources;
//kernelhandle->kernel->P2PRemote(FTreeCoordinate(coordTargets[0],coordTargets[1],coordTargets[2]),
// &targets, &sources, neigh, 1);
for(int idxTarget = 0 ; idxTarget < numberTargets ; ++idxTarget){
for(int idxSource = 0 ; idxSource < numberSources ; ++idxSource){
FReal dx = sources[idxSource].getPosition().getX() - targets[idxTarget].getPosition().getX();
FReal dy = sources[idxSource].getPosition().getY() - targets[idxTarget].getPosition().getY();
FReal dz = sources[idxSource].getPosition().getZ() - targets[idxTarget].getPosition().getZ();
const FReal distSquare = (dx*dx + dy*dy + dz*dz);
if(distSquare > 10E-6*10E-6){
kernelhandle->kernel[threadId]->particlesInteraction(&targets[idxTarget],sources[idxSource]);
}
}
}
FP2PParticleContainer<>* ptrs[27];
memset(ptrs, 0, sizeof(FP2PParticleContainer<>*) * 27);
ptrs[0] = &sources;
kernelhandle->kernel[threadId]->P2PRemote(treecoord, &targets, &targets, ptrs, 1);
const FReal*const potentials = targets.getPotentials();
const FReal*const forcesX = targets.getForcesX();
const FReal*const forcesY = targets.getForcesY();
const FReal*const forcesZ = targets.getForcesZ();
for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){
fieldsTargets[idxPart*kernelhandle->fieldDataSize] = targets[idxPart].getForces().getX();
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = targets[idxPart].getForces().getY();
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = targets[idxPart].getForces().getZ();
fieldsTargets[idxPart*kernelhandle->fieldDataSize+3] = targets[idxPart].getPotential();
fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart];
fieldsTargets[idxPart*kernelhandle->fieldDataSize+3] = forcesZ[idxPart];
}
FmmCore_releaseSource(fmmCore, boxIdDest, potentialsSrc, positionsSrc);
......
......@@ -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];
}
}
......
......@@ -58,6 +58,11 @@ class FAdaptiveChebSymKernel : FChebSymKernel<CellClass, ContainerClass, MatrixK
, public FAbstractAdaptiveKernel<CellClass, ContainerClass> {
//
typedef FChebSymKernel<CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> KernelBaseClass;
enum {order = ORDER,
nnodes = TensorTraits<ORDER>::nnodes};
const MatrixKernelClass *const MatrixKernel;
public:
using KernelBaseClass::P2M;
......@@ -74,11 +79,11 @@ public: