Commit 725ebabf authored by BRAMAS Berenger's avatar BRAMAS Berenger

Update blocked tree to have lighter blocks - the tables of indexes has been...

Update blocked tree to have lighter blocks - the tables of indexes has been removed for non existing cells - should be tested and the opencl code is not up to date for now
parent e6e5ca8f
This diff is collapsed.
This diff is collapsed.
......@@ -25,7 +25,6 @@ class FGroupOfParticles {
MortonIndex startingIndex;
MortonIndex endingIndex;
int numberOfLeavesInBlock;
int blockIndexesTableSize;
//< The real number of particles allocated
FSize nbParticlesAllocatedInGroup;
......@@ -41,6 +40,7 @@ class FGroupOfParticles {
/** Information about a leaf */
struct alignas(FStarPUDefaultAlign::StructAlign) LeafHeader {
MortonIndex mindex;
FSize nbParticles;
size_t offSet;
};
......@@ -60,9 +60,6 @@ protected:
return nbParticles + (MemoryAlignementParticles - (nbParticles%MemoryAlignementParticles));
}
//< This value is for not used leaves
static const int LeafIsEmptyFlag = -1;
//< The size of memoryBuffer in byte
size_t allocatedMemoryInByte;
//< Pointer to a block memory
......@@ -70,8 +67,6 @@ protected:
//< Pointer to the header inside the block memory
BlockHeader* blockHeader;
//< Pointer to the indexes table inside the block memory
int* blockIndexesTable;
//< Pointer to leaves information
LeafHeader* leafHeader;
//< The total number of particles in the group
......@@ -96,13 +91,11 @@ public:
FGroupOfParticles(unsigned char* inBuffer, const size_t inAllocatedMemoryInByte,
unsigned char* inAttributes)
: allocatedMemoryInByte(inAllocatedMemoryInByte), memoryBuffer(inBuffer),
blockHeader(nullptr), blockIndexesTable(nullptr), leafHeader(nullptr), nbParticlesInGroup(0),
blockHeader(nullptr), leafHeader(nullptr), nbParticlesInGroup(0),
attributesBuffer(nullptr), deleteBuffer(false){
// Move the pointers to the correct position
blockHeader = reinterpret_cast<BlockHeader*>(inBuffer);
inBuffer += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(inBuffer);
inBuffer += (blockHeader->blockIndexesTableSize*sizeof(int));
leafHeader = reinterpret_cast<LeafHeader*>(inBuffer);
// Init particle pointers
......@@ -133,7 +126,7 @@ public:
* @param inNumberOfLeaves total number of leaves in the interval (should be <= inEndingIndex-inEndingIndex)
*/
FGroupOfParticles(const MortonIndex inStartingIndex, const MortonIndex inEndingIndex, const int inNumberOfLeaves, const FSize inNbParticles)
: allocatedMemoryInByte(0), memoryBuffer(nullptr), blockHeader(nullptr), blockIndexesTable(nullptr), leafHeader(nullptr), nbParticlesInGroup(inNbParticles),
: allocatedMemoryInByte(0), memoryBuffer(nullptr), blockHeader(nullptr), leafHeader(nullptr), nbParticlesInGroup(inNbParticles),
deleteBuffer(true){
memset(particlePosition, 0, sizeof(particlePosition));
memset(particleAttributes, 0, sizeof(particleAttributes));
......@@ -141,12 +134,11 @@ public:
const FSize nbParticlesAllocatedInGroup = RoundToUpperParticles(nbParticlesInGroup+(MemoryAlignementParticles-1)*inNumberOfLeaves);
// Find the number of leaf to allocate in the blocks
const int blockIndexesTableSize = int(inEndingIndex-inStartingIndex);
FAssertLF(inNumberOfLeaves <= blockIndexesTableSize);
FAssertLF(int(inEndingIndex-inStartingIndex) >= inNumberOfLeaves);
// Total number of bytes in the block
const size_t sizeOfOneParticle = (3*sizeof(FReal) + NbSymbAttributes*sizeof(AttributeClass));
const size_t memoryToAlloc = sizeof(BlockHeader)
+ (blockIndexesTableSize*sizeof(int))
+ (inNumberOfLeaves*sizeof(MortonIndex))
+ (inNumberOfLeaves*sizeof(LeafHeader))
+ nbParticlesAllocatedInGroup*sizeOfOneParticle;
......@@ -161,15 +153,12 @@ public:
unsigned char* bufferPtr = memoryBuffer;
blockHeader = reinterpret_cast<BlockHeader*>(bufferPtr);
bufferPtr += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(bufferPtr);
bufferPtr += (blockIndexesTableSize*sizeof(int));
leafHeader = reinterpret_cast<LeafHeader*>(bufferPtr);
// Init header
blockHeader->startingIndex = inStartingIndex;
blockHeader->endingIndex = inEndingIndex;
blockHeader->numberOfLeavesInBlock = inNumberOfLeaves;
blockHeader->blockIndexesTableSize = blockIndexesTableSize;
blockHeader->nbParticlesAllocatedInGroup = nbParticlesAllocatedInGroup;
// Init particle pointers
......@@ -197,8 +186,8 @@ public:
}
// Set all index to not used
for(int idxLeafPtr = 0 ; idxLeafPtr < blockIndexesTableSize ; ++idxLeafPtr){
blockIndexesTable[idxLeafPtr] = LeafIsEmptyFlag;
for(int idxLeafPtr = 0 ; idxLeafPtr < inNumberOfLeaves ; ++idxLeafPtr){
leafHeader[idxLeafPtr].mindex = -1;
}
}
......@@ -262,7 +251,7 @@ public:
/** The size of the interval endingIndex-startingIndex (set from the constructor) */
int getSizeOfInterval() const {
return blockHeader->blockIndexesTableSize;
return int(blockHeader->endingIndex-blockHeader->startingIndex);
}
/** Return true if inIndex should be located in the current block */
......@@ -270,20 +259,45 @@ public:
return blockHeader->startingIndex <= inIndex && inIndex < blockHeader->endingIndex;
}
/** Return the idx in array of the cell */
MortonIndex getLeafMortonIndex(const int id) const{
FAssertLF(id < blockHeader->numberOfLeavesInBlock);
return leafHeader[id].mindex;
}
/** Check if a cell exist (by binary search) and return it index */
int getLeafIndex(const MortonIndex leafIdx) const{
int idxLeft = 0;
int idxRight = blockHeader->numberOfLeavesInBlock-1;
while(idxLeft <= idxRight){
const int idxMiddle = (idxLeft+idxRight)/2;
if(leafHeader[idxMiddle].mindex == leafIdx){
return idxMiddle;
}
if(leafIdx < leafHeader[idxMiddle].mindex){
idxRight = idxMiddle-1;
}
else{
idxLeft = idxMiddle+1;
}
}
return -1;
}
/** Return true if inIndex is located in the current block and is not empty */
bool exists(const MortonIndex inIndex) const {
return isInside(inIndex) && (blockIndexesTable[inIndex-blockHeader->startingIndex] != LeafIsEmptyFlag);
return isInside(inIndex) && (getLeafIndex(inIndex) != -1);
}
/** Allocate a new leaf by calling its constructor */
size_t newLeaf(const MortonIndex inIndex, const int id, const FSize nbParticles, const size_t offsetInGroup){
FAssertLF(isInside(inIndex));
FAssertLF(!exists(inIndex));
FAssertLF(id < blockHeader->blockIndexesTableSize);
FAssertLF(id < blockHeader->numberOfLeavesInBlock);
FAssertLF(offsetInGroup < size_t(blockHeader->nbParticlesAllocatedInGroup));
blockIndexesTable[inIndex-blockHeader->startingIndex] = id;
leafHeader[id].nbParticles = nbParticles;
leafHeader[id].offSet = offsetInGroup;
leafHeader[id].mindex = inIndex;
const size_t nextLeafOffsetInGroup = RoundToUpperParticles(offsetInGroup+nbParticles);
FAssertLF(nextLeafOffsetInGroup <= size_t(blockHeader->nbParticlesAllocatedInGroup + MemoryAlignementParticles));
......@@ -293,33 +307,27 @@ public:
/** Iterate on each allocated leaves */
template<class ParticlesAttachedClass>
void forEachLeaf(std::function<void(ParticlesAttachedClass*)> function){
for(int idxLeafPtr = 0 ; idxLeafPtr < blockHeader->blockIndexesTableSize ; ++idxLeafPtr){
if(blockIndexesTable[idxLeafPtr] != LeafIsEmptyFlag){
const int id = blockIndexesTable[idxLeafPtr];
ParticlesAttachedClass leaf(leafHeader[id].nbParticles,
particlePosition[0] + leafHeader[id].offSet,
for(int idxLeafPtr = 0 ; idxLeafPtr < blockHeader->numberOfLeavesInBlock ; ++idxLeafPtr){
ParticlesAttachedClass leaf(leafHeader[idxLeafPtr].nbParticles,
particlePosition[0] + leafHeader[idxLeafPtr].offSet,
blockHeader->positionsLeadingDim,
(attributesBuffer?particleAttributes[NbSymbAttributes] + leafHeader[id].offSet:nullptr),
(attributesBuffer?particleAttributes[NbSymbAttributes] + leafHeader[idxLeafPtr].offSet:nullptr),
blockHeader->attributeLeadingDim);
function(&leaf);
}
}
}
/** Return the address of the leaf if it exists (or NULL) */
template<class ParticlesAttachedClass>
ParticlesAttachedClass getLeaf(const MortonIndex leafIndex){
if(blockIndexesTable[leafIndex - blockHeader->startingIndex] != LeafIsEmptyFlag){
const int id = blockIndexesTable[leafIndex - blockHeader->startingIndex];
ParticlesAttachedClass getLeaf(const int id){
FAssertLF(id < blockHeader->numberOfLeavesInBlock);
return ParticlesAttachedClass(leafHeader[id].nbParticles,
particlePosition[0] + leafHeader[id].offSet,
blockHeader->positionsLeadingDim,
(attributesBuffer?particleAttributes[NbSymbAttributes] + leafHeader[id].offSet:nullptr),
blockHeader->attributeLeadingDim);
}
return ParticlesAttachedClass();
}
};
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -40,13 +40,13 @@
template <class OctreeClass, class CellContainerClass, class KernelClass, class ParticleGroupClass, class StarPUCpuWrapperClass
#ifdef SCALFMM_ENABLE_CUDA_KERNEL
#ifdef SCALFMM_ENABLE_CUDA_KERNEL
, class StarPUCudaWrapperClass = FStarPUCudaWrapper<KernelClass, FCudaEmptyCellSymb, int, int, FCudaGroupOfCells<FCudaEmptyCellSymb, int, int>,
FCudaGroupOfParticles<int, 0, 0, int>, FCudaGroupAttachedLeaf<int, 0, 0, int>, FCudaEmptyKernel<int> >
#endif
#ifdef SCALFMM_ENABLE_OPENCL_KERNEL
#endif
#ifdef SCALFMM_ENABLE_OPENCL_KERNEL
, class StarPUOpenClWrapperClass = FStarPUOpenClWrapper<KernelClass, FOpenCLDeviceWrapper<KernelClass>>
#endif
#endif
>
class FGroupTaskStarPUAlgorithm : public FAbstractAlgorithm {
protected:
......@@ -121,15 +121,15 @@ public:
FGroupTaskStarPUAlgorithm(OctreeClass*const inTree, KernelClass* inKernels)
: tree(inTree), originalCpuKernel(inKernels),
cellHandles(nullptr),
#ifdef STARPU_USE_CPU
#ifdef STARPU_USE_CPU
cpuWrapper(tree->getHeight()),
#endif
#ifdef SCALFMM_ENABLE_CUDA_KERNEL
#endif
#ifdef SCALFMM_ENABLE_CUDA_KERNEL
cudaWrapper(tree->getHeight()),
#endif
#ifdef SCALFMM_ENABLE_OPENCL_KERNEL
#endif
#ifdef SCALFMM_ENABLE_OPENCL_KERNEL
openclWrapper(tree->getHeight()),
#endif
#endif
wrapperptr(&wrappers){
FAssertLF(tree, "tree cannot be null");
FAssertLF(inKernels, "kernels cannot be null");
......@@ -245,8 +245,8 @@ protected:
FLOG( FLog::Controller << "\tStart FGroupTaskStarPUAlgorithm\n" );
const bool directOnly = (tree->getHeight() <= 2);
#pragma omp parallel
#pragma omp single
#pragma omp parallel
#pragma omp single
buildExternalInteractionVecs();
buildHandles();
......@@ -567,14 +567,16 @@ protected:
std::vector<BlockInteractions<ParticleGroupClass>>* externalInteractions = &externalInteractionsLeafLevel[idxGroup];
#pragma omp task default(none) firstprivate(idxGroup, containers, externalInteractions)
#pragma omp task default(none) firstprivate(idxGroup, containers, externalInteractions)
{ // Can be a task(inout:iterCells)
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = containers->getStartingIndex();
const MortonIndex blockEndIdx = containers->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
if(containers->exists(mindex)){
for(int leafIdx = 0 ; leafIdx < containers->getNumberOfLeavesInBlock() ; ++leafIdx){
const MortonIndex mindex = containers->getLeafMortonIndex(leafIdx);
// ParticleContainerClass particles = containers->template getLeaf<ParticleContainerClass>(leafIdx);
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
FTreeCoordinate coord(mindex, tree->getHeight()-1);
......@@ -589,11 +591,11 @@ protected:
property.insideIndex = mindex;
property.outIndex = interactionsIndexes[idxInter];
property.outPosition = interactionsPosition[idxInter];
property.insideIdxInBlock = leafIdx;
outsideInteractions.push_back(property);
}
}
}
}
// Sort to match external order
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
......@@ -641,19 +643,18 @@ protected:
std::vector<BlockInteractions<CellContainerClass>>* externalInteractions = &externalInteractionsAllLevel[idxLevel][idxGroup];
#pragma omp task default(none) firstprivate(idxGroup, currentCells, idxLevel, externalInteractions)
#pragma omp task default(none) firstprivate(idxGroup, currentCells, idxLevel, externalInteractions)
{
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = currentCells->getStartingIndex();
const MortonIndex blockEndIdx = currentCells->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
if(currentCells->exists(mindex)){
typename CellContainerClass::CompleteCellClass cell = currentCells->getCompleteCell(mindex);
FAssertLF(cell.getMortonIndex() == mindex);
for(int cellIdx = 0 ; cellIdx < currentCells->getNumberOfCellsInBlock() ; ++cellIdx){
const MortonIndex mindex = currentCells->getCellMortonIndex(cellIdx);
MortonIndex interactionsIndexes[189];
int interactionsPosition[189];
const FTreeCoordinate coord(cell.getCoordinate());
const FTreeCoordinate coord(mindex, idxLevel);
int counter = coord.getInteractionNeighbors(idxLevel,interactionsIndexes,interactionsPosition);
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
......@@ -665,11 +666,11 @@ protected:
property.insideIndex = mindex;
property.outIndex = interactionsIndexes[idxInter];
property.outPosition = interactionsPosition[idxInter];
property.insideIdxInBlock = cellIdx;
outsideInteractions.push_back(property);
}
}
}
}
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
......@@ -710,7 +711,7 @@ protected:
}
FLOG( cellTimer.tac(); );
#pragma omp taskwait
#pragma omp taskwait
FLOG( FLog::Controller << "\t\t Prepare in " << timer.tacAndElapsed() << "s\n" );
FLOG( FLog::Controller << "\t\t\t Prepare at leaf level in " << leafTimer.elapsed() << "s\n" );
......
......@@ -725,16 +725,13 @@ protected:
#pragma omp task default(none) firstprivate(idxGroup, currentCells, idxLevel, externalInteractions)
{
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = currentCells->getStartingIndex();
const MortonIndex blockEndIdx = currentCells->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
if(currentCells->exists(mindex)){
const typename CellContainerClass::CompleteCellClass cell = currentCells->getCompleteCell(mindex);
FAssertLF(cell.getMortonIndex() == mindex);
for(int idxCell = 0 ; idxCell < currentCells->getNumberOfCellsInBlock() ; ++idxCell){
const MortonIndex mindex = currentCells->getCellMortonIndex(idxCell);
MortonIndex interactionsIndexes[189];
int interactionsPosition[189];
const FTreeCoordinate coord(cell.getCoordinate());
const FTreeCoordinate coord(mindex, idxLevel);
int counter = coord.getInteractionNeighbors(idxLevel,interactionsIndexes,interactionsPosition);
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
......@@ -744,11 +741,11 @@ protected:
property.insideIndex = mindex;
property.outIndex = interactionsIndexes[idxInter];
property.outPosition = interactionsPosition[idxInter];
property.insideIdxInBlock = idxCell;
outsideInteractions.push_back(property);
}
}
}
}
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
......@@ -830,11 +827,10 @@ protected:
#pragma omp task default(none) firstprivate(idxGroup, containers, externalInteractions)
{ // Can be a task(inout:iterCells)
std::vector<OutOfBlockInteraction> outsideInteractions;
const MortonIndex blockStartIdx = containers->getStartingIndex();
const MortonIndex blockEndIdx = containers->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
for(int idxLeaf = 0 ; idxLeaf < containers->getNumberOfLeavesInBlock() ; ++idxLeaf){
// ParticleContainerClass particles = containers->template getLeaf<ParticleContainerClass>(mindex);
const MortonIndex mindex = containers->getLeafMortonIndex(idxLeaf);
if(containers->exists(mindex)){
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
......@@ -1163,8 +1159,10 @@ protected:
const MortonIndex blockStartIdx = containers->getStartingIndex();
const MortonIndex blockEndIdx = containers->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
if(containers->exists(mindex)){
for(int leafIdx = 0 ; leafIdx < containers->getNumberOfLeavesInBlock() ; ++leafIdx){
const MortonIndex mindex = containers->getLeafMortonIndex(leafIdx);
// ParticleContainerClass particles = containers->template getLeaf<ParticleContainerClass>(leafIdx);
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
FTreeCoordinate coord(mindex, tree->getHeight()-1);
......@@ -1179,11 +1177,11 @@ protected:
property.insideIndex = mindex;
property.outIndex = interactionsIndexes[idxInter];
property.outPosition = interactionsPosition[idxInter];
property.insideIdxInBlock = leafIdx;
outsideInteractions.push_back(property);
}
}
}
}
// Sort to match external order
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
......@@ -1237,13 +1235,12 @@ protected:
const MortonIndex blockStartIdx = currentCells->getStartingIndex();
const MortonIndex blockEndIdx = currentCells->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
if(currentCells->exists(mindex)){
typename CellContainerClass::CompleteCellClass cell = currentCells->getCompleteCell(mindex);
FAssertLF(cell.getMortonIndex() == mindex);
for(int cellIdx = 0 ; cellIdx < currentCells->getNumberOfCellsInBlock() ; ++cellIdx){
const MortonIndex mindex = currentCells->getCellMortonIndex(cellIdx);
MortonIndex interactionsIndexes[189];
int interactionsPosition[189];
const FTreeCoordinate coord(cell.getCoordinate());
const FTreeCoordinate coord(mindex, idxLevel);
int counter = coord.getInteractionNeighbors(idxLevel,interactionsIndexes,interactionsPosition);
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
......@@ -1255,11 +1252,11 @@ protected:
property.insideIndex = mindex;
property.outIndex = interactionsIndexes[idxInter];
property.outPosition = interactionsPosition[idxInter];
property.insideIdxInBlock = cellIdx;
outsideInteractions.push_back(property);
}
}
}
}
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
......
......@@ -26,9 +26,6 @@ public:
typedef FGroupOfCells<CompositeCellClass, SymboleCellClass, PoleCellClass, LocalCellClass> CellGroupClass;
protected:
//< This value is for not used cells
static const int CellIsEmptyFlag = -1;
//< height of the tree (1 => only the root)
const int treeHeight;
//< max number of cells in a block
......@@ -100,7 +97,7 @@ public:
// Add cell
newBlock->newCell(newNodeIndex, cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
......@@ -109,7 +106,7 @@ public:
blockIteratorInOctree.getCurrentLeaf()->getSrc()->getNbParticles(),
nbParticlesOffsetBeforeLeaf);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(newNodeIndex);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(cellIdInBlock);
attachedLeaf.copyFromContainer(blockIteratorInOctree.getCurrentLeaf()->getSrc(), 0);
cellIdInBlock += 1;
......@@ -150,7 +147,7 @@ public:
const FTreeCoordinate newNodeCoordinate = blockIteratorInOctree.getCurrentCell()->getCoordinate();
newBlock->newCell(newNodeIndex, cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
......@@ -261,7 +258,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -271,7 +268,7 @@ public:
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(currentBlockIndexes[cellIdInBlock], cellIdInBlock,
nbParticlesPerLeaf[cellIdInBlock], nbParticlesOffsetBeforeLeaf);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(currentBlockIndexes[cellIdInBlock]);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(cellIdInBlock);
// Copy each particle from the original position
for(FSize idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){
attachedLeaf.setParticle(idxPart, particlesToSort[idxPart + offsetParticles].originalIndex, inParticlesContainer);
......@@ -345,7 +342,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -467,7 +464,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -477,7 +474,7 @@ public:
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(currentBlockIndexes[cellIdInBlock], cellIdInBlock,
nbParticlesPerLeaf[cellIdInBlock], nbParticlesOffsetBeforeLeaf);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(currentBlockIndexes[cellIdInBlock]);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(cellIdInBlock);
// Copy each particle from the original position
for(FSize idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){
attachedLeaf.setParticle(idxPart, particlesToSort[idxPart + offsetParticles].originalIndex, inParticlesContainer);
......@@ -552,7 +549,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -607,7 +604,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -697,7 +694,9 @@ public:
while(iterCells != iterEndCells && iterLeaves != iterEndLeaves){
(*iterCells)->forEachCell([&](CompositeCellClass aCell){
ParticlesAttachedClass aLeaf = (*iterLeaves)->template getLeaf <ParticlesAttachedClass>(aCell.getMortonIndex());
const int leafIdx = (*iterLeaves)->getLeafIndex(aCell.getMortonIndex());
FAssertLF(leafIdx != -1);
ParticlesAttachedClass aLeaf = (*iterLeaves)->template getLeaf <ParticlesAttachedClass>(leafIdx);
FAssertLF(aLeaf.isAttachedToSomething());
function(aCell, &aLeaf);
});
......
......@@ -27,9 +27,6 @@ public:
typedef FGroupOfCellsDyn<CompositeCellClass> CellGroupClass;
protected:
//< This value is for not used cells
static const int CellIsEmptyFlag = -1;
//< height of the tree (1 => only the root)
const int treeHeight;
//< max number of cells in a block
......@@ -109,7 +106,7 @@ public:
// Add cell
newBlock->newCell(newNodeIndex, cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
......@@ -146,7 +143,7 @@ public:
// Add leaf
newParticleBlock->newLeaf(newNodeIndex, cellIdInBlock);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(newNodeIndex);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(cellIdInBlock);
attachedLeaf.copyFromContainer(newNodeIndex,
blockIteratorLeafInOctree.getCurrentLeaf()->getSrc());
......@@ -189,7 +186,7 @@ public:
const FTreeCoordinate newNodeCoordinate = blockIteratorInOctree.getCurrentCell()->getCoordinate();
newBlock->newCell(newNodeIndex, cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
......@@ -297,7 +294,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -327,8 +324,8 @@ public:
InitLeafFunc(currentBlockIndexes[cellIdInBlock], &inParticlesContainer[offsetParts],
nbParticlesPerLeaf[cellIdInBlock],
newParticleBlock->getLeafSymbBuffer(currentBlockIndexes[cellIdInBlock]), symbSizePerLeaf[cellIdInBlock],
newParticleBlock->getLeafDownBuffer(currentBlockIndexes[cellIdInBlock]), downSizePerDown[cellIdInBlock]);
newParticleBlock->getLeafSymbBuffer(cellIdInBlock), symbSizePerLeaf[cellIdInBlock],
newParticleBlock->getLeafDownBuffer(cellIdInBlock), downSizePerDown[cellIdInBlock]);
offsetParts += nbParticlesPerLeaf[cellIdInBlock];
}
......@@ -398,7 +395,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -514,7 +511,7 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(cellIdInBlock);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
......@@ -544,8 +541,8 @@ public: