00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <sstream>
00020 #include <iomanip>
00021 #include <algorithm>
00022 #include <numeric>
00023
00024 #include "QCReader.hpp"
00025 #include "config.h"
00026 #include "QCTools.hpp"
00027 #include "QCTable.hpp"
00028 #include "QCMndoParam.hpp"
00029 #include "QCAm1Param.hpp"
00030 #include "QCPm3Param.hpp"
00031 #include "QCSystem.hpp"
00032 #include "QCMDSystem.hpp"
00033 #include "QCDistMDSystem.hpp"
00034 #include "QCDCAlgo.hpp"
00035
00036
00040 const string QCReader::NB_ATOMS ("QCPP NB ATOMS");
00041 const string QCReader::NB_ATOM_TYPES ("QCPP NB ATOM TYPES");
00042 const string QCReader::SYSTEM_CHARGE ("QCPP SYSTEM CHARGE");
00043 const string QCReader::SPIN_MULTIPLICITY ("QCPP SPIN MULTIPLICITY");
00044 const string QCReader::COMMENT ("//");
00045
00049 const string QCReader::GENERAL_FILE ("QCPP GENERAL FILE");
00050 const string QCReader::PARAMETER_FILE ("QCPP PARAMETERS FILE");
00051 const string QCReader::ATOMS_FILE ("QCPP ATOMS FILE");
00052 const string QCReader::RESULT_FILE ("QCPP RESULT FILE");
00053 const string QCReader::DENSITY_FILE ("QCPP DENSITY FILE");
00054 const string QCReader::PARTITION_FILE ("QCPP PARTITION FILE");
00055
00056
00060 const string QCReader::MODEL_TYPE ("QCPP MODEL TYPE");
00061 const string QCReader::PARAMETER_TYPE ("QCPP PARAMETER TYPE");
00062 const string QCReader::COMPUTATION_TYPE ("QCPP CALCULATION TYPE");
00063 const string QCReader::MAIN_ALGORITHM ("QCPP MAIN ALGORITHM TYPE");
00064 const string QCReader::DIAGO_ALGORITHM ("QCPP DIAGONALISATION ALGORITHM");
00065 const string QCReader::SHIFT_LEVEL_PARAM ("QCPP SHIFTING LEVEL PARAMETER");
00066 const string QCReader::INTG_ACQUISITION_METHOD ("QCPP INTEGRALS ACQUISITION METHOD");
00067 const string QCReader::INIT_DENSITY_MATRIX ("QCPP INIT DENSITY MATRIX");
00068 const string QCReader::ENERGY_THRESHOLD ("QCPP ENERGY THRESHOLD");
00069 const string QCReader::ENERGY_MAX_ITER ("QCPP ENERGY NB MAX ITE");
00070 const string QCReader::DERIVATION_TYPE ("QCPP DERIVATION TYPE");
00071 const string QCReader::DERIV_SHIFT_BHVR ("QCPP DERIVATION SHIFT BEHAVIOR");
00072 const string QCReader::DELTA_Q ("QCPP DELTAQ");
00073 const string QCReader::NB_PARTITIONS ("QCPP NB PARTITIONS");
00074 const string QCReader::BUFFER_DIAMETER ("QCPP BUFFER DIAMETER");
00075 const string QCReader::CUT_RADIUS ("QCPP CUT RADIUS");
00076 const string QCReader::READ_PARTITION_FILE ("QCPP ONLY READER PARTITION");
00077 const string QCReader::PARTITION_TYPE ("QCPP PARTITION TYPE");
00078 const string QCReader::PARTITIONER_TYPE ("QCPP PARTITIONER TYPE");
00079
00080
00084 const string QCReader::NB_SUBDOMAIN ("NUMBER OF SUBDOMAINS");
00085 const string QCReader::NB_ATOMS_PART ("NUMBER OF ATOMS");
00086 const string QCReader::PARTITION_DESCRIPTION ("PARTITION DESCRIPTION");
00087 const string QCReader::PARTITION ("PARTITION");
00088 const string QCReader::COMMENT_BIS ("#");
00089 const string QCReader::BUFFER1_RADIUS ("RADIUS BUFFER1");
00090 const string QCReader::BUFFER2_RADIUS ("RADIUS BUFFER2");
00091 const string QCReader::PARTITION_TYPEP ("PARTITION TYPE");
00092
00093
00094
00098 const int QCReader::MAX_LENGTH (256);
00099
00100
00101
00102
00103
00104
00108 void
00109 QCReader::openFile (const string& name, const string& path) {
00110
00111 std::string fullpath ;
00112 if ( path == ".") {
00113 fullpath = name;}
00114 else {
00115 fullpath = path + PATH_SEPARATOR + name;
00116 }
00117 input = new ifstream (fullpath.c_str(), ios::in);
00118
00119 if (*input) {
00120 filename = name; inputPath = path;
00121
00122 } else {
00123
00125 cerr << "QCReader: openFile: file not found: " << fullpath <<endl;
00126 exit (EXIT_FAILURE);
00127 }
00128 }
00129
00130
00131
00132
00136 void
00137 QCReader::closeFile (void) {
00138 if (line){
00139 delete line;
00140 line = NULL;
00141 }
00142 if (input) {
00143 input->close();
00144 delete input;
00145 input = NULL;
00146 filename = "";
00147 }
00148 }
00149
00153 void
00154 QCReader::readMasterFile (const string& name, QCFiles& files, const string& path)
00155 {
00156
00157 this->openFile(name, path);
00158
00159 while (this->gotoNextValidLine(), !input->eof()) {
00160
00161 string literal (*line);
00162
00163 if (files.getMap().find(*line) == files.getMap().end()) {
00165 cerr << "QCReader: readMasterFile: bad literal: `"
00166 << literal << "'" << endl;
00167 exit (EXIT_FAILURE);
00168 }
00170 this->gotoNextValidLine();
00171 *(files.getMap()[literal]) = *line;
00172 }
00173 closeFile();
00174 }
00175
00176
00177
00181 void
00182 QCReader::readGeneralFile (const string& name, QCGeneralData& data, const string& path)
00183 {
00184 this->openFile(name, path);
00185
00186 while (this->gotoNextValidLine(), !input->eof()) {
00187
00188 string literal (*line);
00189
00190 if (data.getMap().find(*line) == data.getMap().end()) {
00192 #ifdef QC_DEBUG_READ
00193 cerr << "QCReader: readGeneralFile: unknown literal: `"
00194 << literal << "'" << endl
00195 << "QCReader: ignoring ..." << endl;
00196 #endif
00197 this->gotoNextValidLine();
00198 continue;
00199 }
00201 this->gotoNextValidLine();
00202 *(data.getMap()[literal]) = *line;
00203 }
00204 closeFile();
00206 data.reportStrValues();
00207
00208 data.setIsDCComputation() ;
00209 }
00210
00211
00212
00216 void
00217 QCReader::readAtomsFile (const string& name, QCSystem& system, const string& path)
00218 {
00219
00220 int readval, nMaxAA = 0;
00221 this->openFile(name, path);
00222
00224 readValAfterLiteral (SYSTEM_CHARGE, readval);
00225 system.setSystemCharge(readval);
00226
00228 this->readValAfterLiteral (SPIN_MULTIPLICITY, readval);
00229 system.setSpinMultiplicity(readval);
00230
00232 this->readValAfterLiteral (NB_ATOMS, readval);
00233
00234
00236 system.allocateAtoms(readval);
00237 int nbLink = 0 ;
00238 for (int i=0; (*input) && i<system.getNbAtoms(); i++) {
00239
00240 QCFloat coords[QCAtoms::DIMENSION];
00241 string type;
00242 int nfrag,nAA;
00243
00244 this->readAtomLine(type, coords, QCAtoms::DIMENSION, nfrag,nAA,
00245 system.fragName(i), system.getConnectivity(i));
00247 system.setPointAt(i, coords);
00248
00254 system.setType(i, table[type]);
00255
00259 system.setFragment(i, nfrag);
00260 nMaxAA = QCMax(nMaxAA,nAA);
00261
00262 nbLink += system.getConnectivity(i).size() ;
00263
00264 }
00265 system.setNbAA(nMaxAA+1) ;
00266 system.setNbLinks(nbLink);
00267 closeFile();
00268 }
00272 template <class TPParam>
00273 void
00274 QCReader::readParameterFile (const string& name, TPParam *& params,
00275 int& nbParams, const string& path)
00276 {
00277 this->openFile(name, path);
00278
00279 this->readValAfterLiteral(NB_ATOM_TYPES, nbParams);
00280 params = new TPParam [nbParams];
00281
00282 for (int i=0; i<nbParams; i++) {
00283 params[i].readSetOfParameters(this);
00284 }
00285
00286 closeFile();
00287 }
00288
00289
00290
00291
00295 template <class TPMDSystem>
00296 void
00297 QCReader::readPartitionFile (const string& name, QCGeneralData& data, TPMDSystem& mdSystem, const string& path)
00298 {
00299 QC_TRACE_INIT("BEGIN QCReader::readPartitionFile ");
00300
00301 this->openFile(name, path);
00302 std::string type(" "),NEW("NEW") ;
00303 std::stringstream ss ;
00304 int version ;
00305 if(line == NULL){
00306 line = new string ;
00307 }
00308 int pos, loc =-1 ;
00309 pos = input->tellg() ;
00310 while ( loc < 0) {
00311 std::getline(*input, *line);
00312 loc = line->find_last_of('.');
00313 }
00314 line->erase(line->begin(), line->begin()+loc-1);
00315 ss <<*line ; ss >> version ;
00316
00317 input->seekg(pos);
00318 line->clear() ;
00319 if(version == 2) {
00320
00321 this->readNewPartitionFile (data, mdSystem) ;
00322 }
00323 else if(version == 1){
00324
00325 this->readOldPartitionFile (data, mdSystem) ;
00326 }
00327 else {
00328 std::cerr << " Wrong format of partition file " << std::endl;
00329 exit(EXIT_FAILURE) ;
00330 }
00331 this->closeFile();
00332 QC_TRACE_INIT("END QCReader::readPartitionFile ");
00333 }
00334 template <class TPMDSystem>
00335 void
00336 QCReader::readNewPartitionFile (QCGeneralData& data, TPMDSystem& mdSystem )
00337 {
00338 QC_TRACE_INIT("BEGIN QCReader::readNewPartitionFile ");
00339 std::string type(" "),comment("#"),tmp;
00340 std::stringstream ss, ss1 ;
00341 int nPart;
00342 QCFloat R1,R2;
00343
00344
00345
00346 std::getline(*input, *line);
00347
00348 while ( (*line)[0] == comment[0]) {
00349
00350 std::getline(*input, *line);
00351 }
00352
00353
00354
00355 int pos = line->find_last_of(':'); line->erase(line->begin(), line->begin()+pos+1);
00356 ss << *line ; ss >> nPart ; ss.clear();
00357 data.setNumberOfPartitions(nPart) ;
00358
00359 std::getline(*input, *line);
00360
00361 pos = line->find_last_of(':'); line->erase(line->begin(), line->begin()+pos+1);
00362 ss << *line ; ss >> R1 ; ss.clear();
00363
00364 std::getline(*input, *line);
00365
00366 pos = line->find_last_of(':'); line->erase(line->begin(), line->begin()+pos+1);
00367 ss << *line ; ss >> R2 ; ss.clear();
00368 data.setRadius(R1,R2) ;
00369
00370 std::getline(*input, *line);
00371
00372 pos = line->find_last_of(':'); line->erase(line->begin(), line->begin()+pos+1);
00373 ss << *line ; ss >> type ; ss.clear();
00374 stringToUpper(type) ;
00375 data.setPartitionType(type);
00376
00377 mdSystem.allocDomains(nPart);
00378
00379
00380
00381 int nbNeigh, nbCore, nbBuffer1, nbBuffer2, currentSD;
00382 int localAtomIndex = 0,nbAO =0 ;
00383 QCPoint3D current;
00384 std::string NEWSUBDOM("Sub"),CUT("CUT"),END("END") ;
00385
00386 std::vector<int> coreAt ;
00387 std::vector< vector<int> > buffer1At ;
00388 std::vector< vector<int> > buffer2At;
00389
00390 std::vector<int> atomTab(mdSystem.getRootSystem().getNbAtoms()) ;
00391 std::vector<vector<QCAtomIn> > atomInSDs(mdSystem.getRootSystem().getNbAtoms()) ;
00392 std::vector<int> buffer1DomainID, sharedDomainId, buffer2DomainID ;
00393
00394 QCAtomIn currentAtomIn ;
00395 for ( int nsd = 0 ; nsd < nPart ; ++nsd) {
00396 currentAtomIn.numDomain = nsd ;
00397 for (unsigned int i = 0 ; i < atomTab.size() ; ++i){
00398 atomTab[i] = 0;
00399 }
00400 localAtomIndex = nbAO = 0 ;
00401 std::getline(*input, *line);
00402 pos = line->find_last_of(':'); line->erase(line->begin(), line->begin()+pos+1);
00403 ss << *line ; ss >> currentSD ; ss.clear();
00404 std::getline(*input, *line);
00405 ss << *line ;
00406 ss >> nbNeigh >> nbCore >> nbBuffer1 >> nbBuffer2 ;
00407 ss.clear();
00408
00409
00410
00411 std::getline(*input, *line);
00412 coreAt.resize(nbCore);
00413 buffer1At.resize(nbNeigh) ;
00414 buffer2At.resize(nbNeigh) ;
00415 buffer1DomainID.resize(nbNeigh) ;
00416 buffer2DomainID.resize(nbNeigh) ;
00417 sharedDomainId.resize(nbNeigh) ;
00418 for (int i = 0 ; i < nbNeigh; ++i){
00419 buffer1DomainID[i] = -1;
00420 buffer2DomainID[i] = -1;
00421 }
00422
00423 int currentNeigh , atSize ;
00424
00425
00426
00427 if( nbCore != 0){
00428 std::getline(*input, *line); ss <<*line ;
00429
00430 for ( int at = 0 ; at < nbCore; ++at)
00431 {
00432 ss >> coreAt[at];
00433 atomTab[coreAt[at]] = 1 ;
00434 nbAO += (table[mdSystem.getRootSystem().getType( coreAt[at])] == "H" )? 1 :4 ;
00435 ++localAtomIndex ;
00436 }
00437 }
00438 std::getline(*input, *line);
00439
00440
00441
00442 int pos, nbSD=0 ;
00443 pos = input->tellg() ;
00444 std::getline(*input, *line);
00445 while ( (*line)[3] != CUT[0]){
00446 ++nbSD ;
00447 std::getline(*input, *line);
00448 }
00449 input->seekg(pos) ;
00450 for (int currentVoisin = 0 ; currentVoisin < nbSD; ++currentVoisin){
00451 std::getline(*input, *line); ss <<*line ;
00452 ss >> currentNeigh >> atSize ;
00453 buffer1DomainID[currentVoisin] = currentNeigh;
00454 buffer1At[currentVoisin].resize(atSize) ;
00455 std::vector<int> & currentBuffer = buffer1At[currentVoisin] ;
00456 for (int at = 0 ; at < atSize ; ++at){
00457 ss >> currentBuffer[at] ;
00458 atomTab[currentBuffer[at]] = 1 ;
00459 nbAO += (table[mdSystem.getRootSystem().getType( currentBuffer[at])] == "H" )? 1 :4 ;
00460 ++localAtomIndex ;
00461 }
00462 ss.clear() ;
00463 }
00464
00465
00466
00467 std::getline(*input, *line);
00468 pos = input->tellg() ;
00469 nbSD = 0 ;
00470 std::getline(*input, *line);
00471 while ( !((*line)[0] == NEWSUBDOM[0] || (*line)[0] == END[0]) ){
00472 ++nbSD ;
00473 std::getline(*input, *line);
00474 }
00475
00476 input->seekg(pos) ;
00477
00478
00479 for (int currentVoisin = 0 ; currentVoisin < nbSD; ++currentVoisin){
00480 std::getline(*input, *line); ss <<*line ;
00481
00482 ss >> currentNeigh >> atSize ;
00483
00484 buffer2DomainID[currentVoisin] = currentNeigh;
00485 buffer2At[currentVoisin].resize(atSize) ;
00486
00487 std::vector<int> & currentBuffer = buffer2At[currentVoisin] ;
00488 for (int at = 0 ; at < atSize ; ++at){
00489 ss >> currentBuffer[at] ;
00490 atomTab[currentBuffer[at]] = 1 ;
00491 nbAO += (table[mdSystem.getRootSystem().getType( currentBuffer[at])] == "H" )? 1 :4 ;
00492 ++localAtomIndex ;
00493 }
00494 ss.clear() ;
00495 }
00496
00497
00498
00499 int nbV1 = 0 , nbV2 = 0 ;
00500 for( int i= 0 ; i < nbNeigh ;++ i){
00501 if (buffer1DomainID[i] != -1){ ++nbV1;}
00502 if (buffer2DomainID[i] != -1){ ++nbV2;}
00503 }
00504 if (nbV1 == nbNeigh ) {
00505 sharedDomainId = buffer1DomainID ;
00506 }
00507 else if (nbV2 == nbNeigh ) {
00508 sharedDomainId = buffer2DomainID ;
00509 }
00510 else{
00511 int pos = 0 ;
00512 bool isFind ;
00513 for( int i= 0 ; i < nbNeigh ;++ i){
00514 if (buffer1DomainID[i] != -1){
00515 sharedDomainId[pos] = buffer1DomainID[i] ;
00516 ++pos;
00517 }
00518 for( int i= 0 ; i < nbNeigh ;++ i){
00519 isFind = false ;
00520 if (buffer2DomainID[i] != -1){
00521 for( int j= 0 ; j < pos ;++ j){
00522 if(sharedDomainId[j] == buffer1DomainID[i]){
00523 isFind = true ; break ;
00524 }
00525 }
00526 if(isFind){continue ;}
00527 sharedDomainId[pos] = buffer2DomainID[i] ;
00528 ++pos;
00529 }
00530 }
00531 }
00532 }
00533
00534
00535
00536
00537
00538
00539 int nbshared [nbNeigh] ;
00540 for( int i= 0 ; i < nbNeigh ;++ i){
00541 nbshared[i]= buffer2At[i].size() + buffer1At[i].size();
00542 }
00543 int nblocAtom;
00544 nblocAtom = std::accumulate(atomTab.begin(),atomTab.end(), 0) ;
00545
00546 mdSystem.allocStructures(nsd, nblocAtom, nbAO, nbNeigh, &sharedDomainId[0], nbshared);
00547
00548
00549
00550 int globalIdx , localIdx ;
00551 QCPoint3D current;
00552 localIdx = 0 ;
00553 currentAtomIn.typeZone = QC_CORE ;
00554 for (unsigned int at = 0 ; at < coreAt.size() ; ++at ){
00555 globalIdx = coreAt[at] ;
00556 currentAtomIn.localNum = at ;
00557 atomTab[globalIdx] = 0 ;
00558 mdSystem.getRootSystem().getPointAt(globalIdx, current);
00559 atomInSDs[globalIdx].push_back(currentAtomIn) ;
00560 mdSystem.addAtom(current, mdSystem.getRootSystem().getType(globalIdx),
00561 globalIdx, nsd, QC_CORE , at);
00562
00563 }
00564 localIdx = coreAt.size() ;
00565 currentAtomIn.typeZone = QC_SHELL1 ;
00566 for (unsigned int n = 0 ; n < buffer1At.size() ; ++n ){
00567 for (unsigned int at = 0 ; at < buffer1At[n].size() ; ++at ){
00568 globalIdx = buffer1At[n][at] ;
00569 if ( atomTab[globalIdx] == 1){
00570 mdSystem.getRootSystem().getPointAt(globalIdx, current);
00571 mdSystem.addAtom(current, mdSystem.getRootSystem().getType(globalIdx),
00572 globalIdx, nsd, QC_SHELL1 , localIdx);
00573 currentAtomIn.localNum = localIdx ;
00574 atomInSDs[globalIdx].push_back(currentAtomIn) ;
00575 ++localIdx ;
00576 atomTab[globalIdx] = 0 ;
00577 }
00578 }
00579 }
00580 currentAtomIn.typeZone = QC_SHELL2 ;
00581 for (unsigned int n = 0 ; n < buffer2At.size() ; ++n ){
00582 for (unsigned int at = 0 ; at < buffer2At[n].size() ; ++at ){
00583 globalIdx = buffer2At[n][at] ;
00584 if ( atomTab[globalIdx] == 1){
00585 mdSystem.getRootSystem().getPointAt(globalIdx, current);
00586 mdSystem.addAtom(current, mdSystem.getRootSystem().getType(globalIdx),
00587 globalIdx, nsd, QC_SHELL2 , localIdx);
00588 atomTab[globalIdx] = 0 ;
00589 currentAtomIn.localNum = localIdx ;
00590 atomInSDs[globalIdx].push_back(currentAtomIn) ;
00591 ++localIdx ;
00592 }
00593 }
00594 }
00595 coreAt.clear();
00596 for (unsigned int i = 0 ; i < buffer1At.size(); ++i){
00597 buffer1At[i].clear() ;
00598 buffer1At[i].clear() ;
00599 }
00600 buffer1At.clear() ;
00601 buffer2At.clear() ;
00602 buffer1DomainID.clear() ;
00603 buffer2DomainID.clear() ;
00604 sharedDomainId.clear() ;
00605 }
00606
00607 for (int at = 0 ; at < mdSystem.getRootSystem().getNbAtoms() ; ++at){
00608 mdSystem.fillMaps(atomInSDs[at]);
00609 }
00610
00611 QC_TRACE_INIT("END QCReader::readNewPartitionFile ");
00612
00613 }
00614 template <class TPMDSystem>
00615 void
00616 QCReader::readOldPartitionFile (QCGeneralData& data, TPMDSystem& mdSystem )
00617 {
00618 QC_TRACE_INIT("BEGIN QCReader::readOldPartitionFile ");
00619
00621
00622
00623
00624 int nbDomains;
00625 QCFloat R1,R2;
00626 std::string type ;
00627 this->readValAfterLiteral(NB_SUBDOMAIN, nbDomains);
00628 data.setNumberOfPartitions (nbDomains) ;
00629 mdSystem.allocDomains(nbDomains);
00630
00631 this->readValAfterLiteral(BUFFER1_RADIUS, R1);
00632 this->readValAfterLiteral(BUFFER2_RADIUS, R2);
00633 data.setRadius(R1,R2) ;
00634 this->readValAfterLiteral(PARTITION_TYPEP, type);
00635 stringToUpper(type) ; data.setPartitionType(type);
00636
00638 int nbAtoms;
00639 this->readValAfterLiteral(NB_ATOMS_PART, nbAtoms);
00640 assert(mdSystem.getNbAtoms() == nbAtoms);
00641
00642 this->gotoNextValidLine();
00643 assert(*line == PARTITION_DESCRIPTION);
00644
00645
00647 for (int i=0; i < nbDomains; ++i) {
00648 this->gotoNextValidLine();
00649
00650 int sbdId, nbatoms, nbAO, nbovlp;
00651 int *sbdIds, *nbshared;
00652
00653 istringstream isstrm (*line);
00654 isstrm >> sbdId >> nbatoms >> nbAO >> nbovlp;
00655
00656 sbdIds = new int [nbovlp];
00657 nbshared = new int [nbovlp];
00658
00659 for (int j=0; j < nbovlp; ++j) {
00660 isstrm >> sbdIds[j] >> nbshared[j];
00661 }
00662
00663 mdSystem.allocStructures(sbdId, nbatoms, nbAO, nbovlp, sbdIds, nbshared);
00664
00665 delete [] sbdIds;
00666 delete [] nbshared;
00667 }
00668
00670 this->gotoNextValidLine();
00671 assert(*line == PARTITION);
00672
00673 for (int i=0; i < nbAtoms; ++i) {
00674 this->gotoNextValidLine();
00675 QCPoint3D current;
00676 mdSystem.getRootSystem().getPointAt(i, current);
00677
00678 int atomIdx, nbsbd;
00679 istringstream isstrm (*line);
00680 isstrm >> atomIdx >> nbsbd;
00681
00682 int * domainIds = new int [nbsbd];
00683 QCSubDomainZone * zones = new QCSubDomainZone [nbsbd];
00684 int * atomIdxs = new int [nbsbd];
00685
00686 for (int j=0; j < nbsbd; ++j) {
00687
00688 int zone;
00689 isstrm >> domainIds[j] >> zone >> atomIdxs[j];
00690 zones[j] = static_cast<QCSubDomainZone>(zone);
00691
00692 mdSystem.addAtom(current, mdSystem.getRootSystem().getType(i), i, domainIds[j], zones[j], atomIdxs[j]);
00693 }
00694
00695 mdSystem.fillMaps(nbsbd, domainIds, zones, atomIdxs);
00696
00697 delete [] domainIds;
00698 delete [] zones;
00699 delete [] atomIdxs;
00700 }
00701
00702 QC_TRACE_INIT("END QCReader::readOldPartitionFile ");
00703 }
00704
00705
00706
00707
00708
00709
00710
00711
00712
00716 void QCReader::gotoNextLine (void) {
00717
00718 char str [MAX_LENGTH];
00719 input->getline(str, MAX_LENGTH);
00720 if (line)
00721 delete line;
00722 line = new string (str);
00723 trim (*line);
00724 }
00725
00726
00727
00731 void
00732 QCReader::gotoNextValidLine (void) {
00733
00734 do {
00735
00736 gotoNextLine();
00737 if (lineIsValid())
00738 break;
00739
00740 }
00741 while (!input->eof());
00742
00743 #ifdef TRACE_LINE
00744 cout << "line: " << *line << endl;
00745 #endif //TRACE_LINE
00746 }
00747
00748
00752 void
00753 QCReader::readCoordLine (string& type, QCFloat* coords, const int dim, int& nfrag) {
00754
00755 this->gotoNextValidLine();
00756 std::istringstream iss (*line);
00757 iss >> type;
00758
00759
00760 for (int i = 0; i<dim; i++) {
00761 iss >> coords[i];
00762 }
00763
00764 int num;
00765
00766 if (!iss.eof()) {
00767 iss >> num;
00768 }
00769
00770 if (!iss.eof()) {
00771 std::string frag;
00772 iss >> frag;
00773 int st = frag.find_last_of('-');
00774 frag.erase(frag.begin(), frag.begin()+st+1);
00775 istringstream ss(frag);
00776 ss >> nfrag;
00777 }
00778
00779 }
00780
00781 void
00782 QCReader::readAtomLine (std::string& type, QCFloat* coords, const int dim,int& nfrag, int& nAA,
00783 std::string & fragStr, std::vector<int> &links ){
00784
00785 this->gotoNextValidLine();
00786 istringstream iss (*line);
00787 iss >> type;
00788
00789
00790 for (int i = 0; i<dim; i++) {
00791 iss >> coords[i];
00792 }
00793
00794 int num, nbConnect;
00795
00796 if (!iss.eof()) {
00797 iss >> num;
00798 }
00799
00800 if (!iss.eof()) {
00801 iss >> fragStr; nfrag = 0; nAA = 0 ;
00802 if(fragStr != "DefaultGroup"){
00803 std::string frag = fragStr ;
00804 int st = frag.find_last_of('-');
00805 frag.erase(frag.begin(), frag.begin()+st+1);
00806 istringstream ss(frag),ss1(frag);
00807 ss >> nfrag;
00808 frag = fragStr ;
00809 st = frag.find_last_of(':');
00810 frag.erase(frag.begin()+st,frag.end());
00811 st = frag.find_last_of('-');
00812 frag.erase(frag.begin(), frag.begin()+st+1);
00813 ss1 >> nAA;
00814 }
00815 }
00816 nbConnect = 0 ;
00817 if (!iss.eof()) {
00818 iss >> nbConnect;
00819 }
00820 links.resize(nbConnect) ;
00821 if(nbConnect != 0){
00822 int num ;
00823 for (int i = 0 ; i < nbConnect ; ++i){
00824 iss >> num ;
00825 links[i] = num -1 ;
00826 }
00827 }
00828 }
00829
00830
00831
00835 template void
00836 QCReader::readParameterFile<QCMndoParam> (const string& name, QCMndoParam *& params,
00837 int& nbParams, const string& path);
00838 template void
00839 QCReader::readParameterFile<QCAm1Param> (const string& name, QCAm1Param *& params,
00840 int& nbParams, const string& path);
00841 template void
00842 QCReader::readParameterFile<QCPm3Param> (const string& name, QCPm3Param *& params,
00843 int& nbParams, const string& path);
00844
00845 template void
00846 QCReader::readPartitionFile<QCMDSystem<QCDCAlgo> >
00847 ( const string& name,QCGeneralData & data, QCMDSystem<QCDCAlgo>& mdsystem,const string& path );
00848
00849
00850 #if defined(HAVE_MPI)
00851
00852 template void
00853 QCReader::readPartitionFile<QCDistMDSystem<QCDCAlgo> >( const string& name, QCGeneralData & data,
00854 QCDistMDSystem<QCDCAlgo>& mdsystem, const string& path );
00855 #endif