extractPartition.cpp

Go to the documentation of this file.
00001 //*****************************************************************************//
00002 //                                                                             //
00003 //   Copyright (c) 2005                                                        //
00004 //      INRIA-Futurs                                                           //
00005 //*****************************************************************************//
00006 //                                                                             //
00007 //               *** NOTICE OF PROPRIETARY INFORMATION ***                     //
00008 //                                                                             //
00009 // The information contained in this file is considered proprietary and the    //
00010 // exclusive property of  INRIA. This information may not be disclosed,        //
00011 // duplicated or used, in whole or in part, for  any purpose  whatsoever       //
00012 // without express written authorization from INRIA                            //
00013 //                                                                             //
00014 //*****************************************************************************//
00015 //
00016 //  convertPartition: ../../include/QCAtoms.hpp:113: void QCAtoms::allocateAtoms(int): Assertion `atoms == __null' failed.
00017 //
00018 #include <string>
00019 #include <iostream>
00020 //
00021 #include "QCCommon.hpp"
00022 #include "QCReader.hpp"
00023 #include "QCManager.hpp"
00024 #include "QCFiles.hpp"
00025 //
00026 #include "QCPm3.hpp"
00027 #include "QCPm3Param.hpp"
00028 #include "QCMDSystem.hpp"
00029 #include "QCSystem.hpp"
00030 #include "QCDCAlgo.hpp"
00031 #include "QCKimikaPartitioner.hpp"
00032 
00033 #if defined (QC_TRACE_IN_FILE)  
00034 #include "QCTrace.hpp"
00035 #endif
00036 
00037 
00038 void help()
00039 {
00040   std::cout <<std::endl 
00041             <<"extractPartition -qci atomFileName -part partitionFileName -num nb -out filename" << std::endl
00042             <<std::endl; 
00043   exit(EXIT_FAILURE) ;
00044 }
00045 void usage()
00046 {
00047   std::cout << "Wrong number of arguments " << std::endl ;
00048   help();
00049   exit(EXIT_FAILURE) ;
00050 }
00051 
00052 int main (int argc, char **argv) 
00053 {
00054   
00055   std::string helpS("--help");
00056   //
00057   for( int i = 0 ; i < argc ; ++i){
00058     //    std::cout << i<<"  "<<argv[i] <<"    " << argc  <<std::endl;
00059     //    if (argv[i] == helpS )
00060     if (argv[i] == "--help\0" )
00061       { std::cout << "help call "<<std::endl;help();}
00062   }
00063 
00064   if(argc != 9){ usage() ; }
00065   std::ifstream dataFile;
00066   std::ofstream outFile;
00067   std::string atomsFileName, partFileName, outFileName, temp, format;
00068   int argATOMS= 0, argPartIN=0, argOUT=0, argF=0;
00069   int numberOfSD = -1;
00070 
00071   for ( int a = 1 ; a < argc ; a += 2){
00072     std::string tmp(argv[a]) ;
00073     if (tmp == "-qci"){
00074       argATOMS = a+1 ;
00075       atomsFileName.assign(argv[a+1]);
00076     }
00077     else if (tmp == "-part"){
00078       argPartIN = a+1 ;
00079       partFileName.assign(argv[a+1]);
00080     }
00081     else if (tmp == "-out"){
00082       argOUT  = a+1 ;
00083       outFileName.assign(argv[a+1]);
00084     }
00085     else if ( tmp == "-n" || tmp == "-num"){
00086       argF = a+1 ;
00087       numberOfSD = atoi (argv[a+1]);
00088     }
00089   }
00090   //
00091   QCReader      reader;
00092   QCFiles       files;
00093   QCGeneralData data;
00094   //
00095   QCManager<QCPm3T<QCPm3Param>, QCMDSystem<QCDCAlgo> > manager;
00096   //
00097   //
00098   std::string parameterFile("Pm3Param") ;
00099   //
00100   files.parameterFile() = parameterFile ;
00101   files.atomsFile()     = atomsFileName ;
00102   files.partitionFile() = partFileName ;
00103   files.resultFile()    = outFileName ;
00104   //
00105   QCMDSystem<QCDCAlgo>  & mdSystem = manager.getSystem() ;
00106 
00107   QCKimikaPartitioner<QCMDSystem<QCDCAlgo> > partitioner ;
00108   data.setReadPartitionFileON() ;
00109   data.isDCComputation()         = true ;
00110   data.setComputationType("Tools");
00111   //
00112   //
00113   QC_TRACE("MAIN manager.init ");
00114   manager.initTools(files, data, ".");
00115   //
00116   cout <<   ">>> FILES <<<\n"        << manager.getFiles()       << endl
00117        <<   ">>> GENERAL DATA <<<\n" << manager.getGeneralData() << endl;
00118 
00119 
00120   std::cout << "Read partition file" <<std::endl;
00121   
00122   manager.getPartitioner() = &partitioner ;
00123   partitioner.readFromFile( mdSystem, const_cast<QCGeneralData&>(manager.getGeneralData()),
00124                             manager.getFiles(),  ".");
00125   manager.getPartitioner() = NULL ; 
00126   //
00127   //  Save parttion file in different formats
00128   //
00129   outFile.open(outFileName.c_str());
00130   //
00131   std::cout << " Write subDomain "<< numberOfSD << " in VTK format." <<std::endl;
00132   partitioner.writeSubDomainVTK(outFile,mdSystem.getSubDomain(numberOfSD)); 
00133   //
00134   outFile.close();
00135   //
00136   return QCPP_SUCCES;
00137 }

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