Commit 6b31f590 authored by berenger-bramas's avatar berenger-bramas

Big commit.

All the template organization has been refactorized.

Before :
FOctree< ClassParticle, ClassVector, etc...> myTree;
And in the FOctree class the code did some stuff automatically as:
putting ClassVector and ClassParticle together => ClassVector<ClassParticle>
But it must the user the give a ClassVector with the type ClassVector<template class T>

Now :
We decide everything :
FOctree< ClassParticle, ClassVector<ClassParticle>, etc... >
So the code is more generic but it must the user to describe with more
details his data in his main.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@135 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 69274c7e
......@@ -12,7 +12,7 @@
*
* If you want to create you own kernels you have to inherit from this class.
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass >
template< class ParticleClass, class CellClass, class ContainerClass >
class FAbstractKernels{
public:
/** Default destructor */
......@@ -25,7 +25,7 @@ public:
* @param pole the multipole to fill using the particles
* @param particles the particles from the same spacial boxe
*/
virtual void P2M(CellClass* const pole, const ContainerClass<ParticleClass>* const particles) = 0;
virtual void P2M(CellClass* const pole, const ContainerClass* const particles) = 0;
/**
* M2M
......@@ -66,7 +66,7 @@ public:
* @param local the leaf element (smaller boxe local element)
* @param particles the list of particles inside this boxe
*/
virtual void L2P(const CellClass* const local, ContainerClass<ParticleClass>* const particles) = 0;
virtual void L2P(const CellClass* const local, ContainerClass* const particles) = 0;
/**
* P2P
......@@ -76,8 +76,8 @@ public:
* @param directNeighborsParticles the particles from direct neighbors (this is an array of list)
* @param size the number of direct neighbors (the size of the array directNeighborsParticles)
*/
virtual void P2P(ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
const ContainerClass<ParticleClass>* const directNeighborsParticles[26], const int size) = 0;
virtual void P2P(ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
const ContainerClass* const directNeighborsParticles[26], const int size) = 0;
/**
* P2P
......@@ -90,8 +90,8 @@ public:
* @param size the number of direct neighbors (the size of the array directNeighborsParticles)
*/
virtual void P2P(const MortonIndex inCurrentLeafIndex,
ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
ContainerClass<ParticleClass>* const directNeighborsParticles[26], const MortonIndex inNeighborsIndex[26], const int size) = 0;
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const MortonIndex inNeighborsIndex[26], const int size) = 0;
};
......
......@@ -11,7 +11,7 @@
* This class is used to enable the use of typed particles
* (source XOR target) or simple system (source AND target)
*/
template< class ParticleClass,template <class ParticleClass> class ContainerClass >
template< class ParticleClass, class ContainerClass >
class FAbstractLeaf {
public:
/** Default destructor */
......@@ -32,7 +32,7 @@ public:
* Depending on the system to use the class that inherit
* this interface can sort the particle as they like.
*/
virtual ContainerClass<ParticleClass>* getSrc() = 0;
virtual ContainerClass* getSrc() = 0;
/**
* To get all the target in a leaf
......@@ -40,7 +40,7 @@ public:
* Depending on the system to use the class that inherit
* this interface can sort the particle as they like.
*/
virtual ContainerClass<ParticleClass>* getTargets() = 0;
virtual ContainerClass* getTargets() = 0;
};
......
......@@ -15,7 +15,7 @@
* This kernels simply shows the details of the information
* it receives (in debug)
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass>
template< class ParticleClass, class CellClass, class ContainerClass>
class FBasicKernels : public FAbstractKernels<ParticleClass,CellClass,ContainerClass> {
public:
/** Default destructor */
......@@ -23,7 +23,7 @@ public:
}
/** Print the number of particles */
virtual void P2M(CellClass* const , const ContainerClass<ParticleClass>* const ) {
virtual void P2M(CellClass* const , const ContainerClass* const ) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......@@ -47,21 +47,21 @@ public:
}
/** Print the number of particles */
virtual void L2P(const CellClass* const , ContainerClass<ParticleClass>* const ){
virtual void L2P(const CellClass* const , ContainerClass* const ){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
/** Print the number of particles */
virtual void P2P(ContainerClass<ParticleClass>* const FRestrict , const ContainerClass<ParticleClass>* const FRestrict ,
const ContainerClass<ParticleClass>* const [26], const int ) {
virtual void P2P(ContainerClass* const FRestrict , const ContainerClass* const FRestrict ,
const ContainerClass* const [26], const int ) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
virtual void P2P(const MortonIndex ,
ContainerClass<ParticleClass>* const FRestrict , const ContainerClass<ParticleClass>* const FRestrict ,
ContainerClass<ParticleClass>* const [26], const MortonIndex [26], const int ){
ContainerClass* const FRestrict , const ContainerClass* const FRestrict ,
ContainerClass* const [26], const MortonIndex [26], const int ){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -12,9 +12,9 @@
* This class is used as a leaf in simple system (source AND target)
* here there is only one list that store all particles.
*/
template< class ParticleClass ,template <class ParticleClass> class ContainerClass>
template< class ParticleClass , class ContainerClass>
class FSimpleLeaf : public FAbstractLeaf<ParticleClass,ContainerClass> {
ContainerClass<ParticleClass> particles;
ContainerClass particles;
public:
/** Default destructor */
......@@ -33,7 +33,7 @@ public:
* To get all the sources in a leaf
* @return a pointer to the list of particles that are sources
*/
ContainerClass<ParticleClass>* getSrc() {
ContainerClass* getSrc() {
return &this->particles;
}
......@@ -41,7 +41,7 @@ public:
* To get all the target in a leaf
* @return a pointer to the list of particles that are targets
*/
ContainerClass<ParticleClass>* getTargets() {
ContainerClass* getTargets() {
return &this->particles;
}
......
......@@ -19,7 +19,7 @@
* correctly done on particles.
* It used FTestCell and FTestParticle
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass>
template< class ParticleClass, class CellClass, class ContainerClass>
class FTestKernels : public FAbstractKernels<ParticleClass,CellClass,ContainerClass> {
public:
/** Default destructor */
......@@ -27,7 +27,7 @@ public:
}
// Before upward
void P2M(CellClass* const pole, const ContainerClass<ParticleClass>* const particles) {
void P2M(CellClass* const pole, const ContainerClass* const particles) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// the pole represents all particles under
pole->setDataUp(particles->getSize());
......@@ -69,10 +69,10 @@ public:
}
// After Downward
void L2P(const CellClass* const local, ContainerClass<ParticleClass>*const particles){
void L2P(const CellClass* const local, ContainerClass*const particles){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// The particles is impacted by the parent cell
typename ContainerClass<ParticleClass>::BasicIterator iter(*particles);
typename ContainerClass::BasicIterator iter(*particles);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + local->getDataDown());
iter.gotoNext();
......@@ -81,8 +81,8 @@ public:
}
// After Downward
void P2P(ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
const ContainerClass<ParticleClass>* const directNeighborsParticles[26], const int size) {
void P2P(ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
const ContainerClass* const directNeighborsParticles[26], const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// Each particles targeted is impacted by the particles sources
long inc = sources->getSize();
......@@ -93,7 +93,7 @@ public:
inc += directNeighborsParticles[idx]->getSize();
}
typename ContainerClass<ParticleClass>::BasicIterator iter(*targets);
typename ContainerClass::BasicIterator iter(*targets);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + inc);
iter.gotoNext();
......@@ -104,8 +104,8 @@ public:
// After Downward
void P2P(const MortonIndex ,
ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
ContainerClass<ParticleClass>* const directNeighborsParticles[26], const MortonIndex [26], const int size) {
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[26], const MortonIndex [26], const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// Each particles targeted is impacted by the particles sources
long inc = sources->getSize();
......@@ -116,7 +116,7 @@ public:
inc += directNeighborsParticles[idx]->getSize();
}
typename ContainerClass<ParticleClass>::BasicIterator iter(*targets);
typename ContainerClass::BasicIterator iter(*targets);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + inc);
iter.gotoNext();
......@@ -129,14 +129,13 @@ public:
/** This function test the octree to be sure that the fmm algorithm
* has worked completly.
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass > class LeafClass>
void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>* const tree){
template< class OctreeClass, class ParticleClass, class CellClass, class ContainerClass, class LeafClass>
void ValidateFMMAlgo(OctreeClass* const tree){
std::cout << "Check Result\n";
const int TreeHeight = tree->getHeight();
int NbPart = 0;
{ // Check that each particle has been summed with all other
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentListSrc()->getSize() ){
......@@ -146,7 +145,7 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, ContainerClass, LeafClass
} while(octreeIterator.moveRight());
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.moveDown();
long res = 0;
do{
......@@ -157,7 +156,7 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, ContainerClass, LeafClass
}
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = TreeHeight - 1 ; idxLevel > 1 ; --idxLevel ){
long res = 0;
......@@ -172,10 +171,10 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, ContainerClass, LeafClass
}
}
{ // Check that each particle has been summed with all other
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
typename ContainerClass<ParticleClass>::BasicIterator iter(*octreeIterator.getCurrentListTargets());
typename ContainerClass::BasicIterator iter(*octreeIterator.getCurrentListTargets());
const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc());
......
......@@ -13,10 +13,10 @@
* This class is used to enable the use of typed particles
* (source XOR target) or simple system (source AND target)
*/
template< class ParticleClass ,template <class ParticleClass> class ContainerClass>
template< class ParticleClass , class ContainerClass>
class FTypedLeaf : public FAbstractLeaf<ParticleClass,ContainerClass>, public FAssertable {
ContainerClass<ParticleClass> sources;
ContainerClass<ParticleClass> targets;
ContainerClass sources;
ContainerClass targets;
public:
/** Default destructor */
......@@ -37,7 +37,7 @@ public:
* To get all the sources in a leaf
* @return a pointer to the list of particles that are sources
*/
ContainerClass<ParticleClass>* getSrc() {
ContainerClass* getSrc() {
return &this->sources;
}
......@@ -45,7 +45,7 @@ public:
* To get all the target in a leaf
* @return a pointer to the list of particles that are targets
*/
ContainerClass<ParticleClass>* getTargets() {
ContainerClass* getTargets() {
return &this->targets;
}
......
......@@ -28,8 +28,7 @@
* Particle must extend {FExtendPosition}
* Cell must extend extend {FExtendPosition,FExtendMortonIndex}
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass > class LeafClass>
template< class ParticleClass, class CellClass, class ContainerClass, class LeafClass>
class FOctree {
FReal*const boxWidthAtLevel; //< to store the width of each boxs at all levels
......@@ -503,7 +502,7 @@ public:
* You have to be at the leaf level to call this function!
* @return current element list
*/
ContainerClass<ParticleClass>* getCurrentListSrc() {
ContainerClass* getCurrentListSrc() {
return this->current.leafTree->getLeafSrc(this->currentLocalIndex);
}
......@@ -511,7 +510,7 @@ public:
* You have to be at the leaf level to call this function!
* @return current element list
*/
ContainerClass<ParticleClass>* getCurrentListTargets() {
ContainerClass* getCurrentListTargets() {
return this->current.leafTree->getLeafTargets(this->currentLocalIndex);
}
......@@ -750,7 +749,7 @@ public:
* @return the cell if it exist or null (0)
*
*/
ContainerClass<ParticleClass>* getLeafSrc(const MortonIndex inIndex){
ContainerClass* getLeafSrc(const MortonIndex inIndex){
SubOctreeTypes workingTree;
workingTree.tree = &this->root;
const MortonIndex treeSubLeafMask = ~(~0x00LL << (3 * workingTree.tree->getSubOctreeHeight() ));
......@@ -775,7 +774,7 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighbors(ContainerClass<ParticleClass>* inNeighbors[26], const MortonIndex inIndex, const int inLevel){
int getLeafsNeighbors(ContainerClass* inNeighbors[26], const MortonIndex inIndex, const int inLevel){
MortonIndex inNeighborsIndex[26];
return getLeafsNeighborsWithIndex(inNeighbors, inNeighborsIndex, inIndex, inLevel);
}
......@@ -786,7 +785,7 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighborsWithIndex(ContainerClass<ParticleClass>* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
int getLeafsNeighborsWithIndex(ContainerClass* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel);
......@@ -809,7 +808,7 @@ public:
const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ);
const MortonIndex mortonOther = other.getMortonIndex(inLevel);
// get cell
ContainerClass<ParticleClass>* const leaf = getLeafSrc(mortonOther);
ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if not null
if(leaf){
inNeighborsIndex[idxNeighbors] = mortonOther;
......
......@@ -32,8 +32,7 @@
* Please refere to testOctree.cpp to see an example
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
template< class ParticleClass, class CellClass , class ContainerClass, class LeafClass>
class FAbstractSubOctree : protected FAssertable{
protected:
......@@ -270,12 +269,11 @@ public:
* Please refere to testOctree.cpp to see an example.
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
template< class ParticleClass, class CellClass , class ContainerClass, class LeafClass>
class FSubOctreeWithLeafs : public FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass> {
private:
LeafClass<ParticleClass, ContainerClass >** leafs; //< Leafs array
LeafClass** leafs; //< Leafs array
/** Disable copy */
FSubOctreeWithLeafs(const FSubOctreeWithLeafs&){}
......@@ -295,7 +293,7 @@ public:
const long cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->leafs = new LeafClass<ParticleClass, ContainerClass >*[cellsAtLeafLevel];
this->leafs = new LeafClass*[cellsAtLeafLevel];
assert(this->leafs, "Allocation failled", __LINE__, __FILE__);
for( long indexLeaf = 0 ; indexLeaf < cellsAtLeafLevel ; ++indexLeaf ){
......@@ -324,7 +322,7 @@ public:
const MortonIndex arrayIndex = FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::getLeafIndex(index,inTreeHeight);
// is there already a leaf?
if( !this->leafs[arrayIndex] ){
this->leafs[arrayIndex] = new LeafClass<ParticleClass, ContainerClass >();
this->leafs[arrayIndex] = new LeafClass();
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( arrayIndex , index, host, inBoxWidthAtLevel);
}
......@@ -335,32 +333,32 @@ public:
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particles at this index */
ContainerClass<ParticleClass>* getLeafSrc(const int index){
LeafClass<ParticleClass, ContainerClass >* const leaf = this->leafs[index];
ContainerClass* getLeafSrc(const int index){
LeafClass* const leaf = this->leafs[index];
return (leaf ? leaf->getSrc(): 0);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particles at this index */
ContainerClass<ParticleClass>* getLeafTargets(const int index){
LeafClass<ParticleClass, ContainerClass >* const leaf = this->leafs[index];
ContainerClass* getLeafTargets(const int index){
LeafClass* 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 particles at this index */
const ContainerClass<ParticleClass>* getLeafSrc(const int index) const {
LeafClass<ParticleClass, ContainerClass >* const leaf = this->leafs[index];
const ContainerClass* getLeafSrc(const int index) const {
LeafClass* const leaf = this->leafs[index];
return (leaf ? leaf->getSrc(): 0);
}
/** To get access to leafs elements
* @param index the position of the leaf
* @return the list of particles at this index */
const ContainerClass<ParticleClass>* getLeafTargets(const int index) const {
LeafClass<ParticleClass, ContainerClass >* const leaf = this->leafs[index];
const ContainerClass* getLeafTargets(const int index) const {
LeafClass* const leaf = this->leafs[index];
return (leaf ? leaf->getTargets() : 0);
}
......@@ -385,8 +383,7 @@ public:
*
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
template< class ParticleClass, class CellClass , class ContainerClass, class LeafClass>
class FSubOctree : public FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass> {
private:
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>** subleafs; //< Last levels is composed of suboctree
......
......@@ -22,16 +22,11 @@
*
* Of course this class does not deallocate pointer given in arguements.
*/
template<template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass> class KernelClass,
class ParticleClass, class CellClass,template <class ParticleClass> class ContainerClass,
template<class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
template<class OctreeClass, class ParticleClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithm : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticleClass, CellClass, ContainerClass, LeafClass> Octree;
typedef typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator FOctreeIterator;
Octree* const tree; //< The octree to work on
KernelClass<ParticleClass, CellClass,ContainerClass>* const kernels; //< The kernels
OctreeClass* const tree; //< The octree to work on
KernelClass* const kernels; //< The kernels
const int OctreeHeight;
......@@ -41,7 +36,7 @@ public:
* @param inKernels the kernels to call
* An assert is launched if one of the arguments is null
*/
FFmmAlgorithm(Octree* const inTree, KernelClass<ParticleClass,CellClass,ContainerClass>* const inKernels)
FFmmAlgorithm(OctreeClass* const inTree, KernelClass* const inKernels)
: tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()) {
assert(tree, "tree cannot be null", __LINE__, __FILE__);
......@@ -82,7 +77,7 @@ public:
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
FOctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
// Iterate on leafs
octreeIterator.gotoBottomLeft();
......@@ -111,11 +106,11 @@ public:
FDEBUG(FTic computationCounter);
// Start from leal level - 1
FOctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
octreeIterator.moveUp();
FOctreeIterator avoidGotoLeftIterator(octreeIterator);
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
// for each levels
for(int idxLevel = OctreeHeight - 2 ; idxLevel > 1 ; --idxLevel ){
......@@ -151,10 +146,10 @@ public:
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
FOctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.moveDown();
FOctreeIterator avoidGotoLeftIterator(octreeIterator);
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
const CellClass* neighbors[208];
......@@ -180,10 +175,10 @@ public:
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter );
FOctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.moveDown();
FOctreeIterator avoidGotoLeftIterator(octreeIterator);
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
const int heightMinusOne = OctreeHeight - 1;
// for each levels exepted leaf level
......@@ -220,10 +215,10 @@ public:
const int heightMinusOne = OctreeHeight - 1;
FOctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
// There is a maximum of 26 neighbors
ContainerClass<ParticleClass>* neighbors[26];
ContainerClass* neighbors[26];
MortonIndex neighborsIndex[26];
// for each leafs
do{
......
......@@ -28,19 +28,12 @@
*
* When using this algorithm the P2P is thread safe.
*/
template<template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass> class KernelClass,
class ParticleClass, class CellClass,template <class ParticleClass> class ContainerClass,
template<class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
template<class OctreeClass, class ParticleClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThread : protected FAssertable{
// To reduce the size of variable type based on foctree in this file
typedef FOctree<ParticleClass, CellClass, ContainerClass, LeafClass> Octree;
typedef typename FOctree<ParticleClass, CellClass,ContainerClass,LeafClass>::Iterator OctreeIterator;
typedef KernelClass<ParticleClass, CellClass,ContainerClass> Kernel;
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
Octree* const tree; //< The octree to work on
Kernel** kernels; //< The kernels
OctreeIterator* iterArray;
typename OctreeClass::Iterator* iterArray;
int leafsNumber;
static const int SizeShape = 3*3*3;
......@@ -56,15 +49,15 @@ public:
* @param inKernels the kernels to call
* An assert is launched if one of the arguments is null
*/
FFmmAlgorithmThread(Octree* const inTree, Kernel* const inKernels)
FFmmAlgorithmThread(OctreeClass* const inTree, KernelClass* const inKernels)
: tree(inTree) , kernels(0), iterArray(0), leafsNumber(0),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()) {
assert(tree, "tree cannot be null", __LINE__, __FILE__);
this->kernels = new Kernel*[MaxThreads];
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
this->kernels[idxThread] = new Kernel(*inKernels);
this->kernels[idxThread] = new KernelClass(*inKernels);
}
FDEBUG(FDebug::Controller << "FFmmAlgorithmThread (Max Thread " << omp_get_max_threads() << ")\n");
......@@ -92,7 +85,7 @@ public:
// Count leaf
leafsNumber = 0;
OctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
++leafsNumber;
......@@ -102,7 +95,7 @@ public:
++this->shapeLeaf[(coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3)];
} while(octreeIterator.moveRight());
iterArray = new OctreeIterator[leafsNumber];
iterArray = new typename OctreeClass::Iterator[leafsNumber];
assert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
bottomPass();
......@@ -128,7 +121,7 @@ public:
FDEBUG( FDebug::Controller.write("\tStart Bottom Pass\n").write(FDebug::Flush) );
FDEBUG(FTic counterTime);
OctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
int leafs = 0;
// Iterate on leafs
octreeIterator.gotoBottomLeft();
......@@ -140,7 +133,7 @@ public:
FDEBUG(FTic computationCounter);
#pragma omp parallel
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for nowait
for(int idxLeafs = 0 ; idxLeafs < leafs ; ++idxLeafs){
// We need the current cell that represent the leaf
......@@ -167,10 +160,10 @@ public:
FDEBUG(FTic computationCounter);
// Start from leal level - 1
OctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
octreeIterator.moveUp();
OctreeIterator avoidGotoLeftIterator(octreeIterator);
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
// for each levels
for(int idxLevel = OctreeHeight - 2 ; idxLevel > 1 ; --idxLevel ){
......@@ -186,7 +179,7 @@ public:
FDEBUG(computationCounter.tic());
#pragma omp parallel
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
#pragma omp for nowait
for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){
// We need the current cell and the child
......@@ -217,9 +210,9 @@ public:
FDEBUG(FTic counterTime);
FDEBUG(FTic computationCounter);
OctreeIterator octreeIterator(tree);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.moveDown();
OctreeIterator avoidGotoLeftIterator(octreeIterator);
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
// for each levels
for(int idxLevel = 2 ; idxLevel < OctreeHeight ; ++idxLevel ){
......@@ -235,7 +228,7 @@ public:
FDEBUG(computationCounter.tic());
#pragma omp parallel
{
Kernel * const myThreadkernels = kernels[omp_get_thread_num()];
KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];