Commit 482dd10c authored by COULAUD Olivier's avatar COULAUD Olivier

Manage periodic shift in cells comming from another processor

parent 338024f2
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "Utils/FEnv.hpp" #include "Utils/FEnv.hpp"
#include "Utils/FMpi.hpp" #include "Utils/FMpi.hpp"
#ifdef _OPENMP
#include <omp.h> #include <omp.h>
#endif
#include "FCoreCommon.hpp" #include "FCoreCommon.hpp"
#include "FP2PExclusion.hpp" #include "FP2PExclusion.hpp"
...@@ -2021,8 +2021,8 @@ protected: ...@@ -2021,8 +2021,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];
...@@ -2035,7 +2035,6 @@ protected: ...@@ -2035,7 +2035,6 @@ protected:
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*,19> periodicNeighbors{};
std::array<std::array<FReal,3>,19> periodicOffset{};
int nbPeriodicCells=0 ; int nbPeriodicCells=0 ;
// Pourquoi pas de decallage de boite ??, // Pourquoi pas de decallage de boite ??,
...@@ -2047,7 +2046,7 @@ protected: ...@@ -2047,7 +2046,7 @@ protected:
neighbors[counter] = hypotheticNeighbor; neighbors[counter] = hypotheticNeighbor;
neighborPositions[counter] = indexArray[idxNeigh]; neighborPositions[counter] = indexArray[idxNeigh];
FTreeCoordinate coord3d(indexesNeighbors[idxNeigh] ); FTreeCoordinate coord3d(indexesNeighbors[idxNeigh] );
std::array<FReal,3> & offSet = periodicOffset[nbPeriodicCells]; std::array<FReal,3> offSet{};
bool movePos = false ; bool movePos = false ;
coord3d-=currentIter.coord ; coord3d-=currentIter.coord ;
if (std::abs(coord3d.getX()) == limitem1 ){ // it's a periodic cell) if (std::abs(coord3d.getX()) == limitem1 ){ // it's a periodic cell)
...@@ -2066,22 +2065,21 @@ protected: ...@@ -2066,22 +2065,21 @@ protected:
// std::cout << " ( " << indexesNeighbors[idxNeigh] << " " << coord3d << " offset= " // std::cout << " ( " << indexesNeighbors[idxNeigh] << " " << coord3d << " offset= "
// <<offSet[0] << "," << offSet[1] << "," <<offSet[2] <<" )" ; // <<offSet[0] << "," << offSet[1] << "," <<offSet[2] <<" )" ;
if(movePos){ if(movePos){
periodicNeighbors[nbPeriodicCells] = hypotheticNeighbor;
/// 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)
///// HERE HERE HERE HERE HERE periodicNeighbors[nbPeriodicCells] = new ContainerClass(*(neighbors[idxNeigh])) ;
// ContainerClass * periodicNeighbors[nbPeriodicCells] = new ContainerClass(*(neighbors[idxNeig])) ; // newPos = pos + ofsset
/// NEW NEW NEW NEW NEW NEW FReal*const positionsX = periodicNeighbors[nbPeriodicCells]->getPositions()[0];
FReal*const positionsX = hypotheticNeighbor->getPositions()[0]; FReal*const positionsY = periodicNeighbors[nbPeriodicCells]->getPositions()[1];
FReal*const positionsY = hypotheticNeighbor->getPositions()[1]; FReal*const positionsZ = periodicNeighbors[nbPeriodicCells]->getPositions()[2];
FReal*const positionsZ = hypotheticNeighbor->getPositions()[2]; for(FSize idxPart = 0; idxPart < periodicNeighbors[nbPeriodicCells]->getNbParticles() ; ++idxPart){
for(FSize idxPart = 0; idxPart < hypotheticNeighbor->getNbParticles() ; ++idxPart){ 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;
// std::cout <<indexesNeighbors[idxNeigh] << " " << positionsX[idxPart] << " "<< positionsY[idxPart] << " "<< positionsZ[idxPart] <<std::endl; }
} ++nbPeriodicCells;
++nbPeriodicCells; neighbors[counter] = periodicNeighbors[nbPeriodicCells];
} }
++counter; ++counter;
} }
...@@ -2098,22 +2096,11 @@ protected: ...@@ -2098,22 +2096,11 @@ protected:
if(nbPeriodicCells >0){ if(nbPeriodicCells >0){
//to Do //to Do
for(int i=0 ; i < nbPeriodicCells ; ++i){ for(int i=0 ; i < nbPeriodicCells ; ++i){
auto hypotheticNeighbor = periodicNeighbors[i] ; delete periodicNeighbors[i] ;
auto & offSet = periodicOffset[i];
FReal*const positionsX = hypotheticNeighbor->getPositions()[0];
FReal*const positionsY = hypotheticNeighbor->getPositions()[1];
FReal*const positionsZ = hypotheticNeighbor->getPositions()[2];
for(FSize idxPart = 0; idxPart < hypotheticNeighbor->getNbParticles() ; ++idxPart){
positionsX[idxPart] -= offSet[0];
positionsY[idxPart] -= offSet[1];
positionsZ[idxPart] -= offSet[2];
}
} }
} }
} }
} // end for loop } // end for loop
#pragma omp barrier
} }
delete[] leafsDataArray; delete[] leafsDataArray;
......
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