diff --git a/Examples/MPIInterpolationFMM.hpp b/Examples/MPIInterpolationFMM.hpp index fdd5a4cde3699bb98567da1901892b9bc88c0f77..a6e05ce4dba499d407f02fe908c493924de54ee6 100644 --- a/Examples/MPIInterpolationFMM.hpp +++ b/Examples/MPIInterpolationFMM.hpp @@ -207,8 +207,11 @@ int main(int argc, char* argv[]) << " readinsert-time-max:" << maxTime << std::endl; } - } // ----------------------------------------------------- + } + // ----------------------------------------------------- std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount()); + FAbstractAlgorithm * algorithm = nullptr; + FAlgorithmTimers * timer = nullptr; { // ----------------------------------------------------- std::cout << "\n"<<interpolationType<<" FMM Proc (ORDER="<< ORDER << ") ... " << std::endl; @@ -216,8 +219,7 @@ int main(int argc, char* argv[]) // Kernels to use (pointer because of the limited size of the stack) - FAbstractAlgorithm * algorithm = nullptr; - FAlgorithmTimers * timer = nullptr; + // non periodic FMM algorithm std::unique_ptr<KernelClass> kernelsNoPer(new KernelClass(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel)); @@ -252,68 +254,70 @@ int main(int argc, char* argv[]) std::cout << "exec-time-min:" << minTime << " exec-time-max:" << maxTime << std::endl; - } - // ----------------------------------------------------- - // - // 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(10) ; - - 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] ; - } - }); - FReal gloEnergy = app.global().reduceSum(energy); - if(0 == app.global().processId()){ - 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) - { - std::cout << " Morton distribution "<< std::endl ; - for(auto v : mortonLeafDistribution) - std::cout << v << " "; - - std::cout << std::endl; + +// ----------------------------------------------------- +// +// 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(10) ; + +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; } - std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); - FMpiFmaGenericWriter<FReal> paraWriter(name,app); - paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,mortonLeafDistribution); + energy += potentials[idxPart]*physicalValues[idxPart] ; + } +}); +FReal gloEnergy = app.global().reduceSum(energy); +if(0 == app.global().processId()){ + 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) + { + std::cout << " Morton distribution "<< std::endl ; + for(auto v : mortonLeafDistribution) + std::cout << v << " "; + std::cout << std::endl; } - return 0; + std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); + FMpiFmaGenericWriter<FReal> paraWriter(name,app); + paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,mortonLeafDistribution); + +} +return 0; }