Commit 94fe52ca authored by berenger-bramas's avatar berenger-bramas

Change to make the choice between List/Vector to store particles as

a template.
So this template has to be given to FOctree, FFmm and FKernels.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@114 2616d619-271b-44dc-8df4-d4a8f33a7222
parent a7fa1289
......@@ -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 CellClass, template <class ParticleClass> 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 FList<ParticleClass>* const particles) = 0;
virtual void P2M(CellClass* const pole, const ContainerClass<ParticleClass>* 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, FList<ParticleClass>* const particles) = 0;
virtual void L2P(const CellClass* const local, ContainerClass<ParticleClass>* 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(FList<ParticleClass>* const FRestrict targets, const FList<ParticleClass>* const FRestrict sources,
const FList<ParticleClass>* const directNeighborsParticles[26], const int size) = 0;
virtual void P2P(ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
const ContainerClass<ParticleClass>* 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,
FList<ParticleClass>* const FRestrict targets, const FList<ParticleClass>* const FRestrict sources,
FList<ParticleClass>* const directNeighborsParticles[26], const MortonIndex inNeighborsIndex[26], const int size) = 0;
ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
ContainerClass<ParticleClass>* 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,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 FList<ParticleClass>* getSrc() = 0;
virtual ContainerClass<ParticleClass>* 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 FList<ParticleClass>* getTargets() = 0;
virtual ContainerClass<ParticleClass>* getTargets() = 0;
};
......
......@@ -15,15 +15,15 @@
* This kernels simply shows the details of the information
* it receives (in debug)
*/
template< class ParticleClass, class CellClass>
class FBasicKernels : public FAbstractKernels<ParticleClass,CellClass> {
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass>
class FBasicKernels : public FAbstractKernels<ParticleClass,CellClass,ContainerClass> {
public:
/** Default destructor */
virtual ~FBasicKernels(){
}
/** Print the number of particles */
virtual void P2M(CellClass* const , const FList<ParticleClass>* const ) {
virtual void P2M(CellClass* const , const ContainerClass<ParticleClass>* 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 , FList<ParticleClass>* const ){
virtual void L2P(const CellClass* const , ContainerClass<ParticleClass>* const ){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
/** Print the number of particles */
virtual void P2P(FList<ParticleClass>* const FRestrict , const FList<ParticleClass>* const FRestrict ,
const FList<ParticleClass>* const [26], const int ) {
virtual void P2P(ContainerClass<ParticleClass>* const FRestrict , const ContainerClass<ParticleClass>* const FRestrict ,
const ContainerClass<ParticleClass>* const [26], const int ) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
virtual void P2P(const MortonIndex ,
FList<ParticleClass>* const FRestrict , const FList<ParticleClass>* const FRestrict ,
FList<ParticleClass>* const [26], const MortonIndex [26], const int ){
ContainerClass<ParticleClass>* const FRestrict , const ContainerClass<ParticleClass>* const FRestrict ,
ContainerClass<ParticleClass>* const [26], const MortonIndex [26], const int ){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
......
......@@ -2,7 +2,6 @@
#define FSIMPLELEAF_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Containers/FList.hpp"
#include "FAbstractLeaf.hpp"
/**
......@@ -13,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 >
class FSimpleLeaf : public FAbstractLeaf<ParticleClass> {
FList<ParticleClass> particles;
template< class ParticleClass ,template <class ParticleClass> class ContainerClass>
class FSimpleLeaf : public FAbstractLeaf<ParticleClass,ContainerClass> {
ContainerClass<ParticleClass> particles;
public:
/** Default destructor */
......@@ -34,7 +33,7 @@ public:
* To get all the sources in a leaf
* @return a pointer to the list of particles that are sources
*/
FList<ParticleClass>* getSrc() {
ContainerClass<ParticleClass>* getSrc() {
return &this->particles;
}
......@@ -42,7 +41,7 @@ public:
* To get all the target in a leaf
* @return a pointer to the list of particles that are targets
*/
FList<ParticleClass>* getTargets() {
ContainerClass<ParticleClass>* getTargets() {
return &this->particles;
}
......
......@@ -5,7 +5,6 @@
#include <iostream>
#include "FAbstractKernels.hpp"
#include "../Containers/FList.hpp"
#include "../Containers/FOctree.hpp"
#include "../Utils/FTrace.hpp"
......@@ -20,15 +19,15 @@
* correctly done on particles.
* It used FTestCell and FTestParticle
*/
template< class ParticleClass, class CellClass>
class FTestKernels : public FAbstractKernels<ParticleClass,CellClass> {
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass>
class FTestKernels : public FAbstractKernels<ParticleClass,CellClass,ContainerClass> {
public:
/** Default destructor */
virtual ~FTestKernels(){
}
// Before upward
void P2M(CellClass* const pole, const FList<ParticleClass>* const particles) {
void P2M(CellClass* const pole, const ContainerClass<ParticleClass>* const particles) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// the pole represents all particles under
pole->setDataUp(particles->getSize());
......@@ -70,10 +69,10 @@ public:
}
// After Downward
void L2P(const CellClass* const local, FList<ParticleClass>*const particles){
void L2P(const CellClass* const local, ContainerClass<ParticleClass>*const particles){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
// The particles is impacted by the parent cell
typename FList<ParticleClass>::BasicIterator iter(*particles);
typename ContainerClass<ParticleClass>::BasicIterator iter(*particles);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + local->getDataDown());
iter.gotoNext();
......@@ -82,8 +81,8 @@ public:
}
// After Downward
void P2P(FList<ParticleClass>* const FRestrict targets, const FList<ParticleClass>* const FRestrict sources,
const FList<ParticleClass>* const directNeighborsParticles[26], const int size) {
void P2P(ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
const ContainerClass<ParticleClass>* 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();
......@@ -94,7 +93,7 @@ public:
inc += directNeighborsParticles[idx]->getSize();
}
typename FList<ParticleClass>::BasicIterator iter(*targets);
typename ContainerClass<ParticleClass>::BasicIterator iter(*targets);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + inc);
iter.gotoNext();
......@@ -105,8 +104,8 @@ public:
// After Downward
void P2P(const MortonIndex ,
FList<ParticleClass>* const FRestrict targets, const FList<ParticleClass>* const FRestrict sources,
FList<ParticleClass>* const directNeighborsParticles[26], const MortonIndex [26], const int size) {
ContainerClass<ParticleClass>* const FRestrict targets, const ContainerClass<ParticleClass>* const FRestrict sources,
ContainerClass<ParticleClass>* 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();
......@@ -117,7 +116,7 @@ public:
inc += directNeighborsParticles[idx]->getSize();
}
typename FList<ParticleClass>::BasicIterator iter(*targets);
typename ContainerClass<ParticleClass>::BasicIterator iter(*targets);
while( iter.hasNotFinished() ){
iter.data().setDataDown(iter.data().getDataDown() + inc);
iter.gotoNext();
......@@ -130,13 +129,14 @@ 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 LeafClass>
void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, LeafClass>* const tree){
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){
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, LeafClass>::Iterator octreeIterator(tree);
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentListSrc()->getSize() ){
......@@ -146,7 +146,7 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, LeafClass>* const tree){
} while(octreeIterator.moveRight());
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<ParticleClass, CellClass, LeafClass>::Iterator octreeIterator(tree);
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
octreeIterator.moveDown();
long res = 0;
do{
......@@ -157,7 +157,7 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, LeafClass>* const tree){
}
}
{ // Ceck if there is number of NbPart summed at level 1
typename FOctree<ParticleClass, CellClass, LeafClass>::Iterator octreeIterator(tree);
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
for(int idxLevel = TreeHeight - 1 ; idxLevel > 1 ; --idxLevel ){
long res = 0;
......@@ -172,10 +172,10 @@ void ValidateFMMAlgo(FOctree<ParticleClass, CellClass, LeafClass>* const tree){
}
}
{ // Check that each particle has been summed with all other
typename FOctree<ParticleClass, CellClass, LeafClass>::Iterator octreeIterator(tree);
typename FOctree<ParticleClass, CellClass, ContainerClass, LeafClass>::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
typename FList<ParticleClass>::BasicIterator iter(*octreeIterator.getCurrentListTargets());
typename ContainerClass<ParticleClass>::BasicIterator iter(*octreeIterator.getCurrentListTargets());
const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc());
......
......@@ -2,7 +2,6 @@
#define FTYPEDLEAF_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Containers/FList.hpp"
#include "../Utils/FAssertable.hpp"
#include "FAbstractLeaf.hpp"
......@@ -14,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 >
class FTypedLeaf : public FAbstractLeaf<ParticleClass>, public FAssertable {
FList<ParticleClass> sources;
FList<ParticleClass> targets;
template< class ParticleClass ,template <class ParticleClass> class ContainerClass>
class FTypedLeaf : public FAbstractLeaf<ParticleClass,ContainerClass>, public FAssertable {
ContainerClass<ParticleClass> sources;
ContainerClass<ParticleClass> targets;
public:
/** Default destructor */
......@@ -38,7 +37,7 @@ public:
* To get all the sources in a leaf
* @return a pointer to the list of particles that are sources
*/
FList<ParticleClass>* getSrc() {
ContainerClass<ParticleClass>* getSrc() {
return &this->sources;
}
......@@ -46,7 +45,7 @@ public:
* To get all the target in a leaf
* @return a pointer to the list of particles that are targets
*/
FList<ParticleClass>* getTargets() {
ContainerClass<ParticleClass>* getTargets() {
return &this->targets;
}
......
......@@ -87,6 +87,7 @@ public:
occuped += object.writeDown(&buffer[occuped], Capacity - occuped);
}
// reset occuped memory
void clear(){
occuped = 0;
}
......
......@@ -5,11 +5,6 @@
#include "../Utils/FGlobal.hpp"
#define BIDON
#ifdef BIDON
#include "FVector.hpp"
#define FList FVector
#else
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FList
......@@ -270,6 +265,6 @@ public:
};
};
#endif
#endif //FLIST_HPP
// [--LICENSE--]
......@@ -28,7 +28,8 @@
* Particle must extend {FExtendPosition}
* Cell must extend extend {FExtendPosition,FExtendMortonIndex}
*/
template< class ParticleClass, class CellClass, template <class ParticleClass> class LeafClass>
template< class ParticleClass, class CellClass, template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass > class LeafClass>
class FOctree {
FReal*const boxWidthAtLevel; //< to store the width of each boxs at all levels
......@@ -36,7 +37,7 @@ class FOctree {
const int subHeight; //< tree height
const int leafIndex; //< index of leaf int array
FSubOctree< ParticleClass, CellClass , LeafClass> root; //< root suboctree
FSubOctree< ParticleClass, CellClass , ContainerClass, LeafClass> root; //< root suboctree
const F3DPosition boxCenter; //< the space system center
const F3DPosition boxCorner; //< the space system corner (used to compute morton index)
......@@ -133,18 +134,18 @@ public:
* depending if we are working on the bottom of the tree.
*/
union SubOctreeTypes {
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>* tree; //< Usual pointer to work
FSubOctree<ParticleClass,CellClass,LeafClass>* middleTree; //< To access to sub-octree under
FSubOctreeWithLeafs<ParticleClass,CellClass,LeafClass>* leafTree;//< To access to particles lists
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* tree; //< Usual pointer to work
FSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* middleTree; //< To access to sub-octree under
FSubOctreeWithLeafs<ParticleClass,CellClass,ContainerClass,LeafClass>* leafTree;//< To access to particles lists
};
/**
* This class is a const SubOctreeTypes
*/
union SubOctreeTypesConst {
const FAbstractSubOctree<ParticleClass,CellClass,LeafClass>* tree; //< Usual pointer to work
const FSubOctree<ParticleClass,CellClass,LeafClass>* middleTree; //< To access to sub-octree under
const FSubOctreeWithLeafs<ParticleClass,CellClass,LeafClass>* leafTree;//< To access to particles lists
const FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* tree; //< Usual pointer to work
const FSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* middleTree; //< To access to sub-octree under
const FSubOctreeWithLeafs<ParticleClass,CellClass,ContainerClass,LeafClass>* leafTree;//< To access to particles lists
};
/**
......@@ -502,7 +503,7 @@ public:
* You have to be at the leaf level to call this function!
* @return current element list
*/
FList<ParticleClass>* getCurrentListSrc() {
ContainerClass<ParticleClass>* getCurrentListSrc() {
return this->current.leafTree->getLeafSrc(this->currentLocalIndex);
}
......@@ -510,7 +511,7 @@ public:
* You have to be at the leaf level to call this function!
* @return current element list
*/
FList<ParticleClass>* getCurrentListTargets() {
ContainerClass<ParticleClass>* getCurrentListTargets() {
return this->current.leafTree->getLeafTargets(this->currentLocalIndex);
}
......@@ -749,7 +750,7 @@ public:
* @return the cell if it exist or null (0)
*
*/
FList<ParticleClass>* getLeafSrc(const MortonIndex inIndex){
ContainerClass<ParticleClass>* getLeafSrc(const MortonIndex inIndex){
SubOctreeTypes workingTree;
workingTree.tree = &this->root;
const MortonIndex treeSubLeafMask = ~(~0x00LL << (3 * workingTree.tree->getSubOctreeHeight() ));
......@@ -774,7 +775,7 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighbors(FList<ParticleClass>* inNeighbors[26], const MortonIndex inIndex, const int inLevel){
int getLeafsNeighbors(ContainerClass<ParticleClass>* inNeighbors[26], const MortonIndex inIndex, const int inLevel){
MortonIndex inNeighborsIndex[26];
return getLeafsNeighborsWithIndex(inNeighbors, inNeighborsIndex, inIndex, inLevel);
}
......@@ -785,7 +786,7 @@ public:
* @param inLevel the level of the element
* @return the number of neighbors
*/
int getLeafsNeighborsWithIndex(FList<ParticleClass>* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
int getLeafsNeighborsWithIndex(ContainerClass<ParticleClass>* inNeighbors[26], MortonIndex inNeighborsIndex[26], const MortonIndex inIndex, const int inLevel){
FTreeCoordinate center;
center.setPositionFromMorton(inIndex, inLevel);
......@@ -808,7 +809,7 @@ public:
const FTreeCoordinate other(center.getX() + idxX,center.getY() + idxY,center.getZ() + idxZ);
const MortonIndex mortonOther = other.getMortonIndex(inLevel);
// get cell
FList<ParticleClass>* const leaf = getLeafSrc(mortonOther);
ContainerClass<ParticleClass>* const leaf = getLeafSrc(mortonOther);
// add to list if not null
if(leaf){
inNeighborsIndex[idxNeighbors] = mortonOther;
......
......@@ -8,7 +8,6 @@
#include "../Utils/FMath.hpp"
#include "FTreeCoordinate.hpp"
#include "FList.hpp"
/**
......@@ -33,7 +32,8 @@
* Please refere to testOctree.cpp to see an example
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class LeafClass>
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
class FAbstractSubOctree : protected FAssertable{
protected:
......@@ -268,11 +268,12 @@ public:
* Please refere to testOctree.cpp to see an example.
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class LeafClass>
class FSubOctreeWithLeafs : public FAbstractSubOctree<ParticleClass,CellClass,LeafClass> {
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
class FSubOctreeWithLeafs : public FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass> {
private:
LeafClass<ParticleClass>** leafs; //< Leafs array
LeafClass<ParticleClass, ContainerClass >** leafs; //< Leafs array
/** Disable copy */
FSubOctreeWithLeafs(const FSubOctreeWithLeafs&){}
......@@ -286,13 +287,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<ParticleClass,CellClass,LeafClass>* const inParent, const long inIndexInParent,
FSubOctreeWithLeafs(FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* const inParent, const long inIndexInParent,
const int inSubOctreeHeight, const int inSubOctreePosition) :
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition, true) {
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition, true) {
const long cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->leafs = new LeafClass<ParticleClass>*[cellsAtLeafLevel];
this->leafs = new LeafClass<ParticleClass, ContainerClass >*[cellsAtLeafLevel];
assert(this->leafs, "Allocation failled", __LINE__, __FILE__);
for( long indexLeaf = 0 ; indexLeaf < cellsAtLeafLevel ; ++indexLeaf ){
......@@ -318,12 +319,12 @@ public:
*/
void insert(const MortonIndex index, const FTreeCoordinate& host, const ParticleClass& inParticle, const int inTreeHeight, const FReal* const inBoxWidthAtLevel){
// Get the morton index for the leaf level
const MortonIndex arrayIndex = FAbstractSubOctree<ParticleClass,CellClass,LeafClass>::getLeafIndex(index,inTreeHeight);
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>();
this->leafs[arrayIndex] = new LeafClass<ParticleClass, ContainerClass >();
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>::newLeafInserted( arrayIndex , index, host, inBoxWidthAtLevel);
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( arrayIndex , index, host, inBoxWidthAtLevel);
}
// add particle to leaf list
this->leafs[arrayIndex]->push(inParticle);
......@@ -332,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 */
FList<ParticleClass>* getLeafSrc(const int index){
LeafClass<ParticleClass>* const leaf = this->leafs[index];
ContainerClass<ParticleClass>* getLeafSrc(const int index){
LeafClass<ParticleClass, ContainerClass >* 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 */
FList<ParticleClass>* getLeafTargets(const int index){
LeafClass<ParticleClass>* const leaf = this->leafs[index];
ContainerClass<ParticleClass>* getLeafTargets(const int index){
LeafClass<ParticleClass, ContainerClass >* 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 FList<ParticleClass>* getLeafSrc(const int index) const {
LeafClass<ParticleClass>* const leaf = this->leafs[index];
const ContainerClass<ParticleClass>* getLeafSrc(const int index) const {
LeafClass<ParticleClass, ContainerClass >* 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 FList<ParticleClass>* getLeafTargets(const int index) const {
LeafClass<ParticleClass>* const leaf = this->leafs[index];
const ContainerClass<ParticleClass>* getLeafTargets(const int index) const {
LeafClass<ParticleClass, ContainerClass >* const leaf = this->leafs[index];
return (leaf ? leaf->getTargets() : 0);
}
......@@ -382,10 +383,11 @@ public:
*
* @warning Give the particleClass & cellClass
*/
template< class ParticleClass, class CellClass , template <class ParticleClass> class LeafClass>
class FSubOctree : public FAbstractSubOctree<ParticleClass,CellClass,LeafClass> {
template< class ParticleClass, class CellClass , template <class ParticleClass> class ContainerClass,
template <class ParticleClass, template <class ParticleClass> class ContainerClass> class LeafClass>
class FSubOctree : public FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass> {
private:
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>** subleafs; //< Last levels is composed of suboctree
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>** subleafs; //< Last levels is composed of suboctree
/** Disable copy */
FSubOctree(const FSubOctree&){}
......@@ -399,12 +401,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<ParticleClass,CellClass,LeafClass>* const inParent, const long inIndexInParent,
FSubOctree(FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>* const inParent, const long inIndexInParent,
const int inSubOctreeHeight, const int inSubOctreePosition) :
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition, false) {
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>(inParent, inIndexInParent, inSubOctreeHeight, inSubOctreePosition, false) {
const long cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->subleafs = new FAbstractSubOctree<ParticleClass,CellClass,LeafClass>*[cellsAtLeafLevel];
this->subleafs = new FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>*[cellsAtLeafLevel];
assert(this->subleafs, "Allocation failled", __LINE__, __FILE__);
for( int indexLeaf = 0 ; indexLeaf < cellsAtLeafLevel ; ++indexLeaf ){
......@@ -429,7 +431,7 @@ public:
void insert(const MortonIndex index, const FTreeCoordinate& host, const ParticleClass& inParticle, 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<ParticleClass,CellClass,LeafClass>::getLeafIndex(index,inTreeHeight);
const MortonIndex arrayIndex = FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::getLeafIndex(index,inTreeHeight);
// Is there already a leaf?
if( !this->subleafs[arrayIndex] ){
// We need to create leaf sub octree
......@@ -442,7 +444,7 @@ public:
}
// Or next suboctree contains the reail leaf!
else{
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticleClass,CellClass,LeafClass>(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
this->subleafs[arrayIndex] = new FSubOctreeWithLeafs<ParticleClass,CellClass,ContainerClass,LeafClass>(this,arrayIndex,nextSubOctreeHeight,nextSubOctreePosition);
}
const FTreeCoordinate hostAtLevel(
......@@ -451,7 +453,7 @@ public:
host.getZ() >> (inTreeHeight - nextSubOctreePosition ));
// We need to inform parent class
FAbstractSubOctree<ParticleClass,CellClass,LeafClass>::newLeafInserted( arrayIndex, index >> (3 * (inTreeHeight-nextSubOctreePosition) ), hostAtLevel, inBoxWidthAtLevel);
FAbstractSubOctree<ParticleClass,CellClass,ContainerClass,LeafClass>::newLeafInserted( arrayIndex, index >> (3 * (inTreeHeight-nextSubOctreePosition) ), hostAtLevel, inBoxWidthAtLevel);
}