Commit 89e17b15 authored by COULAUD Olivier's avatar COULAUD Olivier

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

parent d303c1c9
......@@ -82,7 +82,7 @@ int main(int argc, char* argv[])
FParameterDefinitions::PeriodicityNbLevels,
localIncreaseBox
)
;
;
const std::string defaultFile("../Data/test20k.fma");
const std::string filename = FParameters::getStr(argc,argv, FParameterDefinitions::InputFile.options, defaultFile.c_str());
......@@ -255,7 +255,25 @@ int main(int argc, char* argv[])
// FMM exectution FFmmFarField 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();
timeUsed = time.elapsed();
std::cout << "Done " << "(@Algorithm = " << time.elapsed() << " s)." << std::endl;
......@@ -268,24 +286,24 @@ 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) ;
// -----------------------------------------------------
//
// 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 ;
FReal locTotalPhysicalValue=0.0 ;
tree.forEachLeaf([&](LeafClass* leaf){
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];
......@@ -301,37 +319,29 @@ tree.forEachLeaf([&](LeafClass* leaf){
for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const FSize indexPartOrig = indexes[idxPart];
if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) {
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] ;
locTotalPhysicalValue += physicalValues[idxPart] ;
}
});
FReal gloEnergy = app.global().reduceSum(energy);
if(0 == app.global().processId()){
});
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)){
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;
}
}
// -----------------------------------------------------
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);
}
return 0;
}
return 0;
}
......@@ -151,12 +151,15 @@ public:
executeCore(operationsToProceed);
}
#ifdef SCALFMM_USE_MPI
/// 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) {} ;
#endif
virtual void getMortonLeafDistribution(std::vector<MortonIndex> & mortonLeafDistribution) {
mortonLeafDistribution.resize(2) ;
mortonLeafDistribution[0] = 0 ;
mortonLeafDistribution[1] = 8 << (nbLevelsInTree-1) ;
};
};
......
......@@ -2,6 +2,8 @@
#ifndef FFMMALGORITHMTHREADPROC_HPP
#define FFMMALGORITHMTHREADPROC_HPP
#define SCALFMM_DISTRIBUTED_ALGORITHM
#include <omp.h>
#include <algorithm>
//
......@@ -138,9 +140,11 @@ 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
void getAndBuildMortonIndexAtLeaf(std::vector<MortonIndex> & mortonLeafDistribution) final {
for (int p=0 ; p< comm.processCount() ; ++p ){
auto inter = getWorkingInterval(OctreeHeight-1, p );
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;
}
......
This diff is collapsed.
......@@ -24,8 +24,8 @@
#include "Components/FTestCell.hpp"
#include "Components/FTestKernels.hpp"
#include "Core/FFmmAlgorithmThreadProcPeriodic.hpp"
#include "Core/FFmmAlgorithmPeriodic.hpp"
#include "Core/FFmmAlgorithmThreadProcPeriodic.hpp"
#include "Files/FMpiTreeBuilder.hpp"
......
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