Commit 26a0f75b authored by BRAMAS Berenger's avatar BRAMAS Berenger

update dyn block tree

parent 282ef597
......@@ -177,8 +177,8 @@ public:
cellMultipoles = (unsigned char*)FAlignedMemory::AllocateBytes<32>(inNumberOfCells*cellSizes->poleCellClassSize);
memset(cellMultipoles, 0, inNumberOfCells*cellSizes->poleCellClassSize);
cellLocals = (unsigned char*)FAlignedMemory::AllocateBytes<32>(inNumberOfCells*cellSizes->poleCellClassSize);
memset(cellLocals, 0, inNumberOfCells*cellSizes->poleCellClassSize);
cellLocals = (unsigned char*)FAlignedMemory::AllocateBytes<32>(inNumberOfCells*cellSizes->localCellClassSize);
memset(cellLocals, 0, inNumberOfCells*cellSizes->localCellClassSize);
// Set all index to not used
for(int idxCellPtr = 0 ; idxCellPtr < blockIndexesTableSize ; ++idxCellPtr){
......@@ -314,15 +314,21 @@ public:
}
/** Allocate a new cell by calling its constructor */
template<typename... CellConstructorParams>
void newCell(const MortonIndex inIndex, const int id, CellConstructorParams... args){
void newCell(const MortonIndex inIndex, const int id,
std::function<void(const MortonIndex mindex,
unsigned char* symbBuff, const size_t symbSize,
unsigned char* upBuff, const size_t upSize,
unsigned char* downBuff, const size_t downSize,
const int level)> BuildCellFunc,
const int inLevel){
FAssertLF(isInside(inIndex));
FAssertLF(!exists(inIndex));
FAssertLF(id < blockHeader->blockIndexesTableSize);
CompositeCellClass cell(&blockCells[id*cellSizes->symbCellClassSize],
&cellMultipoles[id*cellSizes->poleCellClassSize],
&cellLocals[id*cellSizes->localCellClassSize]);
cell.init(args...);
BuildCellFunc(inIndex,
&blockCells[id*cellSizes->symbCellClassSize],cellSizes->symbCellClassSize,
&cellMultipoles[id*cellSizes->poleCellClassSize],cellSizes->poleCellClassSize,
&cellLocals[id*cellSizes->localCellClassSize],cellSizes->localCellClassSize,
inLevel);
blockIndexesTable[inIndex-blockHeader->startingIndex] = id;
}
......
......@@ -62,7 +62,12 @@ public:
template<class OctreeClass>
FGroupTreeDyn(const int inTreeHeight, const int inNbElementsPerBlock, OctreeClass*const inOctreeSrc,
const size_t inSymbSizePerLevel[], const size_t inPoleSizePerLevel[], const size_t inLocalSizePerLevel[],
std::function<void(const MortonIndex, const void*, size_t*, size_t*)> GetSizeFunc)
std::function<void(const MortonIndex, const void*, size_t*, size_t*)> GetSizeFunc,
std::function<void(const MortonIndex mindex,
unsigned char* symbBuff, const size_t symbSize,
unsigned char* upBuff, const size_t upSize,
unsigned char* downBuff, const size_t downSize,
const int level)> BuildCellFunc)
: treeHeight(inTreeHeight), nbElementsPerBlock(inNbElementsPerBlock), cellBlocksPerLevel(nullptr),
boxCenter(inOctreeSrc->getBoxCenter()), boxCorner(inOctreeSrc->getBoxCenter(),-(inOctreeSrc->getBoxWidth()/2)),
boxWidth(inOctreeSrc->getBoxWidth()), boxWidthAtLeafLevel(inOctreeSrc->getBoxWidth()/FReal(1<<(inTreeHeight-1))){
......@@ -102,7 +107,7 @@ public:
const MortonIndex newNodeIndex = blockIteratorCellInOctree.getCurrentCell()->getMortonIndex();
const FTreeCoordinate newNodeCoordinate = blockIteratorCellInOctree.getCurrentCell()->getCoordinate();
// Add cell
newBlock->newCell(newNodeIndex, cellIdInBlock);
newBlock->newCell(newNodeIndex, cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
newNode.setMortonIndex(newNodeIndex);
......@@ -182,7 +187,7 @@ public:
while(cellIdInBlock != sizeOfBlock){
const MortonIndex newNodeIndex = blockIteratorInOctree.getCurrentCell()->getMortonIndex();
const FTreeCoordinate newNodeCoordinate = blockIteratorInOctree.getCurrentCell()->getCoordinate();
newBlock->newCell(newNodeIndex, cellIdInBlock);
newBlock->newCell(newNodeIndex, cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
newNode.setMortonIndex(newNodeIndex);
......@@ -221,6 +226,11 @@ public:
const FSize ,
unsigned char* , const size_t,
unsigned char* , const size_t)> InitLeafFunc,
std::function<void(const MortonIndex mindex,
unsigned char* symbBuff, const size_t symbSize,
unsigned char* upBuff, const size_t upSize,
unsigned char* downBuff, const size_t downSize,
const int level)> BuildCellFunc,
const bool particlesAreSorted = false, MortonIndex inLeftLimite = -1):
treeHeight(inTreeHeight),nbElementsPerBlock(inNbElementsPerBlock),cellBlocksPerLevel(nullptr),
boxCenter(inBoxCenter), boxCorner(inBoxCenter,-(inBoxWidth/2)), boxWidth(inBoxWidth),
......@@ -285,7 +295,7 @@ public:
inPoleSizePerLevel[idxLevel], inLocalSizePerLevel[idxLevel]);
{
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
......@@ -386,7 +396,7 @@ public:
inPoleSizePerLevel[idxLevel], inLocalSizePerLevel[idxLevel]);
// Init cells
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
......@@ -427,6 +437,11 @@ public:
const FSize ,
unsigned char* , const size_t,
unsigned char* , const size_t)> InitLeafFunc,
std::function<void(const MortonIndex mindex,
unsigned char* symbBuff, const size_t symbSize,
unsigned char* upBuff, const size_t upSize,
unsigned char* downBuff, const size_t downSize,
const int level)> BuildCellFunc,
const bool particlesAreSorted, const bool oneParent,
const FReal inCoverRatio = 0.0, MortonIndex inLeftLimite = -1):
treeHeight(inTreeHeight),nbElementsPerBlock(inNbElementsPerBlock),cellBlocksPerLevel(nullptr),
......@@ -497,7 +512,7 @@ public:
inPoleSizePerLevel[idxLevel], inLocalSizePerLevel[idxLevel]);
{
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
......@@ -599,7 +614,7 @@ public:
inPoleSizePerLevel[idxLevel], inLocalSizePerLevel[idxLevel]);
// Init cells
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
......@@ -655,7 +670,7 @@ public:
inPoleSizePerLevel[idxLevel], inLocalSizePerLevel[idxLevel]);
// Init cells
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock, BuildCellFunc, idxLevel);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
......
......@@ -110,10 +110,6 @@ public:
: symb(nullptr), up(nullptr), down(nullptr){
}
void init(){
resetToInitialState();
}
void release(){
// nothing
}
......@@ -265,7 +261,14 @@ int main(int argc, char* argv[]){
// size_t* inSymbSize, size_t* inDownSize) {
// GroupContainerClass::GetSizeContainerFunc<ContainerClass>(
// inIndex, inParticles, inSymbSize, inDownSize);
// });
// },
// [](const MortonIndex /*mindex*/,
// unsigned char* symbBuff, const size_t /*symbSize*/,
// unsigned char* upBuff, const size_t /*upSize*/,
// unsigned char* downBuff, const size_t /*downSize*/,
// const int /*inLevel*/){
// GroupCellClass cell(symbBuff, upBuff, downBuff);
// });
GroupOctreeClass groupedTree(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), groupSize,
cellSymbSizePerLevel.get(), cellUpSizePerLevel.get(), cellDownSizePerLevel.get(),
allParticles.get(), loader.getNumberOfParticles(),
......@@ -278,6 +281,13 @@ int main(int argc, char* argv[]){
unsigned char* downBuffer, const size_t inDownSize){
GroupContainerClass leaf(symbBuffer, downBuffer);
leaf.init(inIndex, inParticles, inNbParticles, inSymbSize, inDownSize);
},
[](const MortonIndex /*mindex*/,
unsigned char* symbBuff, const size_t /*symbSize*/,
unsigned char* upBuff, const size_t /*upSize*/,
unsigned char* downBuff, const size_t /*downSize*/,
const int /*inLevel*/){
GroupCellClass cell(symbBuff, upBuff, downBuff);
});
// GroupOctreeClass groupedTree(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), groupSize,
// cellSymbSizePerLevel.get(), cellUpSizePerLevel.get(), cellDownSizePerLevel.get(),
......@@ -291,6 +301,13 @@ int main(int argc, char* argv[]){
// unsigned char* downBuffer, const size_t inDownSize){
// GroupContainerClass leaf(symbBuffer, downBuffer);
// leaf.init(inIndex, inParticles, inNbParticles, inSymbSize, inDownSize);
// },
// [](const MortonIndex /*mindex*/,
// unsigned char* symbBuff, const size_t /*symbSize*/,
// unsigned char* upBuff, const size_t /*upSize*/,
// unsigned char* downBuff, const size_t /*downSize*/,
// const int /*inLevel*/){
// GroupCellClass cell(symbBuff, upBuff, downBuff);
// }
// false, true);
// GroupOctreeClass groupedTree(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), groupSize,
......@@ -305,6 +322,13 @@ int main(int argc, char* argv[]){
// unsigned char* downBuffer, const size_t inDownSize){
// GroupContainerClass leaf(symbBuffer, downBuffer);
// leaf.init(inIndex, inParticles, inNbParticles, inSymbSize, inDownSize);
// },
// [](const MortonIndex /*mindex*/,
// unsigned char* symbBuff, const size_t /*symbSize*/,
// unsigned char* upBuff, const size_t /*upSize*/,
// unsigned char* downBuff, const size_t /*downSize*/,
// const int /*inLevel*/){
// GroupCellClass cell(symbBuff, upBuff, downBuff);
// }
// false, true, 0.2);
groupedTree.printInfoBlocks();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment