Commit a6ca1d08 authored by berenger-bramas's avatar berenger-bramas

Add an option -double to create two sphere in one file

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@339 2616d619-271b-44dc-8df4-d4a8f33a7222
parent e4075ed4
......@@ -29,27 +29,8 @@ int main(int argc, char ** argv){
// Nb of particles
const long NbParticles = FParameters::getValue(argc,argv,"-nb", long(20000));
// Center of the box
const FReal XCenter = 0.;
const FReal YCenter = 0.;
const FReal ZCenter = 0.;
// Box width
const FReal BoxWidth = 1.0;
// Output file please let .temp extension
const char defaultFilename[] = "../Data/testSphere20k.fma";
const char* Output;
if(argc == 1){
std::cout << "You have to give a filename in argument.\n";
std::cout << "The program will create one with a default name : " << defaultFilename << "\n";
Output = defaultFilename;
}
else{
Output = argv[1];
std::cout << "Creating : " << Output << "\n";
}
const char* const Output = FParameters::getStr(argc,argv,"-f", "../Data/testSphere20k.fma");
std::cout << "Creating : " << Output << "\n";
// Create file
std::ofstream myfile;
......@@ -63,25 +44,63 @@ int main(int argc, char ** argv){
std::cout << "Creating " << NbParticles << " particles at " << Output << "\n";
std::cout << "Working...\n";
const FReal FRandMax = FReal(RAND_MAX);
// Center of the box
const FReal XCenter = 0.;
const FReal YCenter = 0.;
const FReal ZCenter = 0.;
// Box width
const FReal BoxWidth = 1.0;
// System properties
myfile << NbParticles << " " << BoxWidth << " " << XCenter << " " << YCenter << " " << ZCenter;
if( !FParameters::findParameter(argc,argv,"-double") ){
const FReal rayon = FReal(0.4);
const FReal thresh = FReal(0.15);
const FReal threshDiv2 = thresh/2;
const FReal FRandMax = FReal(RAND_MAX);
const FReal rayon = FReal(0.4);
const FReal thresh = FReal(0.15);
const FReal threshDiv2 = thresh/2;
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " 0.01";
}
}
else{
const FReal rayon = FReal(0.2);
const FReal thresh = FReal(0.03);
const FReal threshDiv2 = thresh/2;
const FReal offset = FReal(0.25);
// Generate particles
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " 0.01";
}
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(rand())/FRandMax) * FMath::FPi;
const FReal omega = (FReal(rand())/FRandMax) * FMath::FPi * FReal(2);
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal px = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal py = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
const FReal pz = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(rand())/FRandMax) - threshDiv2;
myfile << " \n" << px << " " << py << " " << pz << " 0.01";
myfile << " \n" << px << " " << py << " " << pz << " 0.01";
}
}
myfile.close();
......
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