LinearPart.cpp

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <algorithm>
00003 #include <sstream>
00004 #include <fstream>
00005 #include <iostream>
00006 //
00007 #include "BoxPartition.h"
00008 #include "Atoms.h"
00009 //
00010 void usage_box()
00011 {
00012   std::cout << "Wrong number of arguments " << std::endl 
00013             << "LinearPart qciFileName genericPartitionFile numberOfPartitions Roverlap Rcut"<< std::endl
00014             <<std::endl;
00015   exit(1) ;
00016 }
00017 //
00018 //  Le programme principal
00019 //
00020 int main(int argc, char* argv[] ){
00021   //
00022   //  bool useFrag = false;
00023   bool useFrag = false;
00024   if(argc != 6 )
00025     { usage_box() ; }
00026   std::ifstream qciFile ;
00027   std::ofstream fragmentFile , outFile,infoFile;
00028   std::string fragmentFileName, qciFileName(argv[1]), partitionFileName ,outName(argv[2]);
00029   partitionFileName = outName + "-part" ; fragmentFileName = outName +".frag" ;
00030   std::string grid(argv[3]) ;
00031   //
00032   int gridPartition[3] ;
00033   int numberOfIterations = 10 ;
00034   double Roverlap = atof(argv[4]) , Rcut =  atof(argv[5]) ;
00035   //
00036   if (grid.find("x") > 3 ){
00037     std::stringstream ss ; ss << grid ; ss >> gridPartition[0]  ;
00038     gridPartition[1] = gridPartition[2] = 1 ;
00039   }
00040   else {
00041     std::string blanc(" ");
00042     grid[grid.find("x")] = blanc[0];  grid[grid.find("x")] =  blanc[0]; 
00043     std::stringstream ss; ss << grid ; ss >> gridPartition[0]  >> gridPartition[1]  >> gridPartition[2] ;
00044   }
00045   int numberOfPartitions = gridPartition[0]*gridPartition[1] *gridPartition[2]   ;
00046   //
00047   setOfAtoms      atoms ;
00048   //
00049   BoxPartition partition(gridPartition,Roverlap, Rcut) ;
00050   //
00051   // Ouverture des fichiers
00052   //
00053   qciFile.open(qciFileName.c_str()) ;
00054   if(  ! qciFile  ) {
00055     std::cerr <<" Le fichier "<<qciFileName << " n'existe pas. " <<std::endl;
00056     exit(1) ;}
00057   //
00058   std::cout <<" Debut de la lecture de "<<qciFileName <<std::endl;
00059   atoms.readQCIFile(qciFile) ; 
00060   qciFile.close();
00061   //
00062   partition.attachAtoms(&atoms) ;
00063   // 
00064   std::cout <<" debut du partitionnement "<<atoms.numberOfAtoms() <<std::endl;
00065   partition.partitionate(numberOfIterations,useFrag);
00066   //
00067   //  La sauvegarde
00068   //
00069   std::string F1(partitionFileName + ".qci") ;
00070   outFile.open(F1.c_str()) ;
00071   //  
00072   std::cout <<"partition.writeInFile("<<F1 <<"); " <<std::endl;
00073   partition.writeInFile(outFile);
00074   outFile.close();
00075   std::cout << "End of partition.newWriteInFile("<<F1 <<"); " <<std::endl;
00076   //
00077 
00078   F1 = partitionFileName + "-new.qci" ;
00079   outFile.open(F1.c_str()) ;
00080   std::cout <<"partition.writeInFile("<<F1 <<"); "<<std::endl;
00081   partition.newWriteInFile(outFile);
00082   outFile.close();
00083   std::cout << "End of partition.newWriteInFile("<<F1 <<"); " <<std::endl;
00084   //
00085   std::string FF(outName); FF += ".qci";
00086   outFile.open(FF.c_str()) ;
00087   atoms.writeQCIFile(outFile);
00088   outFile.close() ;
00089   exit(1);
00090   //
00091   std::cout << "end of program LinearPart"<<std::endl ;
00092   //
00093   return true ;
00094 }

Generated on Sat Jan 28 21:07:25 2006 for QC++ by  doxygen 1.4.4