Commit 3bd7cd3e authored by BRAMAS Berenger's avatar BRAMAS Berenger

Update ewal test file

parent 46e30723
......@@ -52,29 +52,29 @@ public:
char buffer[bufferSize];
file.getline(buffer, bufferSize);
int imcon ;
int imcon ;
int tempi(0);
FReal tempf(0);
file >> tempi >> imcon >> this->nbParticles >> tempf;
if(imcon >0 ) {
FReal widthx, widthy, widthz;
file >> widthx >> tempf >> tempf;
file >> tempf >> widthy >> tempf;
file >> tempf >> tempf >> widthz;
// this->centerOfBox.setPosition(0.0,0.0,0.0);
this->boxWidth = widthx;
}
else{ // Non periodic case.
this->boxWidth = tempf ;
}
this->centerOfBox.setPosition(0.0,0.0,0.0);
file >> tempi >> imcon >> this->nbParticles;
// Periodic case
if( imcon > 0 ) {
FReal widthx, widthy, widthz;
file >> widthx >> tempf >> tempf;
file >> tempf >> widthy >> tempf;
file >> tempf >> tempf >> widthz;
this->boxWidth = widthx;
}
// Non periodic case
else{
file >> this->boxWidth;
}
this->centerOfBox.setPosition(0.0,0.0,0.0);
}
else {
this->boxWidth = 0;
this->nbParticles = 0;
this->boxWidth = 0;
this->nbParticles = 0;
}
std::cout << "boxWidth: "<< this->boxWidth <<std::endl ;
}
/**
* Default destructor, simply close the file
......@@ -130,15 +130,15 @@ public:
char type[2];
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
file >> x >> y >> z;
file >> vx >> vy >> vz;
file >> fx >> fy >> fz;
// std::cout << " x >> y >> z: " << x<< " " <<y<< " " <<z <<std::endl;
// std::cout << " x >> y >> z: " << x<< " " <<y<< " " <<z <<std::endl;
inParticle.setPosition(x,y,z);
inParticle.setForces(fx,fy,fz);
//inParticle.setForces(vx,vy,vz);
......
......@@ -85,15 +85,15 @@ int main(int argc, char ** argv){
///////////////////////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";
std::cout << ">> options are -h H -sh SH -P p -per PER -f FILE -noper -verbose -gen\n";
std::cout << ">> Recommanded files : ../Data/EwalTest_Periodic.run ../Data/EwalTest_NoPeriodic.run\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/EwalPeriodic.txt");
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/EwalTest_Periodic.run");
// recommenda
FTic counter;
......@@ -253,6 +253,40 @@ int main(int argc, char ** argv){
}
// -----------------------------------------------------
// ReGenerate file
if( FParameters::existParameter(argc, argv, "-gen") ){
std::cout << "Generate ewal.out from input file" << std::endl;
std::ofstream fileout("ewal.out",std::ifstream::out);
std::ifstream file(filename,std::ifstream::in);
if(file.is_open()){
const int bufferSize = 512;
char buffer[bufferSize];
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
if( !FParameters::existParameter(argc, argv, "-noper") ){
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
}
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
file.getline(buffer, bufferSize);
fileout << buffer << '\n';
file.getline(buffer, bufferSize);
file.getline(buffer, bufferSize);
}
}
}
// end generate
// -----------------------------------------------------
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