Commit d303c1c9 authored by COULAUD Olivier's avatar COULAUD Olivier

fix problems, but the bug is still here in periodic

parent 482dd10c
...@@ -1922,6 +1922,7 @@ protected: ...@@ -1922,6 +1922,7 @@ protected:
hasPeriodicLeaves, hasPeriodicLeaves,
currentIter.coord, LeafIndex, AllDirs); currentIter.coord, LeafIndex, AllDirs);
int periodicNeighborsCounter = 0; int periodicNeighborsCounter = 0;
auto nonPeriodicCounter = 0 ;
// //
// First treat P2P interactions the classical interaction // First treat P2P interactions the classical interaction
// For Periodic cells // For Periodic cells
...@@ -1931,19 +1932,17 @@ protected: ...@@ -1931,19 +1932,17 @@ protected:
// //
if(hasPeriodicLeaves){ if(hasPeriodicLeaves){
// Current cell has periodic cells // Current cell has periodic cells
constexpr int maxPeriodicNeighbors = 19; constexpr int maxPeriodicNeighbors = 26;
ContainerClass* periodicNeighbors[maxPeriodicNeighbors]{}; ContainerClass* periodicNeighbors[maxPeriodicNeighbors]{};
int periodicNeighborPositions[maxPeriodicNeighbors]; int periodicNeighborPositions[maxPeriodicNeighbors];
std::array<FTreeCoordinate,maxPeriodicNeighbors> periodicOffsets{} ; // std::array<FTreeCoordinate,maxPeriodicNeighbors> periodicOffsets{} ;
// Move cells and particles // Move cells and particles
for(int idxNeig = 0 ; idxNeig < counter ; ++idxNeig){ for(int idxNeig = 0 ; idxNeig < counter ; ++idxNeig){
if( !offsets[idxNeig].equals(0,0,0) ){ // We need to move the cell if( !offsets[idxNeig].equals(0,0,0) ){ // We need to move the cell
// //
/// NEW NEW NEW NEW NEW NEW /// NEW NEW NEW NEW NEW NEW
// Put periodic cell into another cell (copy data) // Put periodic cell into another cell (copy data)
periodicNeighbors[periodicNeighborsCounter] = new ContainerClass(*(neighbors[idxNeig])) ; periodicNeighbors[periodicNeighborsCounter] = new ContainerClass(*(neighbors[idxNeig])) ;
/// NEW NEW NEW NEW NEW NEW
// newPos = pos + ofsset // newPos = pos + ofsset
FReal*const positionsX = periodicNeighbors[periodicNeighborsCounter]->getPositions()[0]; FReal*const positionsX = periodicNeighbors[periodicNeighborsCounter]->getPositions()[0];
FReal*const positionsY = periodicNeighbors[periodicNeighborsCounter]->getPositions()[1]; FReal*const positionsY = periodicNeighbors[periodicNeighborsCounter]->getPositions()[1];
...@@ -1957,13 +1956,16 @@ protected: ...@@ -1957,13 +1956,16 @@ protected:
positionsZ[idxPart] += zoffset; positionsZ[idxPart] += zoffset;
} }
periodicOffsets[periodicNeighborsCounter] = offsets[idxNeig]; // periodicOffsets[periodicNeighborsCounter] = offsets[idxNeig];
periodicNeighborPositions[periodicNeighborsCounter] = neighborPositions[idxNeig]; periodicNeighborPositions[periodicNeighborsCounter] = neighborPositions[idxNeig];
++periodicNeighborsCounter; ++periodicNeighborsCounter;
} }
else{ // set non periodic cells in neighbors and in neighborPositions else{ // set non periodic cells in neighbors and in neighborPositions
// nonPeriodicCounter versus idxNeig-periodicNeighborsCounter
std::cout << nonPeriodicCounter <<" "<< idxNeig-periodicNeighborsCounter <<std::endl;
neighbors[idxNeig-periodicNeighborsCounter] = neighbors[idxNeig]; neighbors[idxNeig-periodicNeighborsCounter] = neighbors[idxNeig];
neighborPositions[idxNeig-periodicNeighborsCounter] = neighborPositions[idxNeig]; neighborPositions[idxNeig-periodicNeighborsCounter] = neighborPositions[idxNeig];
++nonPeriodicCounter ;
} }
} }
// //
...@@ -1983,7 +1985,7 @@ protected: ...@@ -1983,7 +1985,7 @@ protected:
// //
myThreadkernels->P2P( currentIter.coord, currentIter.targets, myThreadkernels->P2P( currentIter.coord, currentIter.targets,
currentIter.sources, neighbors, currentIter.sources, neighbors,
neighborPositions, counter - periodicNeighborsCounter); neighborPositions, counter-periodicNeighborsCounter);
} }
} }
...@@ -2021,8 +2023,8 @@ protected: ...@@ -2021,8 +2023,8 @@ protected:
FAssertLF(leafsNeedOtherData.getSize() < std::numeric_limits<int>::max()); FAssertLF(leafsNeedOtherData.getSize() < std::numeric_limits<int>::max());
const int nbLeafToProceed = int(leafsNeedOtherData.getSize()); const int nbLeafToProceed = int(leafsNeedOtherData.getSize());
#pragma omp for schedule(dynamic, userChunkSize) //#pragma omp for schedule(dynamic, userChunkSize)
//#pragma omp single #pragma omp single
for(int idxLeafs = 0 ; idxLeafs < nbLeafToProceed ; ++idxLeafs){ for(int idxLeafs = 0 ; idxLeafs < nbLeafToProceed ; ++idxLeafs){
LeafData currentIter = leafsNeedOtherData[idxLeafs]; LeafData currentIter = leafsNeedOtherData[idxLeafs];
...@@ -2034,7 +2036,7 @@ protected: ...@@ -2034,7 +2036,7 @@ protected:
const int nbNeigh = this->getNeighborsIndexesPeriodic(currentIter.coord,limite, const int nbNeigh = this->getNeighborsIndexesPeriodic(currentIter.coord,limite,
indexesNeighbors,indexArray,AllDirs); indexesNeighbors,indexArray,AllDirs);
// std::cout << currentIter.coord.getMortonIndex() << " Cells comming from another process " << nbNeigh <<std::endl; // std::cout << currentIter.coord.getMortonIndex() << " Cells comming from another process " << nbNeigh <<std::endl;
std::array<ContainerClass*,19> periodicNeighbors{}; std::array<ContainerClass*,26> periodicNeighbors{};
int nbPeriodicCells=0 ; int nbPeriodicCells=0 ;
// Pourquoi pas de decallage de boite ??, // Pourquoi pas de decallage de boite ??,
...@@ -2067,7 +2069,7 @@ protected: ...@@ -2067,7 +2069,7 @@ protected:
if(movePos){ if(movePos){
/// NEW NEW NEW NEW NEW NEW /// NEW NEW NEW NEW NEW NEW
// Put periodic cell into another cell (copy data) // Put periodic cell into another cell (copy data)
periodicNeighbors[nbPeriodicCells] = new ContainerClass(*(neighbors[idxNeigh])) ; periodicNeighbors[nbPeriodicCells] = new ContainerClass(*(hypotheticNeighbor)) ;
// newPos = pos + ofsset // newPos = pos + ofsset
FReal*const positionsX = periodicNeighbors[nbPeriodicCells]->getPositions()[0]; FReal*const positionsX = periodicNeighbors[nbPeriodicCells]->getPositions()[0];
FReal*const positionsY = periodicNeighbors[nbPeriodicCells]->getPositions()[1]; FReal*const positionsY = periodicNeighbors[nbPeriodicCells]->getPositions()[1];
...@@ -2076,8 +2078,17 @@ protected: ...@@ -2076,8 +2078,17 @@ protected:
positionsX[idxPart] += offSet[0]; positionsX[idxPart] += offSet[0];
positionsY[idxPart] += offSet[1]; positionsY[idxPart] += offSet[1];
positionsZ[idxPart] += offSet[2]; positionsZ[idxPart] += offSet[2];
// std::cout <<indexesNeighbors[idxNeigh] << " " << positionsX[idxPart] << " "<< positionsY[idxPart] << " "<< positionsZ[idxPart] <<std::endl;
} }
#ifdef toto
std::cout << " MOVE CELLS "<<std::endl;
FReal*const positionsXX = hypotheticNeighbor->getPositions()[0];
FReal*const positionsYX = hypotheticNeighbor->getPositions()[1];
FReal*const positionsZX = hypotheticNeighbor->getPositions()[2];
auto idxPart = 0 ;
std::cout <<neighborPositions[idxNeigh] << " Shift " << positionsX[idxPart] << " "<< positionsY[idxPart] << " "<< positionsZ[idxPart] <<std::endl;
std::cout <<neighborPositions[idxNeigh] << " ORI " << positionsXX[idxPart] << " "<< positionsYX[idxPart] << " "<< positionsZX[idxPart] <<std::endl;
std::cout <<neighborPositions[idxNeigh] << " OFSET " << offSet[0] << " "<< offSet[1] << " "<< offSet[2] <<std::endl;
#endif
++nbPeriodicCells; ++nbPeriodicCells;
neighbors[counter] = periodicNeighbors[nbPeriodicCells]; neighbors[counter] = periodicNeighbors[nbPeriodicCells];
} }
...@@ -2086,11 +2097,7 @@ protected: ...@@ -2086,11 +2097,7 @@ protected:
} }
} }
// std::cout << " counter: "<< counter <<std::endl << " -->"; // std::cout << " counter: "<< counter <<std::endl << " -->";
if(counter){ if(counter){ // neighborPositions doesn't use)
// for( int i =0 ; i < nbPeriodicCells ; ++i){
// std::cout << " " << neighbors[i];
// }
// std::cout << std::endl;
myThreadkernels.P2PRemote( currentIter.coord, currentIter.targets, myThreadkernels.P2PRemote( currentIter.coord, currentIter.targets,
currentIter.sources, neighbors, neighborPositions, counter); currentIter.sources, neighbors, neighborPositions, counter);
if(nbPeriodicCells >0){ if(nbPeriodicCells >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