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 89e17b15 authored by COULAUD Olivier's avatar COULAUD Olivier

Bugs with periodic conditions seem fixed. More tests should be done.

parent d303c1c9
...@@ -80,9 +80,9 @@ int main(int argc, char* argv[]) ...@@ -80,9 +80,9 @@ int main(int argc, char* argv[])
FParameterDefinitions::OutputFile, FParameterDefinitions::OutputFile,
FParameterDefinitions::NbThreads, FParameterDefinitions::NbThreads,
FParameterDefinitions::PeriodicityNbLevels, FParameterDefinitions::PeriodicityNbLevels,
localIncreaseBox localIncreaseBox
) )
; ;
const std::string defaultFile("../Data/test20k.fma"); const std::string defaultFile("../Data/test20k.fma");
const std::string filename = FParameters::getStr(argc,argv, FParameterDefinitions::InputFile.options, defaultFile.c_str()); const std::string filename = FParameters::getStr(argc,argv, FParameterDefinitions::InputFile.options, defaultFile.c_str());
...@@ -127,98 +127,98 @@ int main(int argc, char* argv[]) ...@@ -127,98 +127,98 @@ int main(int argc, char* argv[])
auto boxWidth = loader.getBoxWidth() ; auto boxWidth = loader.getBoxWidth() ;
// //
if(FParameters::existParameter(argc, argv, localIncreaseBox.options)){ if(FParameters::existParameter(argc, argv, localIncreaseBox.options)){
FReal ratio= FParameters::getValue(argc, argv, localIncreaseBox.options, 1.0); FReal ratio= FParameters::getValue(argc, argv, localIncreaseBox.options, 1.0);
boxWidth *= ratio; boxWidth *= ratio;
} }
// Initialize empty oct-tree // Initialize empty oct-tree
OctreeClass tree(TreeHeight, SubTreeHeight, boxWidth, loader.getCenterOfBox()); OctreeClass tree(TreeHeight, SubTreeHeight, boxWidth, loader.getCenterOfBox());
FSize localParticlesNumber = 0 ; FSize localParticlesNumber = 0 ;
// ----------------------------------------------------- // -----------------------------------------------------
if(app.global().processId() == 0){ if(app.global().processId() == 0){
std::cout << "Loading & Inserting " << loader.getNumberOfParticles() std::cout << "Loading & Inserting " << loader.getNumberOfParticles()
<< " particles ..." << std::endl << " particles ..." << std::endl
<<" Box: "<< std::endl <<" Box: "<< std::endl
<< " width " << boxWidth << std::endl << " width " << boxWidth << std::endl
<< " Centre " << loader.getCenterOfBox()<< std::endl; << " Centre " << loader.getCenterOfBox()<< std::endl;
std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl;
} }
time.tic(); time.tic();
/* Mock particle structure to balance the tree over the processes. */
struct TestParticle{
FSize index; // Index of the particle in the original file.
FPoint<FReal> position; // Spatial position of the particle.
FReal physicalValue; // Physical value of the particle.
/* Returns the particle position. */
const FPoint<FReal>& getPosition(){
return position;
}
};
// Temporary array of particles read by this process.
TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()];
memset(particles, 0, (sizeof(TestParticle) * loader.getMyNumberOfParticles()));
// Index (in file) of the first particle that will be read by this process.
FSize idxStart = loader.getStart();
std::cout << "Proc:" << app.global().processId() << " start-index: " << idxStart << std::endl;
// Read particles from parts.
for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){
// Store the index (in the original file) the particle.
particles[idxPart].index = idxPart + idxStart;
// Read particle from file
loader.fillParticle(&particles[idxPart].position,
&particles[idxPart].physicalValue);
}
/* Mock particle structure to balance the tree over the processes. */ // Final vector of particles
struct TestParticle{ FVector<TestParticle> finalParticles;
FSize index; // Index of the particle in the original file. FLeafBalance balancer;
FPoint<FReal> position; // Spatial position of the particle. // Redistribute particules between processes
FReal physicalValue; // Physical value of the particle. FMpiTreeBuilder< FReal, TestParticle >::
/* Returns the particle position. */ DistributeArrayToContainer(app.global(),
const FPoint<FReal>& getPosition(){ particles,
return position; loader.getMyNumberOfParticles(),
} tree.getBoxCenter(),
}; tree.getBoxWidth(),
tree.getHeight(),
// Temporary array of particles read by this process. &finalParticles,
TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()]; &balancer);
memset(particles, 0, (sizeof(TestParticle) * loader.getMyNumberOfParticles()));
// Free temporary array memory.
// Index (in file) of the first particle that will be read by this process. delete[] particles;
FSize idxStart = loader.getStart();
std::cout << "Proc:" << app.global().processId() << " start-index: " << idxStart << std::endl; // Insert final particles into tree.
// Read particles from parts. for(FSize idx = 0 ; idx < finalParticles.getSize(); ++idx){
for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ tree.insert(finalParticles[idx].position,
// Store the index (in the original file) the particle. finalParticles[idx].index,
particles[idxPart].index = idxPart + idxStart; finalParticles[idx].physicalValue);
// Read particle from file }
loader.fillParticle(&particles[idxPart].position,
&particles[idxPart].physicalValue);
}
// Final vector of particles time.tac();
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
// Redistribute particules between processes
FMpiTreeBuilder< FReal, TestParticle >::
DistributeArrayToContainer(app.global(),
particles,
loader.getMyNumberOfParticles(),
tree.getBoxCenter(),
tree.getBoxWidth(),
tree.getHeight(),
&finalParticles,
&balancer);
// Free temporary array memory.
delete[] particles;
// Insert final particles into tree.
for(FSize idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position,
finalParticles[idx].index,
finalParticles[idx].physicalValue);
}
time.tac(); localParticlesNumber = finalParticles.getSize() ;
localParticlesNumber = finalParticles.getSize() ; double timeUsed = time.elapsed();
double minTime,maxTime;
std::cout << "Proc:" << app.global().processId()
<< " " << finalParticles.getSize()
<< " particles have been inserted in the tree. (@Reading and Inserting Particles = "
<< time.elapsed() << " s)."
<< std::endl;
double timeUsed = time.elapsed(); MPI_Reduce(&timeUsed,&minTime,1,MPI_DOUBLE,MPI_MIN,0,app.global().getComm());
double minTime,maxTime; MPI_Reduce(&timeUsed,&maxTime,1,MPI_DOUBLE,MPI_MAX,0,app.global().getComm());
std::cout << "Proc:" << app.global().processId() if(app.global().processId() == 0){
<< " " << finalParticles.getSize() std::cout << "readinsert-time-min:" << minTime
<< " particles have been inserted in the tree. (@Reading and Inserting Particles = " << " readinsert-time-max:" << maxTime
<< time.elapsed() << " s)." << std::endl;
<< std::endl; }
MPI_Reduce(&timeUsed,&minTime,1,MPI_DOUBLE,MPI_MIN,0,app.global().getComm());
MPI_Reduce(&timeUsed,&maxTime,1,MPI_DOUBLE,MPI_MAX,0,app.global().getComm());
if(app.global().processId() == 0){
std::cout << "readinsert-time-min:" << minTime
<< " readinsert-time-max:" << maxTime
<< std::endl;
}
// ----------------------------------------------------- // -----------------------------------------------------
std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount()); std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount());
...@@ -255,7 +255,25 @@ int main(int argc, char* argv[]) ...@@ -255,7 +255,25 @@ int main(int argc, char* argv[])
// FMM exectution FFmmFarField FFmmNearField // FMM exectution FFmmFarField FFmmNearField
algorithm->execute(FFmmNearField); algorithm->execute(FFmmNearField);
// //
algorithm->getMortonLeafDistribution(mortonLeafDistribution);
// auto nbProcess = app.global().processCount() ;
// auto level = tree.getHeight()- 1;
// for (int i =0; i < nbProcess ; ++i){
// auto I = algoPer.getWorkingInterval(level, i);
// mortonLeafDistribution[2*i] = I.leftIndex;
// mortonLeafDistribution[2*i+1] = I.rightIndex;
// }
// if(app.global().processId() == 0)
{
std::cout << app.global().processId() <<" Morton distribution "<< std::endl ;
for(auto v : mortonLeafDistribution)
std::cout << v << " ";
std::cout << std::endl;
}
app.global().barrier();
time.tac(); time.tac();
timeUsed = time.elapsed(); timeUsed = time.elapsed();
std::cout << "Done " << "(@Algorithm = " << time.elapsed() << " s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << time.elapsed() << " s)." << std::endl;
...@@ -268,70 +286,62 @@ int main(int argc, char* argv[]) ...@@ -268,70 +286,62 @@ int main(int argc, char* argv[])
} }
} }
// ----------------------------------------------------- // -----------------------------------------------------
//
// Some output
//
//
{ // -----------------------------------------------------
FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= (loader.getNumberOfParticles()-1); ;
FReal energy =0.0 ;
//
// Loop over all leaves
//
std::cout <<std::endl<<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl;
std::cout << std::scientific;
std::cout.precision(15) ;
FReal TotalPhysicalValue=0.0 ;
tree.forEachLeaf([&](LeafClass* leaf){
const FReal*const posX = leaf->getTargets()->getPositions()[0];
const FReal*const posY = leaf->getTargets()->getPositions()[1];
const FReal*const posZ = leaf->getTargets()->getPositions()[2];
const FReal*const potentials = leaf->getTargets()->getPotentials();
const FReal*const forcesX = leaf->getTargets()->getForcesX();
const FReal*const forcesY = leaf->getTargets()->getForcesY();
const FReal*const forcesZ = leaf->getTargets()->getForcesZ();
const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const FSize indexPartOrig = indexes[idxPart];
if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) {
std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig <<" potential " << potentials[idxPart]
<< " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart]
<< " Forces: " << forcesX[idxPart] << " " << forcesY[idxPart] << " "<< forcesZ[idxPart] <<std::endl;
}
energy += potentials[idxPart]*physicalValues[idxPart] ;
TotalPhysicalValue += physicalValues[idxPart] ;
}
});
FReal gloEnergy = app.global().reduceSum(energy);
if(0 == app.global().processId()){
std::cout <<std::endl<<"aboveRoot: " << aboveTree << " Energy: "<< energy<<" TotalPhysicalValue: " << TotalPhysicalValue<< std::endl; std::cout <<std::endl << "Proc "<< app.global().processId() << " Energy: "<< gloEnergy <<std::endl;
std::cout <<std::endl <<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl<<std::endl;
}
}
// -----------------------------------------------------
if(FParameters::existParameter(argc, argv, FParameterDefinitions::OutputFile.options)){
algorithm->getAndBuildMortonIndexAtLeaf(mortonLeafDistribution);
// //
if(app.global().processId() == 0) // Some output
{ //
std::cout << " Morton distribution "<< std::endl ; //
for(auto v : mortonLeafDistribution) { // -----------------------------------------------------
std::cout << v << " "; FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= (loader.getNumberOfParticles()-1); ;
FReal energy =0.0 ;
//
// Loop over all leaves
//
std::cout <<std::endl<<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl;
std::cout << std::scientific;
std::cout.precision(15) ;
FReal locTotalPhysicalValue=0.0 ;
tree.forEachLeaf([&](LeafClass* leaf){
const FReal*const posX = leaf->getTargets()->getPositions()[0];
const FReal*const posY = leaf->getTargets()->getPositions()[1];
const FReal*const posZ = leaf->getTargets()->getPositions()[2];
const FReal*const potentials = leaf->getTargets()->getPotentials();
const FReal*const forcesX = leaf->getTargets()->getForcesX();
const FReal*const forcesY = leaf->getTargets()->getForcesY();
const FReal*const forcesZ = leaf->getTargets()->getForcesZ();
const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues();
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const FSize indexPartOrig = indexes[idxPart];
if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) )
{
std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig <<" potential " << potentials[idxPart]
<< " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart]
<< " Forces: " << forcesX[idxPart] << " " << forcesY[idxPart] << " "<< forcesZ[idxPart] <<std::endl;
}
energy += potentials[idxPart]*physicalValues[idxPart] ;
locTotalPhysicalValue += physicalValues[idxPart] ;
}
});
FReal gloEnergy = app.global().reduceSum(energy);
FReal TotalPhysicalValue = app.global().reduceSum(locTotalPhysicalValue);
if(0 == app.global().processId()){
std::cout <<std::endl<<"aboveRoot: " << aboveTree << " Energy: "<< energy<<" TotalPhysicalValue: " << TotalPhysicalValue<< std::endl; std::cout <<std::endl << "Proc "<< app.global().processId() << " Energy: "<< gloEnergy <<std::endl;
std::cout <<std::endl <<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl<<std::endl;
}
}
// -----------------------------------------------------
if(FParameters::existParameter(argc, argv, FParameterDefinitions::OutputFile.options)){
std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma"));
FMpiFmaGenericWriter<FReal> paraWriter(name,app);
paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,mortonLeafDistribution);
std::cout << std::endl;
} }
std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); return 0;
FMpiFmaGenericWriter<FReal> paraWriter(name,app);
paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,mortonLeafDistribution);
}
return 0;
} }
...@@ -151,12 +151,15 @@ public: ...@@ -151,12 +151,15 @@ public:
executeCore(operationsToProceed); executeCore(operationsToProceed);
} }
#ifdef SCALFMM_USE_MPI
/// Build and dill vector of the MortonIndex Distribution at Leaf level /// Build and dill vector of the MortonIndex Distribution at Leaf level
/// p = mpi process id then /// p = mpi process id then
/// [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p+1] is the morton index shared by process p /// [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p+1] is the morton index shared by process p
virtual void getAndBuildMortonIndexAtLeaf(std::vector<MortonIndex> & mortonLeafDistribution) {} ; virtual void getMortonLeafDistribution(std::vector<MortonIndex> & mortonLeafDistribution) {
#endif mortonLeafDistribution.resize(2) ;
mortonLeafDistribution[0] = 0 ;
mortonLeafDistribution[1] = 8 << (nbLevelsInTree-1) ;
};
}; };
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef FFMMALGORITHMTHREADPROC_HPP #ifndef FFMMALGORITHMTHREADPROC_HPP
#define FFMMALGORITHMTHREADPROC_HPP #define FFMMALGORITHMTHREADPROC_HPP
#define SCALFMM_DISTRIBUTED_ALGORITHM
#include <omp.h> #include <omp.h>
#include <algorithm> #include <algorithm>
// //
...@@ -138,9 +140,11 @@ public: ...@@ -138,9 +140,11 @@ public:
/// Build and dill vector of the MortonIndex Distribution at Leaf level /// Build and dill vector of the MortonIndex Distribution at Leaf level
/// p = mpi process id then /// p = mpi process id then
/// [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p+1] is the morton index shared by process p /// [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p+1] is the morton index shared by process p
void getAndBuildMortonIndexAtLeaf(std::vector<MortonIndex> & mortonLeafDistribution) final { void getMortonLeafDistribution(std::vector<MortonIndex> & mortonLeafDistribution) final {
for (int p=0 ; p< comm.processCount() ; ++p ){ mortonLeafDistribution.resize(2*nbProcess) ;
auto inter = getWorkingInterval(OctreeHeight-1, p ); auto level = OctreeHeight - 1;
for (int p=0 ; p< nbProcess ; ++p ){
auto inter = this->getWorkingInterval(level, p );
mortonLeafDistribution[2*p] = inter.leftIndex; mortonLeafDistribution[2*p] = inter.leftIndex;
mortonLeafDistribution[2*p+1] = inter.rightIndex; mortonLeafDistribution[2*p+1] = inter.rightIndex;
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef FFMMALGORITHMTHREADPROCPPERIODIC_HPP #ifndef FFMMALGORITHMTHREADPROCPPERIODIC_HPP
#define FFMMALGORITHMTHREADPROCPPERIODIC_HPP #define FFMMALGORITHMTHREADPROCPPERIODIC_HPP
#define SCALFMM_DISTRIBUTED_ALGORITHM
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <vector> #include <vector>
...@@ -28,6 +30,7 @@ ...@@ -28,6 +30,7 @@
#ifdef _OPENMP #ifdef _OPENMP
#include <omp.h> #include <omp.h>
#endif #endif
#include "FCoreCommon.hpp" #include "FCoreCommon.hpp"
#include "FP2PExclusion.hpp" #include "FP2PExclusion.hpp"
...@@ -95,6 +98,25 @@ public: ...@@ -95,6 +98,25 @@ public:
using local_expansion_t = typename CellClass::local_expansion_t; using local_expansion_t = typename CellClass::local_expansion_t;
using symbolic_data_t = CellClass; using symbolic_data_t = CellClass;
/// Get the Morton index Distribution at the leaf level
///
/// Fill the vector mortonDistribution
///
/// p = mpi process id then
/// Processor p owns indexes between [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p]+1]
///
/// parameter[out] mortonLeafDistribution
///
void getMortonLeafDistribution(std::vector<MortonIndex> & mortonLeafDistribution) final {
mortonLeafDistribution.resize(2*nbProcess) ;
auto level = OctreeHeight - 1;
for (int p=0 ; p< nbProcess ; ++p ){
auto inter = this->getWorkingInterval(level, p );
mortonLeafDistribution[2*p] = inter.leftIndex;
mortonLeafDistribution[2*p+1] = inter.rightIndex;
}
}
private: private:
/// Get an interval from a process id and tree level /// Get an interval from a process id and tree level
Interval& getWorkingInterval( int level, int proc){ Interval& getWorkingInterval( int level, int proc){
...@@ -105,7 +127,6 @@ private: ...@@ -105,7 +127,6 @@ private:
const Interval& getWorkingInterval( int level, int proc) const { const Interval& getWorkingInterval( int level, int proc) const {
return workingIntervalsPerLevel[OctreeHeight * proc + level]; return workingIntervalsPerLevel[OctreeHeight * proc + level];
} }
/// Does \a procIdx have work at given \a idxLevel /// Does \a procIdx have work at given \a idxLevel
/** i.e. does it hold cells and is responsible of them ? */ /** i.e. does it hold cells and is responsible of them ? */
bool procHasWorkAtLevel(const int idxLevel , const int idxProc) const { bool procHasWorkAtLevel(const int idxLevel , const int idxProc) const {
...@@ -134,7 +155,14 @@ public: ...@@ -134,7 +155,14 @@ public:
} }
} }
} }
// /// Build and dill vector of the MortonIndex Distribution at Leaf level
// /// p = mpi process id then
// /// [mortonLeafDistribution[2*p], mortonLeafDistribution[2*p+1] is the morton index shared by process p
// virtual void getAndBuildMortonIndexAtLeaf(std::vector<MortonIndex> & mortonLeafDistribution) {
// mortonLeafDistribution.resize(2*nbProcess) ;
// } ;
Interval& getWorkingInterval(const int level){ Interval& getWorkingInterval(const int level){
return getWorkingInterval(level, idProcess); return getWorkingInterval(level, idProcess);
...@@ -1697,13 +1725,15 @@ protected: ...@@ -1697,13 +1725,15 @@ protected:
if(needOther){ //means that something need to be sent (or received) if(needOther){ //means that something need to be sent (or received)
leafsNeedOther.set(idxLeaf,true); leafsNeedOther.set(idxLeaf,true);
++countNeedOther; ++countNeedOther;
// std::cout << " Leaf "<< iterArray[idxLeaf].getCurrentGlobalCoordinate().getMortonIndex() << std::endl ; // std::cout << " Leaf "<< iterArray[idxLeaf].getCurrentGlobalCoordinate().getMortonIndex() << std::endl ;
// for(int i = 0 ; i < nbProcess ; ++i ){ // for(int i = 0 ; i < nbProcess ; ++i ){
// std::cout << " "<< i << " alreadySent " << alreadySent[i]<< " " << toSend[i].size() <<" : "; // std::cout << " "<< i << " alreadySent " << alreadySent[i]<< " " << toSend[i].size() <<" : ";
// for(int j = 0 ; j < toSend[i].size() ; ++j ){ // for(int j = 0 ; j < toSend[i].size() ; ++j ){
// std::cout << " " << toSend[i][j].getCurrentGlobalCoordinate().getMortonIndex() ; // std::cout << " " << toSend[i][j].getCurrentGlobalCoordinate().getMortonIndex() ;
// } // }
// std::cout << std::endl; // std::cout << std::endl;
// }
} }
} }
...@@ -1818,7 +1848,7 @@ protected: ...@@ -1818,7 +1848,7 @@ protected:
// Check the new tree // Check the new tree
// std::cout <<"otherP2Ptree " << std::endl; // std::cout <<"otherP2Ptree " << std::endl;
// otherP2Ptree.forEachCellLeaf([&](CellClass* LeafCell, LeafClass* leaf){ // otherP2Ptree.forEachCellLeaf([&](CellClass* LeafCell, LeafClass* leaf){
// std::cout << LeafCell->getMortonIndex() <<" leaf " << leaf << " source " <<leaf->getSrc() << std::endl; // std::cout << LeafCell->getMortonIndex() <<" leaf " << leaf << " source " <<leaf->getSrc() << std::endl;
// } ); // } );
...@@ -1932,7 +1962,7 @@ protected: ...@@ -1932,7 +1962,7 @@ protected:
// //
if(hasPeriodicLeaves){ if(hasPeriodicLeaves){
// Current cell has periodic cells // Current cell has periodic cells
constexpr int maxPeriodicNeighbors = 26; constexpr int maxPeriodicNeighbors = 19;
ContainerClass* periodicNeighbors[maxPeriodicNeighbors]{}; ContainerClass* periodicNeighbors[maxPeriodicNeighbors]{};
int periodicNeighborPositions[maxPeriodicNeighbors]; int periodicNeighborPositions[maxPeriodicNeighbors];
// std::array<FTreeCoordinate,maxPeriodicNeighbors> periodicOffsets{} ; // std::array<FTreeCoordinate,maxPeriodicNeighbors> periodicOffsets{} ;
...@@ -1951,10 +1981,14 @@ protected: ...@@ -1951,10 +1981,14 @@ protected:
FReal yoffset= boxWidth * FReal(offsets[idxNeig].getY()) ; FReal yoffset= boxWidth * FReal(offsets[idxNeig].getY()) ;
FReal zoffset= boxWidth * FReal(offsets[idxNeig].getZ()) ; FReal zoffset= boxWidth * FReal(offsets[idxNeig].getZ()) ;
for(FSize idxPart = 0; idxPart < periodicNeighbors[periodicNeighborsCounter]->getNbParticles() ; ++idxPart){ for(FSize idxPart = 0; idxPart < periodicNeighbors[periodicNeighborsCounter]->getNbParticles() ; ++idxPart){
// std::cout << " Xo " << positionsX[idxPart] << " " << positionsY[idxPart] << " " << positionsZ[idxPart] <<std::endl;
// std::cout << " Offset " << xoffset << " " << yoffset << " " << zoffset <<std::endl;
positionsX[idxPart] += xoffset; positionsX[idxPart] += xoffset;
positionsY[idxPart] += yoffset; positionsY[idxPart] += yoffset;
positionsZ[idxPart] += zoffset; positionsZ[idxPart] += zoffset;
} // std::cout << " Xn " << positionsX[idxPart] << " " << positionsY[idxPart] << " " << positionsZ[idxPart] <<std::endl;
}
// periodicOffsets[periodicNeighborsCounter] = offsets[idxNeig]; // periodicOffsets[periodicNeighborsCounter] = offsets[idxNeig];
periodicNeighborPositions[periodicNeighborsCounter] = neighborPositions[idxNeig]; periodicNeighborPositions[periodicNeighborsCounter] = neighborPositions[idxNeig];
...@@ -1962,7 +1996,7 @@ protected: ...@@ -1962,7 +1996,7 @@ protected:
} }
else{ // set non periodic cells in neighbors and in neighborPositions else{ // set non periodic cells in neighbors and in neighborPositions
// nonPeriodicCounter versus idxNeig-periodicNeighborsCounter // nonPeriodicCounter versus idxNeig-periodicNeighborsCounter
std::cout << nonPeriodicCounter <<" "<< idxNeig-periodicNeighborsCounter <<std::endl; // std::cout << nonPeriodicCounter <<" "<< idxNeig-periodicNeighborsCounter <<std::endl;
neighbors[idxNeig-periodicNeighborsCounter] = neighbors[idxNeig]; neighbors[idxNeig-periodicNeighborsCounter] = neighbors[idxNeig];