- Timestamp:
- Feb 4, 2011, 6:56:38 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 3c58f8
- Parents:
- 266875
- git-author:
- Frederik Heber <heber@…> (02/01/11 15:23:06)
- git-committer:
- Frederik Heber <heber@…> (02/04/11 18:56:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TremoloParser.cpp
r266875 r72d108 34 34 #include <vector> 35 35 36 #include <boost/tokenizer.hpp> 36 37 #include <iostream> 37 38 #include <iomanip> … … 250 251 usedFields.push_back(keyword); 251 252 } 253 //DoLog(1) && (Log() << Verbose(1) << "INFO: " << usedFields << std::endl); 252 254 } 253 255 … … 267 269 atomInfo = &additionalAtomData[newAtom->getId()]; 268 270 TremoloKey::atomDataKey currentField; 269 string word; 270 int oldId; 271 double tmp; 272 273 lineStream << line; 271 ConvertTo<double> toDouble; 272 ConvertTo<int> toInt; 273 274 // setup tokenizer, splitting up white-spaced entries 275 typedef boost::tokenizer<boost::char_separator<char> > 276 tokenizer; 277 boost::char_separator<char> whitespacesep(" \t"); 278 tokenizer tokens(line, whitespacesep); 279 ASSERT(tokens.begin() != tokens.end(), 280 "TremoloParser::readAtomDataLine - empty string, need at least ' '!"); 281 tokenizer::iterator tok_iter = tokens.begin(); 282 // then associate each token to each file 274 283 for (it = usedFields.begin(); it < usedFields.end(); it++) { 275 currentField = knownKeys[it->substr(0, it->find("="))]; 284 const std::string keyName = it->substr(0, it->find("=")); 285 currentField = knownKeys[keyName]; 286 const string word = *tok_iter; 287 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with remaining data " << word << std::endl); 276 288 switch (currentField) { 277 289 case TremoloKey::x : 278 290 // for the moment, assume there are always three dimensions 279 291 for (int i=0;i<NDIM;i++) { 280 lineStream >> tmp; 281 newAtom->set(i, tmp); 292 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!"); 293 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 294 newAtom->set(i, toDouble(*tok_iter)); 295 tok_iter++; 282 296 } 283 297 break; 284 298 case TremoloKey::u : 285 299 // for the moment, assume there are always three dimensions 286 lineStream >> newAtom->AtomicVelocity[0]; 287 lineStream >> newAtom->AtomicVelocity[1]; 288 lineStream >> newAtom->AtomicVelocity[2]; 300 for (int i=0;i<NDIM;i++) { 301 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!"); 302 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 303 newAtom->AtomicVelocity[i] = toDouble(*tok_iter); 304 tok_iter++; 305 } 289 306 break; 290 307 case TremoloKey::Type : 291 308 char type[3]; 292 lineStream >> type; 309 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 310 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 311 strncpy(type, (*tok_iter).c_str(), 3); 312 tok_iter++; 313 //type[1]='\0'; // cutoff after first char, correct for ATOM entries 293 314 newAtom->setType(World::getInstance().getPeriode()->FindElement(type)); 294 315 ASSERT(newAtom->getType(), "Type was not set for this atom"); 295 316 break; 296 317 case TremoloKey::Id : 297 lineStream >> oldId; 298 atomIdMap[oldId] = newAtom->getId(); 318 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 319 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 320 atomIdMap[toInt(*tok_iter)] = newAtom->getId(); 321 tok_iter++; 299 322 break; 300 323 case TremoloKey::neighbors : 324 for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) { 325 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 326 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 327 lineStream << *tok_iter << "\t"; 328 tok_iter++; 329 } 301 330 readNeighbors(&lineStream, 302 331 atoi(it->substr(it->find("=") + 1, 1).c_str()), newAtom->getId()); 303 332 break; 304 333 default : 305 lineStream >> word; 306 atomInfo->set(currentField, word); 307 break; 308 } 309 } 310 if (newmol != NULL) 334 ASSERT(tok_iter != tokens.end(), "TremoloParser::readAtomDataLine() - no value for "+keyName+"!"); 335 //DoLog(1) && (Log() << Verbose(1) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 336 atomInfo->set(currentField, *tok_iter); 337 tok_iter++; 338 break; 339 } 340 } 341 if (newmol != NULL) { 342 //DoLog(0) && (Log() << Verbose(0) << "New Atom: " << *newAtom << " with type " << newAtom->getType()->getName() << std::endl); 311 343 newmol->AddAtom(newAtom); 344 } 312 345 } 313 346 … … 325 358 // 0 is used to fill empty neighbor positions in the tremolo file. 326 359 if (neighborId > 0) { 327 // std::cout << "Atom with global id " << atomId << " has neighbour with serial " << neighborId << std::endl; 360 // DoLog(1) && (Log() << Verbose(1) 361 // << "Atom with global id " << atomId 362 // << " has neighbour with serial " << neighborId 363 // << std::endl); 328 364 additionalAtomData[atomId].neighbors.push_back(neighborId); 329 365 } … … 366 402 neighbor != currentInfo->second.neighbors.end(); neighbor++ 367 403 ) { 368 // std::cout<< "Creating bond between ("404 // DoLog(1) && (Log() << Verbose(1) << "Creating bond between (" 369 405 // << currentInfo->first 370 406 // << ") and (" 371 // << atomIdMap[*neighbor] << "|" << *neighbor << ")" << std::endl ;407 // << atomIdMap[*neighbor] << "|" << *neighbor << ")" << std::endl); 372 408 World::getInstance().getAtom(AtomById(currentInfo->first)) 373 409 ->addBond(World::getInstance().getAtom(AtomById(atomIdMap[*neighbor])));
Note:
See TracChangeset
for help on using the changeset viewer.