Commit 7d722cc2 authored by berenger-bramas's avatar berenger-bramas
Browse files

Added Target/Source support

But!
Need more test event if it compiles
Need to change some name
Need to think about the operators for the cells that have only targets or sources particules under them.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@32 2616d619-271b-44dc-8df4-d4a8f33a7222
parent facce5df
......@@ -28,10 +28,10 @@
* Particule must extend {FExtendPosition}
* Cell must extend extend {FExtendPosition,FExtendMortonIndex}
*/
template< class ParticuleClass, class CellClass, int OctreeHeight, int SubtreeHeight = 3>
template< class ParticuleClass, class CellClass, template <class ParticuleClass> class LeafClass, int OctreeHeight, int SubtreeHeight = 3>
class FOctree {
FReal boxWidthAtLevel[OctreeHeight]; //< to store the width of each boxs at all levels
FSubOctree< ParticuleClass, CellClass > root; //< root suboctree
FSubOctree< ParticuleClass, CellClass , LeafClass> root; //< root suboctree
const F3DPosition boxCenter; //< the space system center
const F3DPosition boxCorner; //< the space system corner (used to compute morton index)
......@@ -120,18 +120,18 @@ public:
* depending if we are working on the bottom of the tree.
*/
union SubOctreeTypes {
FAbstractSubOctree<ParticuleClass,CellClass>* tree; //< Usual pointer to work
FSubOctree<ParticuleClass,CellClass>* middleTree; //< To access to sub-octree under
FSubOctreeWithLeafs<ParticuleClass,CellClass>* leafTree;//< To access to particules lists
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* tree; //< Usual pointer to work
FSubOctree<ParticuleClass,CellClass,LeafClass>* middleTree; //< To access to sub-octree under
FSubOctreeWithLeafs<ParticuleClass,CellClass,LeafClass>* leafTree;//< To access to particules lists
};
/**
* This class is a const SubOctreeTypes
*/
union SubOctreeTypesConst {
const FAbstractSubOctree<ParticuleClass,CellClass>* tree; //< Usual pointer to work
const FSubOctree<ParticuleClass,CellClass>* middleTree; //< To access to sub-octree under
const FSubOctreeWithLeafs<ParticuleClass,CellClass>* leafTree;//< To access to particules lists
const FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* tree; //< Usual pointer to work
const FSubOctree<ParticuleClass,CellClass,LeafClass>* middleTree; //< To access to sub-octree under
const FSubOctreeWithLeafs<ParticuleClass,CellClass,LeafClass>* leafTree;//< To access to particules lists
};
/**
......@@ -489,8 +489,16 @@ public:
* You have to be at the leaf level to call this function!
* @return current element list
*/
FList<ParticuleClass*>* getCurrentList() {
return this->current.leafTree->getLeaf(this->currentLocalIndex);
FList<ParticuleClass*>* getCurrentListSources() {
return this->current.leafTree->getLeafSources(this->currentLocalIndex);
}
/** To access the current particules list
* You have to be at the leaf level to call this function!
* @return current element list
*/
FList<ParticuleClass*>* getCurrentListTargets() {
return this->current.leafTree->getLeafTargets(this->currentLocalIndex);
}
/** Get the current pointed cell
......@@ -714,7 +722,7 @@ public:
* @return the cell if it exist or null (0)
*
*/
FList<ParticuleClass*>* getLeaf(const MortonIndex inIndex){
FList<ParticuleClass*>* getLeafSources(const MortonIndex inIndex){
SubOctreeTypes workingTree;
workingTree.tree = &this->root;
const MortonIndex treeSubLeafMask = ~(~0x00LL << (3 * workingTree.tree->getSubOctreeHeight() ));
......@@ -730,7 +738,7 @@ public:
// compute correct index in the array
const MortonIndex treeLeafMask = ~(~0x00LL << (3 * (leafIndex + 1 - workingTree.tree->getSubOctreePosition()) ));
return workingTree.leafTree->getLeaf(treeLeafMask & inIndex);
return workingTree.leafTree->getLeafSources(treeLeafMask & inIndex);
}
/** This function fill an array with the neighbors of a cell
......@@ -762,7 +770,7 @@ public:
const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ);
const MortonIndex mortonOther = other.getMortonIndex(inLevel);
// get cell
FList<ParticuleClass*>* const leaf = getLeaf(mortonOther);
FList<ParticuleClass*>* const leaf = getLeafSources(mortonOther);
// add to list if not null
if(leaf) inNeighbors[idxNeighbors++] = leaf;
}
......
......@@ -34,7 +34,7 @@
* Please refere to testOctree.cpp to see an example
* @warning Give the particuleClass & cellClass
*/
template< class ParticuleClass, class CellClass >
template< class ParticuleClass, class CellClass , template <class ParticuleClass> class LeafClass>
class FAbstractSubOctree : protected FAssertable{
protected:
......@@ -249,11 +249,11 @@ public:
* Please refere to testOctree.cpp to see an example.
* @warning Give the particuleClass & cellClass
*/
template< class ParticuleClass, class CellClass >
class FSubOctreeWithLeafs : public FAbstractSubOctree<ParticuleClass,CellClass> {
template< class ParticuleClass, class CellClass , template <class ParticuleClass> class LeafClass>
class FSubOctreeWithLeafs : public FAbstractSubOctree<ParticuleClass,CellClass,LeafClass> {
private:
FList<ParticuleClass*>** leafs; //< Leafs array
LeafClass<ParticuleClass>** leafs; //< Leafs array
/** Disable copy */
FSubOctreeWithLeafs(const FSubOctreeWithLeafs&){}
......@@ -267,13 +267,13 @@ public:
* @param inSubOctreeHeight Height of this suboctree
* @param inSubOctreePosition Level of the current suboctree in the global tree (1 if upper tree)
*/
FSubOctreeWithLeafs(FAbstractSubOctree<ParticuleClass,CellClass>* const inParent, const long inIndexInParent,
FSubOctreeWithLeafs(FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* const inParent, const long inIndexInParent,
const int inSubOctreeHeight, const int inSubOctreePosition) :
FAbstractSubOctree<ParticuleClass,CellClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition) {
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition) {
const long cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->leafs = new FList<ParticuleClass*>*[cellsAtLeafLevel];
this->leafs = new LeafClass<ParticuleClass>*[cellsAtLeafLevel];
assert(this->leafs, "Allocation failled", __LINE__, __FILE__);
for( long indexLeaf = 0 ; indexLeaf < cellsAtLeafLevel ; ++indexLeaf ){
......@@ -299,28 +299,46 @@ public:
*/
void insert(const MortonIndex index, ParticuleClass* const inParticule, const int inTreeHeight, const FReal* const inBoxWidthAtLevel){
// Get the morton index for the leaf level
const MortonIndex arrayIndex = FAbstractSubOctree<ParticuleClass,CellClass>::getLeafIndex(index,inTreeHeight);
const MortonIndex arrayIndex = FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>::getLeafIndex(index,inTreeHeight);
// is there already a leaf?
if( !this->leafs[arrayIndex] ){
this->leafs[arrayIndex] = new FList<ParticuleClass*>();
FAbstractSubOctree<ParticuleClass,CellClass>::newLeafInserted( arrayIndex , index, inBoxWidthAtLevel);
this->leafs[arrayIndex] = new LeafClass<ParticuleClass>();
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>::newLeafInserted( arrayIndex , index, inBoxWidthAtLevel);
}
// add particule to leaf list
this->leafs[arrayIndex]->pushFront(inParticule);
this->leafs[arrayIndex]->push(inParticule);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particules at this index */
FList<ParticuleClass*>* getLeaf(const int index){
return this->leafs[index];
FList<ParticuleClass*>* getLeafSources(const int index){
LeafClass<ParticuleClass>* const leaf = this->leafs[index];
return (leaf ? leaf->getSources(): 0);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particules at this index */
const FList<ParticuleClass*>* getLeaf(const int index) const {
return this->leafs[index];
FList<ParticuleClass*>* getLeafTargets(const int index){
LeafClass<ParticuleClass>* const leaf = this->leafs[index];
return (leaf ? leaf->getTargets(): 0);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particules at this index */
const FList<ParticuleClass*>* getLeafSources(const int index) const {
LeafClass<ParticuleClass>* const leaf = this->leafs[index];
return (leaf ? leaf->getSources(): 0);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particules at this index */
const FList<ParticuleClass*>* getLeafTargets(const int index) const {
LeafClass<ParticuleClass>* const leaf = this->leafs[index];
return (leaf ? leaf->getTargets() : 0);
}
};
......@@ -344,10 +362,10 @@ public:
*
* @warning Give the particuleClass & cellClass
*/
template< class ParticuleClass, class CellClass >
class FSubOctree : public FAbstractSubOctree<ParticuleClass,CellClass> {
template< class ParticuleClass, class CellClass , template <class ParticuleClass> class LeafClass>
class FSubOctree : public FAbstractSubOctree<ParticuleClass,CellClass,LeafClass> {
private:
FAbstractSubOctree<ParticuleClass,CellClass>** subleafs; //< Last levels is composed of suboctree
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>** subleafs; //< Last levels is composed of suboctree
/** Disable copy */
FSubOctree(const FSubOctree&){}
......@@ -361,12 +379,12 @@ public:
* @param inSubOctreeHeight Height of this suboctree
* @param inSubOctreePosition Level of the current suboctree in the global tree (0 if upper tree)
*/
FSubOctree(FAbstractSubOctree<ParticuleClass,CellClass>* const inParent, const long inIndexInParent,
FSubOctree(FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* const inParent, const long inIndexInParent,
const int inSubOctreeHeight, const int inSubOctreePosition) :
FAbstractSubOctree<ParticuleClass,CellClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition) {
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition) {
const long cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->subleafs = new FAbstractSubOctree<ParticuleClass,CellClass>*[cellsAtLeafLevel];
this->subleafs = new FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>*[cellsAtLeafLevel];
assert(this->subleafs, "Allocation failled", __LINE__, __FILE__);
for( int indexLeaf = 0 ; indexLeaf < cellsAtLeafLevel ; ++indexLeaf ){
......@@ -391,7 +409,7 @@ public:
void insert(const MortonIndex index, ParticuleClass* const inParticule, const int inTreeHeight, const FReal* const inBoxWidthAtLevel){
// We need the morton index at the bottom level of this sub octree
// so we remove the right side
const MortonIndex arrayIndex = FAbstractSubOctree<ParticuleClass,CellClass>::getLeafIndex(index,inTreeHeight);
const MortonIndex arrayIndex = FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>::getLeafIndex(index,inTreeHeight);
// Is there already a leaf?
if( !this->subleafs[arrayIndex] ){
// We need to create leaf sub octree
......@@ -404,11 +422,11 @@ public:
}
// Or next suboctree contains the reail leaf!
else{
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticuleClass,CellClass>(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticuleClass,CellClass,LeafClass>(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
}
// We need to inform parent class
FAbstractSubOctree<ParticuleClass,CellClass>::newLeafInserted( arrayIndex, index >> (3 * (inTreeHeight-nextSubOctreePosition) ), inBoxWidthAtLevel);
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>::newLeafInserted( arrayIndex, index >> (3 * (inTreeHeight-nextSubOctreePosition) ), inBoxWidthAtLevel);
}
// Ask next suboctree to insert the particule
this->subleafs[arrayIndex]->insert( index, inParticule, inTreeHeight, inBoxWidthAtLevel);
......@@ -417,14 +435,14 @@ public:
/** To get access to leafs elements (child suboctree)
* @param index the position of the leaf/child suboctree
* @return child at this index */
FAbstractSubOctree<ParticuleClass,CellClass>* leafs(const int index) {
FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* leafs(const int index) {
return this->subleafs[index];
}
/** To get access to leafs elements (child suboctree)
* @param index the position of the leaf/child suboctree
* @return child at this index */
const FAbstractSubOctree<ParticuleClass,CellClass>* leafs(const int index) const {
const FAbstractSubOctree<ParticuleClass,CellClass,LeafClass>* leafs(const int index) const {
return this->subleafs[index];
}
};
......
#ifndef FABSTRACTLEAF_HPP
#define FABSTRACTLEAF_HPP
// /!\ Please, you must read the license at the bottom of this page
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FAbstractLeaf
* @brief
* Please read the license
* This class is used to enable the use of typed particules
* (source XOR target) or simple system (source AND target)
*/
template< class ParticuleClass >
class FAbstractLeaf {
public:
/** Default destructor */
virtual ~FAbstractLeaf(){
}
/**
* To add a new particule in the leaf
* @param particule the new particule
* Depending on the system to use the class that inherit
* this interface can sort the particule as they like.
*/
virtual void push(ParticuleClass* const particule) = 0;
/**
* To get all the sources in a leaf
* @return a pointer to the list of particules that are sources
* Depending on the system to use the class that inherit
* this interface can sort the particule as they like.
*/
virtual FList<ParticuleClass*>* getSources() = 0;
/**
* To get all the target in a leaf
* @return a pointer to the list of particules that are targets
* Depending on the system to use the class that inherit
* this interface can sort the particule as they like.
*/
virtual FList<ParticuleClass*>* getTargets() = 0;
};
#endif //FABSTRACTLEAF_HPP
// [--LICENSE--]
......@@ -2,8 +2,8 @@
#define FBASICCELL_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "FExtendPosition.hpp"
#include "FExtendMortonIndex.hpp"
#include "../Extenssions/FExtendPosition.hpp"
#include "../Extenssions/FExtendMortonIndex.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......
......@@ -2,7 +2,7 @@
#define FBASICPARTICULE_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "FExtendPosition.hpp"
#include "../Extenssions/FExtendPosition.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......
......@@ -21,11 +21,14 @@
*
* Of course this class does not deallocate pointer given in arguements.
*/
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass, class ParticuleClass, class CellClass, int OctreeHeight, int SubtreeHeight>
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticuleClass, class CellClass,
template<class ParticuleClass> class LeafClass,
int OctreeHeight, int SubtreeHeight>
class FFMMAlgorithm : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
typedef FOctree<ParticuleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass,LeafClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
Octree* const tree; //< The octree to work on
KernelClass<ParticuleClass, CellClass, OctreeHeight>* const kernels; //< The kernels
......@@ -85,7 +88,7 @@ public:
// We need the current cell that represent the leaf
// and the list of particules
FDEBUG(computationCounter.tic());
kernels->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentList());
kernels->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentListSources());
FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight());
......@@ -212,10 +215,10 @@ public:
// for each leafs
do{
FDEBUG(computationCounter.tic());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentList());
kernels->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
kernels->P2P( octreeIterator.getCurrentList() , neighbors, counter);
kernels->P2P( octreeIterator.getCurrentListTargets() , neighbors, counter);
FDEBUG(computationCounter.tac());
FDEBUG(totalComputation += computationCounter.elapsed());
} while(octreeIterator.moveRight());
......
......@@ -29,11 +29,14 @@
* Threaded & based on the inspector-executor model
* schedule(runtime)
*/
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass, class ParticuleClass, class CellClass, int OctreeHeight, int SubtreeHeight>
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticuleClass, class CellClass,
template<class ParticuleClass> class LeafClass,
int OctreeHeight, int SubtreeHeight>
class FFMMAlgorithmArray : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator OctreeIterator;
typedef FOctree<ParticuleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass,LeafClass, OctreeHeight, SubtreeHeight>::Iterator OctreeIterator;
typedef KernelClass<ParticuleClass, CellClass, OctreeHeight> Kernel;
Octree* const tree; //< The octree to work on
......@@ -127,7 +130,7 @@ public:
for(int idxLeafs = 0 ; idxLeafs < leafs ; ++idxLeafs){
// We need the current cell that represent the leaf
// and the list of particules
myThreadkernels->P2M( iterArray[idxLeafs].getCurrentCell() , iterArray[idxLeafs].getCurrentList());
myThreadkernels->P2M( iterArray[idxLeafs].getCurrentCell() , iterArray[idxLeafs].getCurrentListSources());
}
}
FDEBUG(computationCounter.tac());
......@@ -293,10 +296,10 @@ public:
#pragma omp for
for(int idxLeafs = 0 ; idxLeafs < leafs ; ++idxLeafs){
myThreadkernels->L2P(iterArray[idxLeafs].getCurrentCell(), iterArray[idxLeafs].getCurrentList());
myThreadkernels->L2P(iterArray[idxLeafs].getCurrentCell(), iterArray[idxLeafs].getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, iterArray[idxLeafs].getCurrentGlobalIndex(),heightMinusOne);
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentList() , neighbors, counter);
myThreadkernels->P2P( iterArray[idxLeafs].getCurrentListTargets() , neighbors, counter);
}
}
FDEBUG(computationCounter.tac());
......
......@@ -25,11 +25,14 @@
*
* Of course this class does not deallocate pointer given in arguements.
*/
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass, class ParticuleClass, class CellClass, int OctreeHeight, int SubtreeHeight>
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticuleClass, class CellClass,
template<class ParticuleClass> class LeafClass,
int OctreeHeight, int SubtreeHeight>
class FFMMAlgorithmTask : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
typedef FOctree<ParticuleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass,LeafClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
Octree* const tree; //< The octree to work on
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[FThreadNumbers]; //< The kernels
......@@ -100,7 +103,7 @@ public:
{
// We need the current cell that represent the leaf
// and the list of particules
kernels[omp_get_thread_num()]->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentList());
kernels[omp_get_thread_num()]->P2M( octreeIterator.getCurrentCell() , octreeIterator.getCurrentListSources());
}
} while(octreeIterator.moveRight());
......@@ -254,10 +257,10 @@ public:
{
// There is a maximum of 26 neighbors
FList<ParticuleClass*>* neighbors[26];
kernels[omp_get_thread_num()]->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentList());
kernels[omp_get_thread_num()]->L2P(octreeIterator.getCurrentCell(), octreeIterator.getCurrentListTargets());
// need the current particules and neighbors particules
const int counter = tree->getLeafsNeighbors(neighbors, octreeIterator.getCurrentGlobalIndex(),heightMinusOne);
kernels[omp_get_thread_num()]->P2P( octreeIterator.getCurrentList() , neighbors, counter);
kernels[omp_get_thread_num()]->P2P( octreeIterator.getCurrentListTargets() , neighbors, counter);
}
} while(octreeIterator.moveRight());
}
......
......@@ -24,11 +24,14 @@
*
* The parallel algorithm is simple, each thread is taking a value from the iterator (protected by a mutex)
*/
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass, class ParticuleClass, class CellClass, int OctreeHeight, int SubtreeHeight>
template<template< class ParticuleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticuleClass, class CellClass,
template<class ParticuleClass> class LeafClass,
int OctreeHeight, int SubtreeHeight>
class FFMMAlgorithmThreaded : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
typedef FOctree<ParticuleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight> Octree;
typedef typename FOctree<ParticuleClass, CellClass, LeafClass, OctreeHeight, SubtreeHeight>::Iterator FOctreeIterator;
KernelClass<ParticuleClass, CellClass, OctreeHeight>* kernels[FThreadNumbers]; //< The kernels (one by thread)
Octree* const tree; //< The octree to work on
......@@ -100,7 +103,7 @@ public:
omp_set_lock(&mutex);
while(!stop){
CellClass*const cell = octreeIterator.getCurrentCell();
const FList<ParticuleClass*>* const particules = octreeIterator.getCurrentList();
const FList<ParticuleClass*>* const particules = octreeIterator.getCurrentListSources();
if(!octreeIterator.moveRight()) stop = true;
omp_unset_lock(&mutex);
......@@ -270,7 +273,7 @@ public:
// for each leafs
while(!stop){
const CellClass * const cell = octreeIterator.getCurrentCell();
FList<ParticuleClass*>* const particules = octreeIterator.getCurrentList();
FList<ParticuleClass*>* const particules = octreeIterator.getCurrentListTargets();
const MortonIndex cellIndex = octreeIterator.getCurrentGlobalIndex();
if(!octreeIterator.moveRight()) stop = true;
omp_unset_lock(&mutex);
......
......@@ -3,7 +3,7 @@
// /!\ Please, you must read the license at the bottom of this page
#include "FBasicParticule.hpp"
#include "FExtendPhysicalValue.hpp"
#include "../Extenssions/FExtendPhysicalValue.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......
#ifndef FSIMPLELEAF_HPP
#define FSIMPLELEAF_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Containers/FList.hpp"
#include "FAbstractLeaf.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FSimpleLeaf
* @brief
* Please read the license
* This class is used as a leaf in simple system (source AND target)
* here there is only one list that store all particules.
*/
template< class ParticuleClass >
class FSimpleLeaf : public FAbstractLeaf<ParticuleClass> {
FList<ParticuleClass*> particules;
public:
/** Default destructor */
virtual ~FSimpleLeaf(){
}
/**
* To add a new particule in the leaf
* @param particule the new particule
*/
void push(ParticuleClass* const particule){
this->particules.pushFront(particule);
}
/**
* To get all the sources in a leaf
* @return a pointer to the list of particules that are sources
*/
FList<ParticuleClass*>* getSources() {
return &this->particules;
}
/**
* To get all the target in a leaf
* @return a pointer to the list of particules that are targets
*/
FList<ParticuleClass*>* getTargets() {
return &this->particules;
}
};
#endif //FSIMPLELEAF_HPP
// [--LICENSE--]
......@@ -99,20 +99,22 @@ public:
/** This function test the octree to be sure that the fmm algorithm
* has worked completly.
*/
template< class ParticuleClass, class CellClass, int TreeHeight, int SizeSubLevels>
void ValidateFMMAlgo(FOctree<ParticuleClass, CellClass, TreeHeight , SizeSubLevels>* const tree, const int NbPart){
template< class ParticuleClass, class CellClass, template<class ParticuleClass> class LeafClass, int TreeHeight, int SizeSubLevels>
void ValidateFMMAlgo(FOctree<ParticuleClass, CellClass, LeafClass, TreeHeight , SizeSubLevels>* const tree){
std::cout << "Check Result\n";
int NbPart = 0;
{ // Check that each particule has been summed with all other
typename FOctree<FTestParticule, FTestCell, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
typename FOctree<FTestParticule, FTestCell, LeafClass, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentList()->getSize() ){
std::cout << "Problem P2M : " << (octreeIterator.getCurrentCell()->getDataUp() - octreeIterator.getCurrentList()->getSize()) << "\n";
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentListSources()->getSize() ){
std::cout << "Problem P2M : " << (octreeIterator.getCurrentCell()->getDataUp() - octreeIterator.getCurrentListSources()->getSize()) << "\n";
}
NbPart += octreeIterator.getCurrentListSources()->getSize();
} while(octreeIterator.moveRight());
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<FTestParticule, FTestCell, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
typename FOctree<FTestParticule, FTestCell, LeafClass, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
octreeIterator.moveDown();
long res = 0;
do{
......@@ -123,7 +125,7 @@ void ValidateFMMAlgo(FOctree<ParticuleClass, CellClass, TreeHeight , SizeSubLeve
}
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<FTestParticule, FTestCell, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
typename FOctree<FTestParticule, FTestCell, LeafClass, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = TreeHeight - 1 ; idxLevel > 1 ; --idxLevel ){
long res = 0;
......@@ -138,10 +140,10 @@ void ValidateFMMAlgo(FOctree<ParticuleClass, CellClass, TreeHeight , SizeSubLeve
}
}
{ // Check that each particule has been summed with all other
typename FOctree<FTestParticule, FTestCell, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
typename FOctree<FTestParticule, FTestCell, LeafClass, TreeHeight, SizeSubLevels>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
typename FList<FTestParticule*>::BasicIterator iter(*octreeIterator.getCurrentList());
typename FList<FTestParticule*>::BasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.isValide() ){
// If a particules has been impacted by less than NbPart - 1 (the current particule)
// there is a problem
......