Commit cd014f43 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Make the periodic using MPI thread working

parent 2614f593
......@@ -320,107 +320,6 @@ public:
// Periodic levels = levels <= 0
/////////////////////////////////////////////////////////////////////////////
/** This function process several M2M from level nbLevelsAboveRoot to level 0
* and give the final result
* @param result the cell at the last M2M
* @param root the starting cell
* @param startX the beginning of the index in x [0;endX]
* @param endX the end of the index in x [startX;1]
* @param startY the beginning of the index in y [0;endY]
* @param endY the end of the index in y [startY;1]
* @param startZ the beginning of the index in z [0;endZ]
* @param endZ the end of the index in z [startZ;1]
*/
void processTopM2MInIntervals( CellClass*const result, const CellClass& root, const int startX,
const int endX, const int startY, const int endY, const int startZ,
const int endZ){
// allocate array
CellClass*const cellsAtLevel = new CellClass[nbLevelsAboveRoot+2];
// process by using other function
processM2MInIntervals(cellsAtLevel,root,startX,endX,startY,endY,startZ,endZ);
// copy result
*result = cellsAtLevel[0];
delete[] cellsAtLevel;
}
/** This function process several M2M from level nbLevelsAboveRoot to level 0
* @param cellsAtLevel the intermediate results
* @param root the starting cell
* @param startX the beginning of the index in x [0;endX]
* @param endX the end of the index in x [startX;1]
* @param startY the beginning of the index in y [0;endY]
* @param endY the end of the index in y [startY;1]
* @param startZ the beginning of the index in z [0;endZ]
* @param endZ the end of the index in z [startZ;1]
*/
void processM2MInIntervals( CellClass cellsAtLevel[], const CellClass& root, const int startX,
const int endX, const int startY, const int endY, const int startZ,
const int endZ){
// start from the initial cell
cellsAtLevel[nbLevelsAboveRoot+1] = root;
// to create virtual children
CellClass* virtualChild[8];
// for all levels
for(int idxLevel = nbLevelsAboveRoot ; idxLevel >= 0 ; --idxLevel){
// reset children
memset(virtualChild, 0, sizeof(CellClass*)*8);
// fill the vector with previous result
for(int idxX = startX ; idxX <= endX ; ++idxX){
for(int idxY = startY ; idxY <= endY ; ++idxY){
for(int idxZ = startZ ; idxZ <= endZ ; ++idxZ){
virtualChild[childIndex(idxX,idxY,idxZ)] = &cellsAtLevel[idxLevel+1];
}
}
}
// compute the M2M
kernels->M2M( &cellsAtLevel[idxLevel], virtualChild, idxLevel + 2);
}
}
/** Fill an interactions neighbors with some intervals
* @param neighbors the vector to fill
* @param source the source cell to fill the vector
* @param startX the beginning of the index in x [-3;0]
* @param endX the end of the index in x [0;3]
* @param startY the beginning of the index in y [-3;0]
* @param endY the end of the index in y [0;3]
* @param startZ the beginning of the index in z [-3;0]
* @param endZ the end of the index in z [0;3]
* @return the number of position filled
*/
int fillM2LVectorFromIntervals(const CellClass* neighbors[343], const CellClass& source,
const int startX, const int endX, const int startY, const int endY,
const int startZ, const int endZ){
int counter = 0;
// for all x in interval
for(int idxX = startX ; idxX <= endX ; ++idxX){
// for all y in interval
for(int idxY = startY ; idxY <= endY ; ++idxY){
// for all z in interval
for(int idxZ = startZ ; idxZ <= endZ ; ++idxZ){
// do not fill close neigbors
if( FMath::Abs(idxX) > 1 || FMath::Abs(idxY) > 1 || FMath::Abs(idxZ) > 1 ){
neighbors[neighIndex(idxX,idxY,idxZ)] = &source;
++counter;
}
}
}
}
// return the number of position filled
return counter;
}
/** Get the index of a child (for the M2M and the L2L)
* @param x the x position in the children (from 0 to +1)
* @param y the y position in the children (from 0 to +1)
* @param z the z position in the children (from 0 to +1)
* @return the index (from 0 to 7)
*/
int childIndex(const int x, const int y, const int z) const {
return (x<<2) | (y<<1) | z;
}
/** Get the index of a interaction neighbors (for M2L)
* @param x the x position in the interactions (from -3 to +3)
* @param y the y position in the interactions (from -3 to +3)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -101,14 +101,14 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FLeafBalance balancer;
// FMpiTreeBuilder<TestParticle>::ArrayToTree(app.global(), particles, NbParticles, loader.getCenterOfBox(),
// loader.getBoxWidth(), tree.getHeight(), &finalParticles, &balancer);
FMpiTreeBuilder< TestParticle >::DistributeArrayToContainer(app.global(),particles,
NbParticles,
loader.getCenterOfBox(),
loader.getBoxWidth(),tree.getHeight(),
&finalParticles, &balancer);
// loader.getBoxWidth(), tree.getHeight(), &finalParticles, &balancer);
FMpiTreeBuilder< TestParticle >::DistributeArrayToContainer(app.global(),particles,
NbParticles,
loader.getCenterOfBox(),
loader.getBoxWidth(),tree.getHeight(),
&finalParticles, &balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position);
......@@ -138,6 +138,7 @@ int main(int argc, char ** argv){
{
long long totalRepeatedBox = algo.theoricalRepetition();
std::cout << "totalRepeatedBox in each dim is = " << totalRepeatedBox << "\n";
totalRepeatedBox = (totalRepeatedBox*totalRepeatedBox*totalRepeatedBox);
const long long NbParticlesEntireSystem = (NbParticles * app.global().processCount()) * totalRepeatedBox;
std::cout << "The total number of particles is " << NbParticlesEntireSystem << "\n";
......@@ -197,7 +198,7 @@ int main(int argc, char ** argv){
std::cout << "Index problem !!!!!" << std::endl;
}
if( algo.getWorkingInterval(idxLevel).min <= octreeIteratorSeq.getCurrentGlobalIndex()){
if( algo.getWorkingInterval(idxLevel).leftIndex <= octreeIteratorSeq.getCurrentGlobalIndex()){
if( octreeIterator.getCurrentCell()->getDataUp() != octreeIteratorSeq.getCurrentCell()->getDataUp() ){
std::cout << "Up problem at " << octreeIterator.getCurrentGlobalIndex() <<
" Good is " << octreeIteratorSeq.getCurrentCell()->getDataUp() <<
......@@ -237,6 +238,16 @@ int main(int argc, char ** argv){
ContainerClass* containerValide = (octreeIteratorSeq.getCurrentListTargets());
const long long int*const dataDownValide = containerValide->getDataDown();
if( octreeIterator.getCurrentGlobalIndex() != octreeIteratorSeq.getCurrentGlobalIndex()){
std::cout << "Index problem !!!!!" << std::endl;
}
if(container->getNbParticles() != containerValide->getNbParticles()){
std::cout << "Not the same number of particles on the leaf " << octreeIterator.getCurrentGlobalIndex() << "\n";
std::cout << "\t Correct is " << containerValide->getNbParticles() << "\n";
std::cout << "\t Not Correct is " << container->getNbParticles() << "\n";
}
for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){
// If a particles has been impacted by less than NbPart - 1 (the current particle)
// there is a problem
......@@ -250,7 +261,7 @@ int main(int argc, char ** argv){
<< " invalide " << octreeIterator.getCurrentListTargets()->getNbParticles() << std::endl;
}
}
} while(octreeIterator.moveRight());
} while(octreeIterator.moveRight() && octreeIteratorSeq.moveRight());
}
}
std::cout << "Test is over...\n";
......
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