Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit f1079b46 authored by BRAMAS Berenger's avatar BRAMAS Berenger

update block algorithm it compiles without warning but does not work yet

parent f735f541
......@@ -14,7 +14,7 @@ template <unsigned NbAttributesPerParticle, class AttributeClass = FReal>
class FGroupAttachedLeaf {
protected:
//< Nb of particles in the current leaf
const int nbParticles;
int nbParticles;
//< Pointers to the positions of the particles
FReal* positionsPointers[3];
//< Pointers to the attributes of the particles
......
......@@ -9,7 +9,7 @@
#include <list>
#include <vector>
template <class OctreeClass, class CellContainerClass, class CellClass, class KernelClass, class ParticleContainerClass>
template <class OctreeClass, class CellContainerClass, class CellClass, class KernelClass, class ParticleGroupClass, class ParticleContainerClass>
class FGroupSeqAlgorithm {
protected:
struct OutOfBlockInteraction{
......@@ -51,11 +51,11 @@ public:
protected:
void bottomPass(){
typename std::list<ParticleContainerClass>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleContainerClass>::iterator endParticles = tree->leavesEnd();
typename std::list<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename std::list<CellContainerClass>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::list<CellContainerClass>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename std::list<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::list<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
{ // Can be a task(in:iterParticles, out:iterCells)
......@@ -65,7 +65,7 @@ protected:
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
CellClass* cell = (*iterCells)->getCell(mindex);
if(cell){
ParticleContainerClass particles = (*iterParticles)->getLeaf(mindex);
ParticleContainerClass particles = (*iterParticles)->template getLeaf<ParticleContainerClass>(mindex);
FAssertLF(particles.isAttachedToSomething());
kernels->P2M(cell, &particles);
}
......@@ -81,11 +81,11 @@ protected:
void upwardPass(){
for(int idxLevel = tree->getHeight()-2 ; idxLevel >= 2 ; --idxLevel){
typename std::list<CellContainerClass>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass>::iterator endCells = tree->cellsEnd(idxLevel);
typename std::list<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename std::list<CellContainerClass>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::list<CellContainerClass>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename std::list<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::list<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
{ // Can be a task(in:iterParticles, out:iterChildCells ...)
......@@ -121,8 +121,8 @@ protected:
void transferPass(){
for(int idxLevel = tree->getHeight()-1 ; idxLevel >= 2 ; --idxLevel){
typename std::list<CellContainerClass>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass>::iterator endCells = tree->cellsEnd(idxLevel);
typename std::list<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
while(iterCells != endCells){
std::vector<OutOfBlockInteraction> outsideInteractions;
......@@ -139,7 +139,7 @@ protected:
FTreeCoordinate coord(mindex, idxLevel);
int counter = coord.getInteractionNeighbors(idxLevel,interactionsIndexes,interactionsPosition);
CellClass* interactions[343];
const CellClass* interactions[343];
memset(interactions, 0, 343*sizeof(CellClass*));
int counterExistingCell = 0;
......@@ -167,11 +167,11 @@ protected:
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, long long, int>::QsSequential(outsideInteractions.data(),outsideInteractions.size());
FQuickSort<OutOfBlockInteraction, long long, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
typename std::list<CellContainerClass>::iterator iterLeftCells = tree->cellsBegin(idxLevel);
typename std::list<CellContainerClass*>::iterator iterLeftCells = tree->cellsBegin(idxLevel);
int currentOutInteraction = 0;
while(iterLeftCells != iterCells && currentOutInteraction < outsideInteractions.size()){
while(iterLeftCells != iterCells && currentOutInteraction < int(outsideInteractions.size())){
const MortonIndex blockStartIdx = (*iterLeftCells)->getStartingIndex();
const MortonIndex blockEndIdx = (*iterLeftCells)->getEndingIndex();
......@@ -180,7 +180,7 @@ protected:
}
int lastOutInteraction = currentOutInteraction + 1;
while(lastOutInteraction < outsideInteractions.size() && outsideInteractions[lastOutInteraction].outIndex < blockEndIdx){
while(lastOutInteraction < int(outsideInteractions.size()) && outsideInteractions[lastOutInteraction].outIndex < blockEndIdx){
lastOutInteraction += 1;
}
......@@ -190,7 +190,7 @@ protected:
if(interCell){
CellClass* cell = (*iterCells)->getCell(outsideInteractions[outInterIdx].insideIndex);
FAssertLF(cell);
CellClass* interactions[343];
const CellClass* interactions[343];
memset(interactions, 0, 343*sizeof(CellClass*));
interactions[outsideInteractions[outInterIdx].outPosition] = interCell;
const int counter = 1;
......@@ -215,11 +215,11 @@ protected:
void downardPass(){
for(int idxLevel = 2 ; idxLevel <= tree->getHeight()-2 ; ++idxLevel){
typename std::list<CellContainerClass>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass>::iterator endCells = tree->cellsEnd(idxLevel);
typename std::list<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::list<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename std::list<CellContainerClass>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::list<CellContainerClass>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename std::list<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::list<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
{ // Can be a task(in:iterParticles, inout:iterChildCells ...)
......@@ -255,11 +255,11 @@ protected:
void directPass(){
{
typename std::list<ParticleContainerClass>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleContainerClass>::iterator endParticles = tree->leavesEnd();
typename std::list<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename std::list<CellContainerClass>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::list<CellContainerClass>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename std::list<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::list<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
{ // Can be a task(in:iterCells, inout:iterParticles)
......@@ -269,7 +269,7 @@ protected:
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
CellClass* cell = (*iterCells)->getCell(mindex);
if(cell){
ParticleContainerClass particles = (*iterParticles)->getLeaf(mindex);
ParticleContainerClass particles = (*iterParticles)->template getLeaf<ParticleContainerClass>(mindex);
FAssertLF(particles.isAttachedToSomething());
kernels->P2M(cell, &particles);
}
......@@ -283,8 +283,8 @@ protected:
FAssertLF(iterParticles == endParticles && iterCells == endCells);
}
{
typename std::list<ParticleContainerClass>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleContainerClass>::iterator endParticles = tree->leavesEnd();
typename std::list<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::list<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
while(iterParticles != endParticles){
typename std::vector<OutOfBlockInteraction> outsideInteractions;
......@@ -294,7 +294,7 @@ protected:
const MortonIndex blockEndIdx = (*iterParticles)->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
ParticleContainerClass particles = (*iterParticles)->getLeaf(mindex);
ParticleContainerClass particles = (*iterParticles)->template getLeaf<ParticleContainerClass>(mindex);
if(particles.isAttachedToSomething()){
MortonIndex interactionsIndexes[26];
int interactionsPosition[26];
......@@ -308,7 +308,7 @@ protected:
for(int idxInter = 0 ; idxInter < counter ; ++idxInter){
if( blockStartIdx <= interactionsIndexes[idxInter] && interactionsIndexes[idxInter] < blockEndIdx ){
interactionsObjects[counterExistingCell] = (*iterParticles)->getLeaf(interactionsIndexes[idxInter]);
interactionsObjects[counterExistingCell] = (*iterParticles)->template getLeaf<ParticleContainerClass>(interactionsIndexes[idxInter]);
if(interactionsObjects[counterExistingCell].isAttachedToSomething()){
interactions[interactionsPosition[idxInter]] = &interactionsObjects[counterExistingCell];
counterExistingCell += 1;
......@@ -330,11 +330,11 @@ protected:
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, long long, int>::QsSequential(outsideInteractions.data(),outsideInteractions.size());
FQuickSort<OutOfBlockInteraction, long long, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
typename std::list<ParticleContainerClass>::iterator iterLeftParticles = tree->leavesBegin();
typename std::list<ParticleGroupClass*>::iterator iterLeftParticles = tree->leavesBegin();
int currentOutInteraction = 0;
while(iterLeftParticles != iterParticles && currentOutInteraction < outsideInteractions.size()){
while(iterLeftParticles != iterParticles && currentOutInteraction < int(outsideInteractions.size())){
const MortonIndex blockStartIdx = (*iterLeftParticles)->getStartingIndex();
const MortonIndex blockEndIdx = (*iterLeftParticles)->getEndingIndex();
......@@ -343,17 +343,17 @@ protected:
}
int lastOutInteraction = currentOutInteraction + 1;
while(lastOutInteraction < outsideInteractions.size() && outsideInteractions[lastOutInteraction].outIndex < blockEndIdx){
while(lastOutInteraction < int(outsideInteractions.size()) && outsideInteractions[lastOutInteraction].outIndex < blockEndIdx){
lastOutInteraction += 1;
}
{ // Can be a task(in:currentOutInteraction, in:outsideInteractions, in:lastOutInteraction, inout:iterLeftParticles, inout:iterParticles)
for(int outInterIdx = currentOutInteraction ; outInterIdx < lastOutInteraction ; ++outInterIdx){
ParticleContainerClass interParticles = (*iterLeftParticles)->getLeaf(outsideInteractions[outInterIdx].outIndex);
ParticleContainerClass interParticles = (*iterLeftParticles)->template getLeaf<ParticleContainerClass>(outsideInteractions[outInterIdx].outIndex);
if(interParticles.isAttachedToSomething()){
ParticleContainerClass particles = (*iterParticles)->getLeaf(outsideInteractions[outInterIdx].insideIndex);
ParticleContainerClass particles = (*iterParticles)->template getLeaf<ParticleContainerClass>(outsideInteractions[outInterIdx].insideIndex);
FAssertLF(particles.isAttachedToSomething());
CellClass* interactions[27];
ParticleContainerClass* interactions[27];
memset(interactions, 0, 27*sizeof(CellClass*));
interactions[outsideInteractions[outInterIdx].outPosition] = &interParticles;
const int counter = 1;
......
......@@ -13,10 +13,11 @@
#include <list>
#include <functional>
template <class CellClass, unsigned NbAttributesPerParticle, class AttributeClass = FReal>
template <class CellClass, class GroupAttachedLeafClass, unsigned NbAttributesPerParticle, class AttributeClass = FReal>
class FGroupTree {
public:
typedef FGroupAttachedLeaf<NbAttributesPerParticle,AttributeClass> BasicAttachedClass;
typedef GroupAttachedLeafClass BasicAttachedClass;
typedef FGroupOfParticles<NbAttributesPerParticle,AttributeClass> ParticleGroupClass;
typedef FGroupOfCells<CellClass> CellGroupClass;
protected:
......@@ -30,7 +31,7 @@ protected:
//< all the blocks of the tree
std::list<CellGroupClass*>* cellBlocksPerLevel;
//< all the blocks of leaves
std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*> particleBlocks;
std::list<ParticleGroupClass*> particleBlocks;
//< the space system center
const FPoint boxCenter;
......@@ -499,7 +500,7 @@ public:
}
delete[] cellBlocksPerLevel;
for (FGroupOfParticles<NbAttributesPerParticle,AttributeClass>* block: particleBlocks){
for (ParticleGroupClass* block: particleBlocks){
delete block;
}
}
......@@ -515,7 +516,7 @@ public:
*/
template<class ParticlesAttachedClass>
void forEachLeaf(std::function<void(ParticlesAttachedClass*)> function){
for (FGroupOfParticles<NbAttributesPerParticle,AttributeClass>* block: particleBlocks){
for (ParticleGroupClass* block: particleBlocks){
block->forEachLeaf(function);
}
}
......@@ -555,8 +556,8 @@ public:
typename std::list<CellGroupClass*>::iterator iterCells = cellBlocksPerLevel[treeHeight-1].begin();
const typename std::list<CellGroupClass*>::iterator iterEndCells = cellBlocksPerLevel[treeHeight-1].end();
typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::iterator iterLeaves = particleBlocks.begin();
const typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::iterator iterEndLeaves = particleBlocks.end();
typename std::list<ParticleGroupClass*>::iterator iterLeaves = particleBlocks.begin();
const typename std::list<ParticleGroupClass*>::iterator iterEndLeaves = particleBlocks.end();
while(iterCells != iterEndCells && iterLeaves != iterEndLeaves){
(*iterCells)->forEachCell([&](CellClass* aCell){
......@@ -598,7 +599,7 @@ public:
std::cout << "There are " << particleBlocks.size() << " leaf-groups.\n";
int idxGroup = 0;
int totalNbParticles = 0;
for (const FGroupOfParticles<NbAttributesPerParticle,AttributeClass>* block: particleBlocks){
for (const ParticleGroupClass* block: particleBlocks){
std::cout << "\t Group " << (idxGroup++);
std::cout << "\t Size = " << block->getNumberOfLeavesInBlock();
std::cout << "\t Starting Index = " << block->getStartingIndex();
......@@ -639,19 +640,19 @@ public:
}
typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::iterator leavesBegin(){
typename std::list<ParticleGroupClass*>::iterator leavesBegin(){
return particleBlocks.begin();
}
typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::const_iterator leavesBegin() const {
typename std::list<ParticleGroupClass*>::const_iterator leavesBegin() const {
return particleBlocks.begin();
}
typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::iterator leavesEnd(){
typename std::list<ParticleGroupClass*>::iterator leavesEnd(){
return particleBlocks.end();
}
typename std::list<FGroupOfParticles<NbAttributesPerParticle,AttributeClass>*>::const_iterator leavesEnd() const {
typename std::list<ParticleGroupClass*>::const_iterator leavesEnd() const {
return particleBlocks.end();
}
};
......
#ifndef FP2PGROUPPARTICLECONTAINER_HPP
#define FP2PGROUPPARTICLECONTAINER_HPP
#include "FGroupAttachedLeaf.hpp"
template<int NRHS = 1, int NLHS = 1>
class FP2PGroupParticleContainer : public FGroupAttachedLeaf<NRHS+4*NLHS, FReal> {
typedef FGroupAttachedLeaf<NRHS+4*NLHS, FReal> Parent;
public:
FP2PGroupParticleContainer(){}
FP2PGroupParticleContainer(const int inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition,
FReal* inAttributesBuffer, const size_t inLeadingAttributes)
: Parent(inNbParticles, inPositionBuffer, inLeadingPosition, inAttributesBuffer, inLeadingAttributes) {
}
FReal* getPhysicalValues(const int idxRhs = 0){
return Parent::getAttribute(0+idxRhs);
}
const FReal* getPhysicalValues(const int idxRhs = 0) const {
return Parent::getAttribute(0+idxRhs);
}
FReal* getPotentials(const int idxLhs = 0){
return Parent::getAttribute(NRHS+idxLhs);
}
const FReal* getPotentials(const int idxLhs = 0) const {
return Parent::getAttribute(NRHS+idxLhs);
}
FReal* getForcesX(const int idxLhs = 0){
return Parent::getAttribute(NRHS+NLHS+idxLhs);
}
const FReal* getForcesX(const int idxLhs = 0) const {
return Parent::getAttribute(NRHS+NLHS+idxLhs);
}
FReal* getForcesY(const int idxLhs = 0){
return Parent::getAttribute(NRHS+2*NLHS+idxLhs);
}
const FReal* getForcesY(const int idxLhs = 0) const {
return Parent::getAttribute(NRHS+2*NLHS+idxLhs);
}
FReal* getForcesZ(const int idxLhs = 0){
return Parent::getAttribute(NRHS+3*NLHS+idxLhs);
}
const FReal* getForcesZ(const int idxLhs = 0) const {
return Parent::getAttribute(NRHS+3*NLHS+idxLhs);
}
};
#endif // FP2PGROUPPARTICLECONTAINER_HPP
......@@ -24,6 +24,7 @@
#include "../../Src/Files/FFmaBinLoader.hpp"
#include "../../Src/GroupTree/FGroupSeqAlgorithm.hpp"
#include "../../Src/GroupTree/FP2PGroupParticleContainer.hpp"
int main(int argc, char* argv[]){
static const int P = 9;
......@@ -32,7 +33,7 @@ int main(int argc, char* argv[]){
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FOctree< CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FGroupTree< CellClass, 4, FReal> GroupOctreeClass;
typedef FGroupTree< CellClass, FP2PGroupParticleContainer<>, 4, FReal> GroupOctreeClass;
FTic counter;
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
......@@ -71,8 +72,13 @@ int main(int argc, char* argv[]){
typedef FRotationKernel< CellClass, ContainerClass , P> KernelClass;
FGroupSeqAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::BasicAttachedClass> algo(NULL,NULL);
typedef FRotationKernel< CellClass, FP2PGroupParticleContainer<> , P> KernelClass;
typedef FGroupSeqAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::ParticleGroupClass, FP2PGroupParticleContainer<> > GroupAlgorithm;
KernelClass kernel(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
GroupAlgorithm algo(&groupedTree2,&kernel);
algo.execute();
return 0;
}
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