Commit 2a039931 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files
parents edd97550 29c8dac6
......@@ -128,12 +128,12 @@ public:
FReal x, y, z, fx, fy, fz, vx, vy, vz;
int index;
char type[2];
std::string line;
std::string line;
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
file.read(type, 2);
file >> index;
std::getline(file, line); // needed to skip the end of the line in non periodic case
std::getline(file, line); // needed to skip the end of the line in non periodic case
file >> x >> y >> z;
file >> vx >> vy >> vz;
......
......@@ -22,8 +22,6 @@
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include "../../Src/Core/FFmmAlgorithmThread.hpp"
#include "../../Src/Core/FFmmAlgorithmTask.hpp"
#include "../../Src/Kernels/Spherical/FSphericalKernel.hpp"
#include "../../Src/Kernels/Spherical/FSphericalCell.hpp"
......@@ -88,8 +86,6 @@ int main(int argc, char ** argv){
typedef FSphericalKernel<ParticleClass, CellClass, ContainerClass > KernelClass;
typedef FFmmAlgorithm<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithmThread<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassThread;
typedef FFmmAlgorithmTask<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassTask;
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test Spherical algorithm.\n";
std::cout << ">> You can pass -sequential or -task (thread by default).\n";
......@@ -124,6 +120,16 @@ int main(int argc, char ** argv){
counter.tic();
loader.fillTree(tree);
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
ParticleClass particle;
loader.fillParticle(particle);
// reset forces and insert in the tree
particle.setIndex(idxPart);
particle.setForces(0,0,0);
particle.setPotential(0);
// insert in tree
tree.insert(part);
}
counter.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
......@@ -142,21 +148,9 @@ int main(int argc, char ** argv){
std::cout << "Working on particles ..." << std::endl;
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute();
}
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
......@@ -171,7 +165,13 @@ int main(int argc, char ** argv){
while( iter.hasNotFinished() ){
potential += iter.data().getPotential() * iter.data().getPhysicalValue();
forces += iter.data().getForces();
std::cout << " " << iter.data().getIndex()+1 << " \t "<< std::setprecision(5)<< iter.data().getPosition().getX() << " \t" << iter.data().getPosition().getY() << " \t" << iter.data().getPosition().getZ() << " Forces: \t"<< std::setprecision(8)<< iter.data().getForces().getX()*coeff_MD << " \t " << iter.data().getForces().getY()*coeff_MD << " \t " << iter.data().getForces().getZ()*coeff_MD<< std::endl;
std::cout << " " << iter.data().getIndex()+1 << " \t "<<
std::setprecision(5)<< iter.data().getPosition().getX() << " \t" <<
iter.data().getPosition().getY() << " \t" <<
iter.data().getPosition().getZ() << " Forces: \t"<<
std::setprecision(8) << iter.data().getForces().getX()*coeff_MD << " \t " <<
iter.data().getForces().getY()*coeff_MD << " \t " <<
iter.data().getForces().getZ()*coeff_MD << std::endl;
iter.gotoNext();
}
......
......@@ -22,6 +22,7 @@
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Core/FFmmAlgorithmPeriodic.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include "../../Src/Kernels/Spherical/FSphericalKernel.hpp"
#include "../../Src/Kernels/Spherical/FSphericalCell.hpp"
......@@ -80,18 +81,23 @@ int main(int argc, char ** argv){
typedef FSphericalKernel<ParticleClass, CellClass, ContainerClass > KernelClass;
typedef FFmmAlgorithmPeriodic<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithm<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassNoPer;
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test Spherical algorithm.\n";
std::cout << ">> options are -h H -sh SH -P p -per PER -f FILE -noper -verbose\n";
std::cout << ">> Recommanded files : ../Data/EwalForcesPositionOut.txt ../Data/EwalNonPeriodic.txt ../Data/EwalPeriodic.txt\n";
//////////////////////////////////////////////////////////////
const int NbLevels = FParameters::getValue(argc,argv,"-h", 4);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 2);
const int DevP = FParameters::getValue(argc,argv,"-P", 9);
const int PeriodicDeep = FParameters::getValue(argc,argv,"-per", 2);
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/testEwal417.dt");
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/EwalPeriodic.txt");
// recommenda
FTic counter;
const FReal coeff_MD= 138935.4835 / 418.4 ;
const FReal coeff_MD = FReal(138935.4835 / 418.4);
// -----------------------------------------------------
......@@ -136,10 +142,17 @@ int main(int argc, char ** argv){
std::cout << "Create kernel & run simu ..." << std::endl;
counter.tic();
FmmClass algo(&tree,PeriodicDeep);
KernelClass kernels( DevP, algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter());
algo.setKernel(&kernels);
algo.execute();
if( FParameters::existParameter(argc, argv, "-noper") ){
KernelClass kernels( DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
FmmClassNoPer algo(&tree,&kernels);
algo.execute();
}
else{
FmmClass algo(&tree,PeriodicDeep);
KernelClass kernels( DevP, algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter());
algo.setKernel(&kernels);
algo.execute();
}
counter.tac();
......@@ -158,17 +171,28 @@ int main(int argc, char ** argv){
while( iter.hasNotFinished() ){
const ParticleClass& part = particles[iter.data().getIndex()];
// std::cout << ">> index " << iter.data().getIndex() << " type " << iter.data().getType() << std::endl;
// std::cout << "Good x " << part.getPosition().getX() << " y " << part.getPosition().getY() << " z " << part.getPosition().getZ() << std::endl;
// std::cout << "FMM x " << iter.data().getPosition().getX() << " y " << iter.data().getPosition().getY() << " z " << iter.data().getPosition().getZ() << std::endl;
// std::cout << "Good fx " <<part.getForces().getX() << " fy " << part.getForces().getY() << " fz " << part.getForces().getZ() << std::endl;
// std::cout << "FMM fx " << iter.data().getForces().getX() << " fy " << iter.data().getForces().getY() << " fz " << iter.data().getForces().getZ() << std::endl;
// std::cout << "GOOD physical value " << part.getPhysicalValue() << " potential " << part.getPotential() << std::endl;
// std::cout << "FMM physical value " << iter.data().getPhysicalValue() << " potential " << iter.data().getPotential() << std::endl;
// std::cout << "\n";
if(FParameters::existParameter(argc, argv, "-verbose")){
std::cout << ">> index " << iter.data().getIndex() << " type " << iter.data().getType() << std::endl;
std::cout << "Good x " << part.getPosition().getX() << " y " << part.getPosition().getY() << " z " << part.getPosition().getZ() << std::endl;
std::cout << "FMM x " << iter.data().getPosition().getX() << " y " << iter.data().getPosition().getY() << " z " << iter.data().getPosition().getZ() << std::endl;
std::cout << "Good fx " <<part.getForces().getX() << " fy " << part.getForces().getY() << " fz " << part.getForces().getZ() << std::endl;
std::cout << "FMM fx " << iter.data().getForces().getX() << " fy " << iter.data().getForces().getY() << " fz " << iter.data().getForces().getZ() << std::endl;
std::cout << "GOOD physical value " << part.getPhysicalValue() << " potential " << part.getPotential() << std::endl;
std::cout << "FMM physical value " << iter.data().getPhysicalValue() << " potential " << iter.data().getPotential() << std::endl;
std::cout << "\n";
}
potential += iter.data().getPotential() * iter.data().getPhysicalValue();
std::cout << " " << iter.data().getIndex()+1 << " \t "<< std::setprecision(5)<< iter.data().getPosition().getX() << " \t" << iter.data().getPosition().getY() << " \t" << iter.data().getPosition().getZ() << " Forces: \t"<< std::setprecision(8)<< iter.data().getForces().getX() << " \t " << iter.data().getForces().getY() << " \t " << iter.data().getForces().getZ()<< std::endl;
if(FParameters::existParameter(argc, argv, "-verbose")){
std::cout << " " << iter.data().getIndex()+1 << " \t "<<
std::setprecision(5)<< iter.data().getPosition().getX() << " \t" <<
iter.data().getPosition().getY() << " \t" <<
iter.data().getPosition().getZ() << " Forces: \t"<< std::setprecision(8)<<
iter.data().getForces().getX() << " \t " << iter.data().getForces().getY() <<
" \t " << iter.data().getForces().getZ()<< std::endl;
}
potentialDiff.add(part.getPotential(),iter.data().getPotential());
fx.add(part.getForces().getX(),iter.data().getForces().getX());
......@@ -197,6 +221,37 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
{ // get sum forces&potential
FReal potential = 0;
FPoint forces;
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
do{
ContainerClass::ConstBasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.hasNotFinished() ){
potential += iter.data().getPotential() * iter.data().getPhysicalValue();
forces += iter.data().getForces();
if(FParameters::existParameter(argc, argv, "-verbose")){
std::cout << " " << iter.data().getIndex()+1 << " \t "<<
std::setprecision(5)<< iter.data().getPosition().getX() << " \t" <<
iter.data().getPosition().getY() << " \t" <<
iter.data().getPosition().getZ() << " Forces: \t"<<
std::setprecision(8) << iter.data().getForces().getX()*coeff_MD << " \t " <<
iter.data().getForces().getY()*coeff_MD << " \t " <<
iter.data().getForces().getZ()*coeff_MD << std::endl;
}
iter.gotoNext();
}
} while(octreeIterator.moveRight());
std::cout << "Foces Sum x = " << forces.getX() << " y = " << forces.getY() << " z = " << forces.getZ() << std::endl;
std::cout << "Potential = " << potential*coeff_MD << std::endl;
std::cout << "Constante DL_POLY: " << coeff_MD << std::endl;
}
// -----------------------------------------------------
delete[] particles;
return 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